diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..ff5ca685ed662c4d9cf5e468ad914ac4c251603e --- /dev/null +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -0,0 +1,24 @@ +**IssueNo**: + +**Description**: +(提交描述) + +**Feature or Bugfix**: +- [ ] Feature +- [ ] Bugfix + +**Binary Source**: +- [ ] No +- [ ] yes + +**预测试**: +- [ ] Pass +- [ ] Fail +- [ ] 评估不涉及 + +**合入前自检**: +- [ ] 不涉及性能或已进行性能测试且无性能劣化。 +- [ ] 符合对应的编码规范。 +- [ ] 不涉及文档更新,或已更新了文档。 +- [ ] 针对可测试性要求,已增加必要的自测用例、合理的日志记录或Trace信息。 +- [ ] 不存在非法的文件引入,包括图片和代码等。 \ No newline at end of file diff --git a/LICENSE_HW b/LICENSE_HW new file mode 100644 index 0000000000000000000000000000000000000000..4cc30cf5c3a35704ab29c02abf16f971cec62269 --- /dev/null +++ b/LICENSE_HW @@ -0,0 +1,21 @@ +Copyright 2021-2024 Huawei Device Co., Ltd. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the distribution. + + * Neither the name of Huawei Device Co., Ltd. nor the names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/LICENSE_KHZG b/LICENSE_KHZG new file mode 100644 index 0000000000000000000000000000000000000000..452a23994b23a7a5f0eb9be33af7058009eed20f --- /dev/null +++ b/LICENSE_KHZG @@ -0,0 +1,21 @@ +Copyright 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the distribution. + + * Neither the name of Hunan OpenValley Digital Industry Development Co., Ltd. nor the names of its contributors may be + used to endorse or promote products derived from this software without specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT +HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/OAT.xml b/OAT.xml index 1f5876088898c9ce3f7c46c84ba1023bf5801f27..757c2b5dcce849f920333d92e8df388c5ad56006 100644 --- a/OAT.xml +++ b/OAT.xml @@ -65,21 +65,30 @@ used to filter file path. desc="" name="projectPolicy"> + desc="" + filefilter="copyrightPolicyFilter" + name="Huawei Device Co., Ltd." + group="defaultGroup" + path=".*" + rule="may" + type="copyright"/> + + + + + + - + + + + + - + @@ -107,6 +124,53 @@ used to filter file path. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md index 16a40eda07f0aac888170c266e273952ecfe3eb0..2ee2ac6fa5816950849e60a2c5ca8d68e6f7e998 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ Flutter Engine 原始仓来源:https://github.com/flutter/engine -## 仓库说明: -本仓库是基于flutter官方engine仓库拓展,可构建支持在OpenHarmony设备上运行的flutter engine程序。 +## 仓库说明 +本仓库是基于flutter 3.7.12版本官方engine仓库拓展,可构建支持在OpenHarmony设备上运行的flutter engine程序。 -## 构建说明: +## 构建说明 * 构建环境: 1. 目前支持在Linux与Mac中构建,Window环境中支持构建gen_snapshot; @@ -26,7 +26,7 @@ Flutter Engine 配置node:下载 `node` 并解压,且配置到环境变量中: ``` - # nodejs + # nodejs (版本要求为v14.19.1及以上,且低于v17.0.0) export NODE_HOME=/home//env/node-v14.19.1-linux-x64 export PATH=$NODE_HOME/bin:$PATH ``` @@ -53,11 +53,11 @@ Flutter Engine 3. 同步代码:在engine目录,执行`gclient sync`;这里会同步engine源码、官方packages仓,还有执行ohos_setup任务; -4. 下载sdk: 从[鸿蒙SDK](https://developer.huawei.com/consumer/cn/develop)下载配套开发工具,暂不支持非该渠道下载的套件 +4. 下载sdk: 从[OpenHarmony SDK](https://developer.huawei.com/consumer/cn/develop)下载配套开发工具,暂不支持非该渠道下载的套件 ```sh # 需要设置的环境变量: HarmonyOS SDK, ohpm, hvigor, node - export TOOL_HOME=/Applications/DevEco-Studio.app/Contents # mac环境 + export TOOL_HOME=/Applications/DevEco-Studio.app/Contents # Mac环境 export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/ hvigor/bin @@ -72,31 +72,9 @@ Flutter Engine [构建产物](https://docs.qq.com/sheet/DUnljRVBYUWZKZEtF?tab=BB08J2) -## FAQ -1. 运行项目工程报Member notfound:'isOhos'的错误:请确保src/third_party/dart目录下应用了所有的dart patch(补丁位于src/flutter/attachment/repos目录,可使用git apply应用patch)应用patch后重新编译engine - -2. 提示Permission denied: 执行chmod +x <脚本文件> 添加执行权限 - -3. 单独编译debug/release/profile模式的engine:`./ohos -t debug|release|profile` - -4. 查看帮助:`./ohos -h` - -5. 由于windows和mac、linux对换行符处理方式不同,在应用dart补丁时会造成dart vm snapshot hash结果不同,可通过以下方法获取当前snapshot hash值 - -6. MediaQuery组件暂不支持displayFeatureType和displayFeatureState信息 - - ```shell - python xxx/src/third_party/dart/tools/make_version.py --format='{{SNAPSHOT_HASH}}' - ``` - - 其中xxx为创建的engine路径 - - 如果获取到的值不是“8af474944053df1f0a3be6e6165fa7cf”那么就需要检查xxx/src/third_party/dart/runtime/vm/dart.cc文件和xxx/src/third_party/dart/runtime/vm/image_snapshot.cc文件中全部行的结尾是不是以LF结尾的,windows可以使用notepad++查看,其它系统具体方法请自行查询 - - ## embedding层代码构建指导 -1. 编辑shell/platform/ohos/flutter_embedding/local.properties: +1. 编辑`shell/platform/ohos/flutter_embedding/local.properties`: ``` sdk.dir= @@ -107,7 +85,7 @@ Flutter Engine 1. debug/release,复制 `libflutter.so` 2. profile,复制 `libflutter.so` 和 `libvmservice_snapshot.so` -3. 在shell/platform/ohos/flutter_embedding目录下,执行 +3. 在`shell/platform/ohos/flutter_embedding`目录下,执行 ``` # buildMode可选值为: debug release profile @@ -120,4 +98,23 @@ Flutter Engine 6. 替换 `flutter_flutter/packages/flutter_tools/templates/app_shared/ohos.tmpl/har/har_product.tmpl/` 目录下对应文件,重新运行项目工程即可生效。 -ps:如果你使用的是DevEco Studio的Beta版本,编译工程时遇到“must have required property 'compatibleSdkVersion', location: build-profile.json5:17:11"错误,请参考《DevEco Studio环境配置指导.docx》中的‘6 创建工程和运行Hello World’【配置插件】章节修改 shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5文件。 +## FAQ +1. 运行项目工程报Member notfound:'isOhos'的错误:请确保`src/third_party/dart`目录下应用了所有的dart patch(补丁位于`src/flutter/attachment/repos`目录,可使用git apply应用patch),应用patch后重新编译engine + +2. 提示Permission denied: 执行chmod +x <脚本文件> 添加执行权限 + +3. 单独编译debug/release/profile模式的engine:`./ohos -t debug|release|profile` + +4. 查看帮助:`./ohos -h` + +5. 由于windows和Linux、Mac对换行符处理方式不同,在应用dart补丁时会造成dart vm snapshot hash结果不同,可通过以下方法获取当前snapshot hash值 + + ```shell + python xxx/src/third_party/dart/tools/make_version.py --format='{{SNAPSHOT_HASH}}' + ``` + + 其中xxx为创建的engine路径 + + 如果获取到的值不是“8af474944053df1f0a3be6e6165fa7cf”那么就需要检查`xxx/src/third_party/dart/runtime/vm/dart.cc`文件和`xxx/src/third_party/dart/runtime/vm/image_snapshot.cc`文件中全部行的结尾是不是以LF结尾的,windows可以使用notepad++查看,其它系统具体方法请自行查询 + +6. MediaQuery组件暂不支持gestureSettings.DeviceGesturesetting、displayFeatureType和displayFeatureState信息 diff --git a/attachment/repos/bootstrap/ohos b/attachment/repos/bootstrap/ohos index 99f75119643b6c9f0b965cccd7f0b02f5a1b79b9..b4597f5487d9d88e6804fda4b4b02261bbc75d37 100755 --- a/attachment/repos/bootstrap/ohos +++ b/attachment/repos/bootstrap/ohos @@ -1,16 +1,7 @@ #! /bin/bash -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. # #编译依赖 #sudo apt install g++-multilib git python3 curl diff --git a/attachment/repos/bootstrap/ohos.bat b/attachment/repos/bootstrap/ohos.bat index 289c3c0dab13217aaf53a5feeb1edc2377d5004c..4589330a76f22448ff653f8d811bfd7f15c89cd8 100644 --- a/attachment/repos/bootstrap/ohos.bat +++ b/attachment/repos/bootstrap/ohos.bat @@ -1,15 +1,6 @@ -@rem Copyright (c) 2021-2023 Huawei Device Co., Ltd. -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem http://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. +@rem Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. +@rem Use of this source code is governed by a BSD-style license tha +@rem found in the LICENSE_HW file. @echo off setlocal EnableDelayedExpansion diff --git a/attachment/repos/bootstrap/setup.sh b/attachment/repos/bootstrap/setup.sh index 285760b851a0d9b5cb243e9597f739d7e0c4ac0e..a47b72d18975e36f7874cf8177509df181130ed3 100755 --- a/attachment/repos/bootstrap/setup.sh +++ b/attachment/repos/bootstrap/setup.sh @@ -1,15 +1,6 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. #! /bin/sh chmod -R +w .vpython* diff --git a/attachment/repos/dart.patch0 b/attachment/repos/dart.patch0 index 8094cc2e317d80592662f557836994999c0b947c..6eb95a2a1a9638a11685a3b3ddf11824d166bc14 100644 --- a/attachment/repos/dart.patch0 +++ b/attachment/repos/dart.patch0 @@ -76,7 +76,7 @@ index 33be98fc0aa..eda146a0580 100644 String? _authCode; diff --git a/pkg/vm/lib/transformations/ffi/abi.dart b/pkg/vm/lib/transformations/ffi/abi.dart -index cc2d86bafd7..e703419eed7 100644 +index cc2d86bafd7..47368356a2e 100644 --- a/pkg/vm/lib/transformations/ffi/abi.dart +++ b/pkg/vm/lib/transformations/ffi/abi.dart @@ -40,6 +40,7 @@ enum _OS { @@ -87,48 +87,83 @@ index cc2d86bafd7..e703419eed7 100644 } /// An application binary interface (ABI). -@@ -71,6 +72,9 @@ class Abi { - /// The application binary interface for Fuchsia on the X64 architecture. - static const fuchsiaX64 = _fuchsiaX64; +@@ -65,6 +66,15 @@ class Abi { + /// The application binary interface for android on the X64 architecture. + static const androidX64 = _androidX64; ++ /// The application binary interface for Ohos on the X64 architecture. ++ static const ohosArm = _ohosArm; ++ ++ /// The application binary interface for Ohos on the X64 architecture. ++ static const ohosArm64 = _ohosArm64; ++ + /// The application binary interface for Ohos on the X64 architecture. + static const ohosX64 = _ohosX64; + - /// The application binary interface for iOS on the Arm architecture. - static const iosArm = _iosArm; + /// The application binary interface for Fuchsia on the Arm64 architecture. + static const fuchsiaArm64 = _fuchsiaArm64; -@@ -131,6 +135,7 @@ class Abi { +@@ -129,6 +139,9 @@ class Abi { + androidArm64, + androidIA32, androidX64, ++ ohosArm, ++ ohosArm64, ++ ohosX64, fuchsiaArm64, fuchsiaX64, -+ ohosX64, iosArm, - iosArm64, - iosX64, -@@ -176,6 +181,7 @@ class Abi { +@@ -174,6 +187,9 @@ class Abi { + static const _androidArm64 = Abi._(_Architecture.arm64, _OS.android); + static const _androidIA32 = Abi._(_Architecture.ia32, _OS.android); static const _androidX64 = Abi._(_Architecture.x64, _OS.android); ++ static const _ohosArm = Abi._(_Architecture.arm, _OS.ohos); ++ static const _ohosArm64 = Abi._(_Architecture.arm64, _OS.ohos); ++ static const _ohosX64 = Abi._(_Architecture.x64, _OS.ohos); static const _fuchsiaArm64 = Abi._(_Architecture.arm64, _OS.fuchsia); static const _fuchsiaX64 = Abi._(_Architecture.x64, _OS.fuchsia); -+ static const _ohosX64 = Abi._(_Architecture.x64, _OS.ohos); static const _iosArm = Abi._(_Architecture.arm, _OS.ios); - static const _iosArm64 = Abi._(_Architecture.arm64, _OS.ios); - static const _iosX64 = Abi._(_Architecture.x64, _OS.ios); -@@ -200,6 +206,7 @@ const Map abiNames = { +@@ -198,6 +214,9 @@ const Map abiNames = { + Abi.androidArm64: 'androidArm64', + Abi.androidIA32: 'androidIA32', Abi.androidX64: 'androidX64', ++ Abi.ohosArm: 'ohosArm', ++ Abi.ohosArm64: 'ohosArm64', ++ Abi.ohosX64: 'ohosX64', Abi.fuchsiaArm64: 'fuchsiaArm64', Abi.fuchsiaX64: 'fuchsiaX64', -+ Abi.ohosX64: 'ohosX64', Abi.iosArm: 'iosArm', - Abi.iosArm64: 'iosArm64', - Abi.iosX64: 'iosX64', -@@ -239,6 +246,7 @@ const Map> nonSizeAlignment = { +@@ -239,6 +258,8 @@ const Map> nonSizeAlignment = { // _wordSize64 Abi.androidArm64: _wordSize64, Abi.androidX64: _wordSize64, ++ Abi.ohosArm64: _wordSize64, + Abi.ohosX64: _wordSize64, Abi.fuchsiaArm64: _wordSize64, Abi.fuchsiaX64: _wordSize64, Abi.iosArm64: _wordSize64, +@@ -256,6 +277,7 @@ const Map> nonSizeAlignment = { + Abi.linuxIA32: _wordSize32Align32, + // _wordSize32Align64 + Abi.androidArm: _wordSize32Align64, ++ Abi.ohosArm: _wordSize32Align64, + Abi.linuxArm: _wordSize32Align64, + Abi.linuxRiscv32: _wordSize32Align64, + Abi.windowsIA32: _wordSize32Align64, +diff --git a/pkg/vm/testcases/transformations/ffi/abi_specific_int.dart b/pkg/vm/testcases/transformations/ffi/abi_specific_int.dart +index f926b9d46c1..a72516ac911 100644 +--- a/pkg/vm/testcases/transformations/ffi/abi_specific_int.dart ++++ b/pkg/vm/testcases/transformations/ffi/abi_specific_int.dart +@@ -9,6 +9,9 @@ import 'dart:ffi'; + Abi.androidArm64: Uint32(), + Abi.androidIA32: Uint32(), + Abi.androidX64: Uint32(), ++ Abi.ohosArm: Uint32(), ++ Abi.ohosArm64: Uint32(), ++ Abi.ohosX64: Uint32(), + Abi.fuchsiaArm64: Uint64(), + Abi.fuchsiaX64: Uint32(), + Abi.iosArm: Uint32(), diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index 13bfd0a724b..042b6a45f7e 100644 --- a/runtime/BUILD.gn @@ -7674,166 +7709,234 @@ index b7e5be3eab5..8a8f873f6c5 100644 bool _isAllowedOrigin(String origin) { Uri uri; +diff --git a/sdk/lib/_internal/vm/lib/ffi_patch.dart b/sdk/lib/_internal/vm/lib/ffi_patch.dart +index 4e719feb5d4..df1aecdb4f8 100644 +--- a/sdk/lib/_internal/vm/lib/ffi_patch.dart ++++ b/sdk/lib/_internal/vm/lib/ffi_patch.dart +@@ -27,6 +27,9 @@ int get _intPtrSize => (const [ + 8, // androidArm64, + 4, // androidIA32, + 8, // androidX64, ++ 4, // ohosArm, ++ 8, // ohosArm64, ++ 8, // ohosX64, + 8, // fuchsiaArm64, + 8, // fuchsiaX64, + 4, // iosArm, diff --git a/sdk/lib/ffi/abi.dart b/sdk/lib/ffi/abi.dart -index e6f08b37d25..5af605a8764 100644 +index e6f08b37d25..342c5c63c22 100644 --- a/sdk/lib/ffi/abi.dart +++ b/sdk/lib/ffi/abi.dart -@@ -34,6 +34,9 @@ class Abi { - /// The application binary interface for Fuchsia on the X64 architecture. - static const fuchsiaX64 = _fuchsiaX64; +@@ -28,6 +28,15 @@ class Abi { + /// The application binary interface for android on the X64 architecture. + static const androidX64 = _androidX64; -+ /// The application binary interface for Ohos on the X64 architecture. ++ /// The application binary interface for android on the X64 architecture. ++ static const ohosArm = _ohosArm; ++ ++ /// The application binary interface for android on the X64 architecture. ++ static const ohosArm64 = _ohosArm64; ++ ++ /// The application binary interface for android on the X64 architecture. + static const ohosX64 = _ohosX64; + - /// The application binary interface for iOS on the Arm architecture. - static const iosArm = _iosArm; + /// The application binary interface for Fuchsia on the Arm64 architecture. + static const fuchsiaArm64 = _fuchsiaArm64; -@@ -94,6 +97,7 @@ class Abi { +@@ -92,6 +101,9 @@ class Abi { + androidArm64, + androidIA32, androidX64, ++ ohosArm, ++ ohosArm64, ++ ohosX64, fuchsiaArm64, fuchsiaX64, -+ ohosX64, iosArm, - iosArm64, - iosX64, -@@ -136,6 +140,7 @@ class Abi { +@@ -134,6 +146,9 @@ class Abi { + static const _androidArm64 = Abi._(_Architecture.arm64, _OS.android); + static const _androidIA32 = Abi._(_Architecture.ia32, _OS.android); static const _androidX64 = Abi._(_Architecture.x64, _OS.android); ++ static const _ohosArm = Abi._(_Architecture.arm, _OS.ohos); ++ static const _ohosArm64 = Abi._(_Architecture.arm64, _OS.ohos); ++ static const _ohosX64 = Abi._(_Architecture.x64, _OS.ohos); static const _fuchsiaArm64 = Abi._(_Architecture.arm64, _OS.fuchsia); static const _fuchsiaX64 = Abi._(_Architecture.x64, _OS.fuchsia); -+ static const _ohosX64 = Abi._(_Architecture.x64, _OS.ohos); static const _iosArm = Abi._(_Architecture.arm, _OS.ios); - static const _iosArm64 = Abi._(_Architecture.arm64, _OS.ios); - static const _iosX64 = Abi._(_Architecture.x64, _OS.ios); -@@ -170,4 +175,5 @@ enum _OS { +@@ -170,4 +185,5 @@ enum _OS { linux, macos, windows, + ohos, } +diff --git a/sdk/lib/ffi/abi_specific.dart b/sdk/lib/ffi/abi_specific.dart +index 61eb867be17..8aff498845a 100644 +--- a/sdk/lib/ffi/abi_specific.dart ++++ b/sdk/lib/ffi/abi_specific.dart +@@ -24,6 +24,9 @@ part of dart.ffi; + /// Abi.androidArm64: Uint64(), + /// Abi.androidIA32: Uint32(), + /// Abi.androidX64: Uint64(), ++/// Abi.ohosArm: Uint32(), ++/// Abi.ohosArm64: Uint64(), ++/// Abi.ohosX64: Uint64(), + /// Abi.fuchsiaArm64: Uint64(), + /// Abi.fuchsiaX64: Uint64(), + /// Abi.iosArm: Uint32(), diff --git a/sdk/lib/ffi/c_type.dart b/sdk/lib/ffi/c_type.dart -index ee358c2f79d..1f9e629beb9 100644 +index ee358c2f79d..e87207e9e4b 100644 --- a/sdk/lib/ffi/c_type.dart +++ b/sdk/lib/ffi/c_type.dart -@@ -29,6 +29,7 @@ part of dart.ffi; +@@ -27,6 +27,9 @@ part of dart.ffi; + Abi.androidArm64: Uint8(), + Abi.androidIA32: Int8(), Abi.androidX64: Int8(), ++ Abi.ohosArm: Uint8(), ++ Abi.ohosArm64: Uint8(), ++ Abi.ohosX64: Int8(), Abi.fuchsiaArm64: Uint8(), Abi.fuchsiaX64: Int8(), -+ Abi.ohosX64: Int8(), Abi.iosArm: Int8(), - Abi.iosArm64: Int8(), - Abi.iosX64: Int8(), -@@ -66,6 +67,7 @@ class Char extends AbiSpecificInteger { +@@ -64,6 +67,9 @@ class Char extends AbiSpecificInteger { + Abi.androidArm64: Int8(), + Abi.androidIA32: Int8(), Abi.androidX64: Int8(), ++ Abi.ohosArm: Int8(), ++ Abi.ohosArm64: Int8(), ++ Abi.ohosX64: Int8(), Abi.fuchsiaArm64: Int8(), Abi.fuchsiaX64: Int8(), -+ Abi.ohosX64: Int8(), Abi.iosArm: Int8(), - Abi.iosArm64: Int8(), - Abi.iosX64: Int8(), -@@ -103,6 +105,7 @@ class SignedChar extends AbiSpecificInteger { +@@ -101,6 +107,9 @@ class SignedChar extends AbiSpecificInteger { + Abi.androidArm64: Uint8(), + Abi.androidIA32: Uint8(), Abi.androidX64: Uint8(), ++ Abi.ohosArm: Uint8(), ++ Abi.ohosArm64: Uint8(), ++ Abi.ohosX64: Uint8(), Abi.fuchsiaArm64: Uint8(), Abi.fuchsiaX64: Uint8(), -+ Abi.ohosX64: Uint8(), Abi.iosArm: Uint8(), - Abi.iosArm64: Uint8(), - Abi.iosX64: Uint8(), -@@ -140,6 +143,7 @@ class UnsignedChar extends AbiSpecificInteger { +@@ -138,6 +147,9 @@ class UnsignedChar extends AbiSpecificInteger { + Abi.androidArm64: Int16(), + Abi.androidIA32: Int16(), Abi.androidX64: Int16(), ++ Abi.ohosArm: Int16(), ++ Abi.ohosArm64: Int16(), ++ Abi.ohosX64: Int16(), Abi.fuchsiaArm64: Int16(), Abi.fuchsiaX64: Int16(), -+ Abi.ohosX64: Int16(), Abi.iosArm: Int16(), - Abi.iosArm64: Int16(), - Abi.iosX64: Int16(), -@@ -177,6 +181,7 @@ class Short extends AbiSpecificInteger { +@@ -175,6 +187,9 @@ class Short extends AbiSpecificInteger { + Abi.androidArm64: Uint16(), + Abi.androidIA32: Uint16(), Abi.androidX64: Uint16(), ++ Abi.ohosArm: Uint16(), ++ Abi.ohosArm64: Uint16(), ++ Abi.ohosX64: Uint16(), Abi.fuchsiaArm64: Uint16(), Abi.fuchsiaX64: Uint16(), -+ Abi.ohosX64: Uint16(), Abi.iosArm: Uint16(), - Abi.iosArm64: Uint16(), - Abi.iosX64: Uint16(), -@@ -214,6 +219,7 @@ class UnsignedShort extends AbiSpecificInteger { +@@ -212,6 +227,9 @@ class UnsignedShort extends AbiSpecificInteger { + Abi.androidArm64: Int32(), + Abi.androidIA32: Int32(), Abi.androidX64: Int32(), ++ Abi.ohosArm: Int32(), ++ Abi.ohosArm64: Int32(), ++ Abi.ohosX64: Int32(), Abi.fuchsiaArm64: Int32(), Abi.fuchsiaX64: Int32(), -+ Abi.ohosX64: Int32(), Abi.iosArm: Int32(), - Abi.iosArm64: Int32(), - Abi.iosX64: Int32(), -@@ -251,6 +257,7 @@ class Int extends AbiSpecificInteger { +@@ -249,6 +267,9 @@ class Int extends AbiSpecificInteger { + Abi.androidArm64: Uint32(), + Abi.androidIA32: Uint32(), Abi.androidX64: Uint32(), ++ Abi.ohosArm: Uint32(), ++ Abi.ohosArm64: Uint32(), ++ Abi.ohosX64: Uint32(), Abi.fuchsiaArm64: Uint32(), Abi.fuchsiaX64: Uint32(), -+ Abi.ohosX64: Uint32(), Abi.iosArm: Uint32(), - Abi.iosArm64: Uint32(), - Abi.iosX64: Uint32(), -@@ -289,6 +296,7 @@ class UnsignedInt extends AbiSpecificInteger { +@@ -287,6 +308,9 @@ class UnsignedInt extends AbiSpecificInteger { + Abi.androidArm64: Int64(), + Abi.androidIA32: Int32(), Abi.androidX64: Int64(), ++ Abi.ohosArm: Int32(), ++ Abi.ohosArm64: Int64(), ++ Abi.ohosX64: Int64(), Abi.fuchsiaArm64: Int64(), Abi.fuchsiaX64: Int64(), -+ Abi.ohosX64: Int64(), Abi.iosArm: Int32(), - Abi.iosArm64: Int64(), - Abi.iosX64: Int64(), -@@ -327,6 +335,7 @@ class Long extends AbiSpecificInteger { +@@ -325,6 +349,9 @@ class Long extends AbiSpecificInteger { + Abi.androidArm64: Uint64(), + Abi.androidIA32: Uint32(), Abi.androidX64: Uint64(), ++ Abi.ohosArm: Uint32(), ++ Abi.ohosArm64: Uint64(), ++ Abi.ohosX64: Uint64(), Abi.fuchsiaArm64: Uint64(), Abi.fuchsiaX64: Uint64(), -+ Abi.ohosX64: Uint64(), Abi.iosArm: Uint32(), - Abi.iosArm64: Uint64(), - Abi.iosX64: Uint64(), -@@ -364,6 +373,7 @@ class UnsignedLong extends AbiSpecificInteger { +@@ -362,6 +389,9 @@ class UnsignedLong extends AbiSpecificInteger { + Abi.androidArm64: Int64(), + Abi.androidIA32: Int64(), Abi.androidX64: Int64(), ++ Abi.ohosArm: Int64(), ++ Abi.ohosArm64: Int64(), ++ Abi.ohosX64: Int64(), Abi.fuchsiaArm64: Int64(), Abi.fuchsiaX64: Int64(), -+ Abi.ohosX64: Int64(), Abi.iosArm: Int64(), - Abi.iosArm64: Int64(), - Abi.iosX64: Int64(), -@@ -401,6 +411,7 @@ class LongLong extends AbiSpecificInteger { +@@ -399,6 +429,9 @@ class LongLong extends AbiSpecificInteger { + Abi.androidArm64: Uint64(), + Abi.androidIA32: Uint64(), Abi.androidX64: Uint64(), ++ Abi.ohosArm: Uint64(), ++ Abi.ohosArm64: Uint64(), ++ Abi.ohosX64: Uint64(), Abi.fuchsiaArm64: Uint64(), Abi.fuchsiaX64: Uint64(), -+ Abi.ohosX64: Uint64(), Abi.iosArm: Uint64(), - Abi.iosArm64: Uint64(), - Abi.iosX64: Uint64(), -@@ -433,6 +444,7 @@ class UnsignedLongLong extends AbiSpecificInteger { +@@ -431,6 +464,9 @@ class UnsignedLongLong extends AbiSpecificInteger { + Abi.androidArm64: Int64(), + Abi.androidIA32: Int32(), Abi.androidX64: Int64(), ++ Abi.ohosArm: Int32(), ++ Abi.ohosArm64: Int64(), ++ Abi.ohosX64: Int64(), Abi.fuchsiaArm64: Int64(), Abi.fuchsiaX64: Int64(), -+ Abi.ohosX64: Int64(), Abi.iosArm: Int32(), - Abi.iosArm64: Int64(), - Abi.iosX64: Int64(), -@@ -466,6 +478,7 @@ class IntPtr extends AbiSpecificInteger { +@@ -464,6 +500,9 @@ class IntPtr extends AbiSpecificInteger { + Abi.androidArm64: Uint64(), + Abi.androidIA32: Uint32(), Abi.androidX64: Uint64(), ++ Abi.ohosArm: Uint32(), ++ Abi.ohosArm64: Uint64(), ++ Abi.ohosX64: Uint64(), Abi.fuchsiaArm64: Uint64(), Abi.fuchsiaX64: Uint64(), -+ Abi.ohosX64: Uint64(), Abi.iosArm: Uint32(), - Abi.iosArm64: Uint64(), - Abi.iosX64: Uint64(), -@@ -499,6 +512,7 @@ class UintPtr extends AbiSpecificInteger { +@@ -497,6 +536,9 @@ class UintPtr extends AbiSpecificInteger { + Abi.androidArm64: Uint64(), + Abi.androidIA32: Uint32(), Abi.androidX64: Uint64(), ++ Abi.ohosArm: Uint32(), ++ Abi.ohosArm64: Uint64(), ++ Abi.ohosX64: Uint64(), Abi.fuchsiaArm64: Uint64(), Abi.fuchsiaX64: Uint64(), -+ Abi.ohosX64: Uint64(), Abi.iosArm: Uint32(), - Abi.iosArm64: Uint64(), - Abi.iosX64: Uint64(), -@@ -535,6 +549,7 @@ class Size extends AbiSpecificInteger { +@@ -533,6 +575,9 @@ class Size extends AbiSpecificInteger { + Abi.androidArm64: Uint32(), + Abi.androidIA32: Uint32(), Abi.androidX64: Uint32(), ++ Abi.ohosArm: Uint32(), ++ Abi.ohosArm64: Uint32(), ++ Abi.ohosX64: Uint32(), Abi.fuchsiaArm64: Uint32(), Abi.fuchsiaX64: Int32(), -+ Abi.ohosX64: Int32(), Abi.iosArm: Int32(), - Abi.iosArm64: Int32(), - Abi.iosX64: Int32(), diff --git a/sdk_args.gni b/sdk_args.gni index 4b2a1e4ea63..a864344ee8d 100644 --- a/sdk_args.gni diff --git a/attachment/repos/skia.patch b/attachment/repos/skia.patch index adad9f220a0bb691d29b861f077f901cf4df36aa..d4edec37a968bc6a36153cc1ed14c9229629bd8b 100644 --- a/attachment/repos/skia.patch +++ b/attachment/repos/skia.patch @@ -7,7 +7,7 @@ index ebbd898ec9..015bb75414 100644 # Skia public API, generally provided by :skia. config("skia_public") { - include_dirs = [ "." ] -+ include_dirs = [ ".", ++ include_dirs = [ ".", + "//third_part/khronos/", ] defines = [] @@ -1131,7 +1131,7 @@ index 0000000000..0e5e0829b6 +} diff --git a/src/ports/skia_ohos/FontConfig_ohos.cpp b/src/ports/skia_ohos/FontConfig_ohos.cpp new file mode 100644 -index 0000000000..2dfc1348c1 +index 0000000000..ea5c8ecf84 --- /dev/null +++ b/src/ports/skia_ohos/FontConfig_ohos.cpp @@ -0,0 +1,1312 @@ @@ -1141,7 +1141,7 @@ index 0000000000..2dfc1348c1 + +#include "FontConfig_ohos.h" + -+#include ++#include +#include +#include +#include @@ -1659,7 +1659,7 @@ index 0000000000..2dfc1348c1 + return logErrInfo(ERROR_CONFIG_MISSING_TAG, "alias"); + } + // "adjust", "variation" - optional -+ const char* tags[] = {"alias", "adjust", "variations", "index"}; ++ const char* tags[] = {"alias", "adjust", "font-variations", "index"}; + std::vector aliasSet; + std::vector adjustSet; + std::vector variationSet; @@ -1824,7 +1824,7 @@ index 0000000000..2dfc1348c1 + bool hasIndex = false; + bool hasVariations = false; + for (unsigned int i = 0; i < members.size(); i++) { -+ if (members[i] == "variations") { ++ if (members[i] == "font-variations") { + hasVariations = true; + } else if (members[i] == "index") { + hasIndex = true; @@ -1842,7 +1842,7 @@ index 0000000000..2dfc1348c1 + SkString lang = SkString(key); + SkString familyName = SkString(root[key].asCString()); + if (hasVariations) { -+ key = "variations"; ++ key = "font-variations"; + if (root[key].isArray()) { + const Json::Value& varArr = root[key]; + std::vector variationSet; @@ -1850,7 +1850,7 @@ index 0000000000..2dfc1348c1 + if (varArr[i].isObject()) { + parseVariation(varArr[i], variationSet); + } else { -+ SkString text = SkString("variations#"); ++ SkString text = SkString("font-variations#"); + text.appendU32(i + 1); + (void) logErrInfo(ERROR_CONFIG_INVALID_VALUE_TYPE, text.c_str(), + Json::objectValue, varArr[i].type()); @@ -1881,7 +1881,7 @@ index 0000000000..2dfc1348c1 + return NO_ERROR; +} + -+/*! To parse an item of 'variations' attribute ++/*! To parse an item of 'font-variations' attribute + * \param root the root node of an item in 'variations' list + * \param[out] variationSet the value of VariationInfo is written to and returned to the caller + * \return NO_ERROR successful @@ -3718,10 +3718,10 @@ index 0000000000..f80e920de0 +#endif /* SKTYPEFACE_OHOS_H */ diff --git a/src/ports/skia_ohos/config/fontconfig.json b/src/ports/skia_ohos/config/fontconfig.json new file mode 100644 -index 0000000000..ec225a188e +index 0000000000..2c5458bc6b --- /dev/null +++ b/src/ports/skia_ohos/config/fontconfig.json -@@ -0,0 +1,76 @@ +@@ -0,0 +1,1373 @@ +{ + "fontdir": ["/system/fonts/"], + "generic": [ @@ -3757,6 +3757,26 @@ index 0000000000..ec225a188e + { + "weight": 200, "to": 900 + } ++ ], ++ "font-variations": [ ++ { ++ "weight": 100, "wght": 100 ++ }, ++ { ++ "weight": 300, "wght": 247 ++ }, ++ { ++ "weight": 400, "wght": 400 ++ }, ++ { ++ "weight": 500, "wght": 500 ++ }, ++ { ++ "weight": 700, "wght": 706 ++ }, ++ { ++ "weight": 900, "wght": 844 ++ } + ] + }, + { @@ -3765,6 +3785,26 @@ index 0000000000..ec225a188e + { + "HarmonyOS-Sans-Condensed": 0 + } ++ ], ++ "font-variations": [ ++ { ++ "weight": 100, "wght": 100 ++ }, ++ { ++ "weight": 300, "wght": 247 ++ }, ++ { ++ "weight": 400, "wght": 400 ++ }, ++ { ++ "weight": 500, "wght": 500 ++ }, ++ { ++ "weight": 700, "wght": 706 ++ }, ++ { ++ "weight": 900, "wght": 844 ++ } + ] + }, + { @@ -3774,27 +3814,1284 @@ index 0000000000..ec225a188e + "HarmonyOS-Sans-Digit": 0 + } + ] ++ }, ++ { ++ "family": "Noto Serif", ++ "alias": [ ++ { ++ "serif": 0 ++ } ++ ] ++ }, ++ { ++ "family": "Noto Sans Mono", ++ "alias": [ ++ { ++ "monospace": 400 ++ } ++ ] + } + ], + "fallback": [ + { + "": [ + { ++ "und-Zsye": "HMOS Color Emoji" ++ }, ++ { ++ "": "Noto Sans" ++ }, ++ { ++ "font-variations": [ ++ { ++ "weight": 100, "wght": 100 ++ }, ++ { ++ "weight": 300, "wght": 247 ++ }, ++ { ++ "weight": 400, "wght": 400 ++ }, ++ { ++ "weight": 500, "wght": 500 ++ }, ++ { ++ "weight": 700, "wght": 706 ++ }, ++ { ++ "weight": 900, "wght": 844 ++ } ++ ], ++ "und-Arab": "HarmonyOS Sans Naskh Arabic UI" ++ }, ++ { ++ "und-Ethi": "Noto Sans Ethiopic" ++ }, ++ { ++ "und-Hebr": "Noto Sans Hebrew" ++ }, ++ { ++ "und-Thai": "Noto Sans Thai" ++ }, ++ { ++ "und-Armn": "Noto Sans Armenian" ++ }, ++ { ++ "und-Geor,und-Geok": "Noto Sans Georgian" ++ }, ++ { ++ "und-Deva": "Noto Sans Devanagari" ++ }, ++ { ++ "und-Gujr": "Noto Sans Gujarati" ++ }, ++ { ++ "und-Guru": "Noto Sans Gurmukhi" ++ }, ++ { ++ "und-Taml": "Noto Sans Tamil" ++ }, ++ { ++ "und-Mlym": "Noto Sans Malayalam" ++ }, ++ { ++ "und-Beng": "Noto Sans Bengali" ++ }, ++ { ++ "und-Telu": "Noto Sans Telugu" ++ }, ++ { ++ "und-Knda": "Noto Sans Kannada" ++ }, ++ { ++ "und-Orya": "Noto Sans Oriya" ++ }, ++ { ++ "und-Sinh": "Noto Sans Sinhala" ++ }, ++ { ++ "und-Khmr": "Noto Sans Khmer" ++ }, ++ { ++ "und-Laoo": "Noto Sans Lao" ++ }, ++ { ++ "und-Mymr": "Noto Sans Myanmar" ++ }, ++ { ++ "und-Thaa": "Noto Sans Thaana" ++ }, ++ { ++ "und-Cham": "Noto Sans Cham" ++ }, ++ { ++ "und-Ahom": "Noto Serif Ahom" ++ }, ++ { ++ "und-Adlm": "Noto Sans Adlam" ++ }, ++ { ++ "und-Avst": "Noto Sans Avestan" ++ }, ++ { ++ "und-Bali": "Noto Sans Balinese" ++ }, ++ { ++ "und-Bamu": "Noto Sans Bamum" ++ }, ++ { ++ "und-Batk": "Noto Sans Batak" ++ }, ++ { ++ "und-Brah": "Noto Sans Brahmi" ++ }, ++ { ++ "und-Bugi": "Noto Sans Buginese" ++ }, ++ { ++ "und-Buhd": "Noto Sans Buhid" ++ }, ++ { ++ "und-Cans": "Noto Sans Canadian Aboriginal" ++ }, ++ { ++ "und-Cari": "Noto Sans Carian" ++ }, ++ { ++ "und-Cakm": "Noto Sans Chakma" ++ }, ++ { ++ "und-Cher": "Noto Sans Cherokee" ++ }, ++ { ++ "und-Copt": "Noto Sans Coptic" ++ }, ++ { ++ "und-Xsux": "Noto Sans Cuneiform" ++ }, ++ { ++ "und-Cprt": "Noto Sans Cypriot" ++ }, ++ { ++ "und-Dsrt": "Noto Sans Deseret" ++ }, ++ { ++ "und-Egyp": "Noto Sans Egyptian Hieroglyphs" ++ }, ++ { ++ "und-Elba": "Noto Sans Elbasan" ++ }, ++ { ++ "und-Glag": "Noto Sans Glagolitic" ++ }, ++ { ++ "und-Goth": "Noto Sans Gothic" ++ }, ++ { ++ "und-Hano": "Noto Sans Hanunoo" ++ }, ++ { ++ "und-Armi": "Noto Sans Imperial Aramaic" ++ }, ++ { ++ "und-Phli": "Noto Sans Inscriptional Pahlavi" ++ }, ++ { ++ "und-Prti": "Noto Sans Inscriptional Parthian" ++ }, ++ { ++ "und-Java": "Noto Sans Javanese" ++ }, ++ { ++ "und-Kthi": "Noto Sans Kaithi" ++ }, ++ { ++ "und-Kali": "Noto Sans Kayah Li" ++ }, ++ { ++ "und-Khar": "Noto Sans Kharoshthi" ++ }, ++ { ++ "und-Lepc": "Noto Sans Lepcha" ++ }, ++ { ++ "und-Limb": "Noto Sans Limbu" ++ }, ++ { ++ "und-Linb": "Noto Sans Linear B" ++ }, ++ { ++ "und-Lisu": "Noto Sans Lisu" ++ }, ++ { ++ "und-Lyci": "Noto Sans Lycian" ++ }, ++ { ++ "und-Lydi": "Noto Sans Lydian" ++ }, ++ { ++ "und-Mand": "Noto Sans Mandaic" ++ }, ++ { ++ "und-Mtei": "Noto Sans Meetei Mayek" ++ }, ++ { ++ "und-Talu": "Noto Sans New Tai Lue" ++ }, ++ { ++ "und-Nkoo": "Noto Sans NKo" ++ }, ++ { ++ "und-Ogam": "Noto Sans Ogham" ++ }, ++ { ++ "und-Olck": "Noto Sans Ol Chiki" ++ }, ++ { ++ "und-Ital": "Noto Sans Old Italic" ++ }, ++ { ++ "und-Xpeo": "Noto Sans Old Persian" ++ }, ++ { ++ "und-Sarb": "Noto Sans Old South Arabian" ++ }, ++ { ++ "und-Orkh": "Noto Sans Old Turkic" ++ }, ++ { ++ "und-Osge": "Noto Sans Osage" ++ }, ++ { ++ "und-Osma": "Noto Sans Osmanya" ++ }, ++ { ++ "und-Phnx": "Noto Sans Phoenician" ++ }, ++ { ++ "und-Rjng": "Noto Sans Rejang" ++ }, ++ { ++ "und-Runr": "Noto Sans Runic" ++ }, ++ { ++ "und-Samr": "Noto Sans Samaritan" ++ }, ++ { ++ "und-Saur": "Noto Sans Saurashtra" ++ }, ++ { ++ "und-Shaw": "Noto Sans Shavian" ++ }, ++ { ++ "und-Sund": "Noto Sans Sundanese" ++ }, ++ { ++ "und-Sylo": "Noto Sans Syloti Nagri" ++ }, ++ { ++ "und-Syrn": "Noto Sans Syriac Eastern" ++ }, ++ { ++ "und-Syrj": "Noto Sans Syriac Western" ++ }, ++ { ++ "und-Tglg": "Noto Sans Tagalog" ++ }, ++ { ++ "und-Tagb": "Noto Sans Tagbanwa" ++ }, ++ { ++ "und-Lana": "Noto Sans Tai Tham" ++ }, ++ { ++ "und-Tavt": "Noto Sans Tai Viet" ++ }, ++ { ++ "und-Tibt": "Noto Serif Tibetan" ++ }, ++ { ++ "und-Tfng": "Noto Sans Tifinagh" ++ }, ++ { ++ "und-Ugar": "Noto Sans Ugaritic" ++ }, ++ { ++ "und-Vaii": "Noto Sans Vai" ++ }, ++ { ++ "font-variations": [ ++ { ++ "weight": 100, "wght": 100 ++ }, ++ { ++ "weight": 300, "wght": 247 ++ }, ++ { ++ "weight": 400, "wght": 400 ++ }, ++ { ++ "weight": 500, "wght": 500 ++ }, ++ { ++ "weight": 600, "wght": 603 ++ }, ++ { ++ "weight": 700, "wght": 706 ++ }, ++ { ++ "weight": 900, "wght": 844 ++ } ++ ], + "zh-Hans": "HarmonyOS Sans SC" + }, + { ++ "font-variations": [ ++ { ++ "weight": 100, "wght": 100 ++ }, ++ { ++ "weight": 300, "wght": 247 ++ }, ++ { ++ "weight": 400, "wght": 400 ++ }, ++ { ++ "weight": 500, "wght": 500 ++ }, ++ { ++ "weight": 700, "wght": 706 ++ }, ++ { ++ "weight": 900, "wght": 844 ++ } ++ ], + "zh-Hant": "HarmonyOS Sans TC" + }, + { -+ "und-Arab": "HarmonyOS Sans Naskh Arabic UI" ++ "ja": "Noto Sans CJK JP" + }, + { -+ "ja": "Noto Sans JP" ++ "ko": "Noto Sans CJK JP" + }, + { -+ "ko": "Noto Sans KR" -+ } -+ ] ++ "und-Zsye": "HMOS Color Emoji Flags" ++ }, ++ { ++ "und-Zsym": "Noto Sans Symbols" ++ }, ++ { ++ "und-Zsym": "Noto Sans Symbols 2" ++ }, ++ { ++ "und-Tale": "Noto Sans Tai Le" ++ }, ++ { ++ "und-Yiii": "Noto Sans Yi" ++ }, ++ { ++ "und-Mong": "Noto Sans Mongolian" ++ }, ++ { ++ "und-Phag": "Noto Sans Phags-Pa" ++ }, ++ { ++ "und-Hluw": "Noto Sans Anatolian Hieroglyphs" ++ }, ++ { ++ "und-Bass": "Noto Sans Bassa Vah" ++ }, ++ { ++ "und-Bhks": "Noto Sans Bhaiksuki" ++ }, ++ { ++ "und-Hatr": "Noto Sans Hatran" ++ }, ++ { ++ "und-Lina": "Noto Sans Linear A" ++ }, ++ { ++ "und-Mani": "Noto Sans Manichaean" ++ }, ++ { ++ "und-Marc": "Noto Sans Marchen" ++ }, ++ { ++ "und-Merc": "Noto Sans Meroitic" ++ }, ++ { ++ "und-Plrd": "Noto Sans Miao" ++ }, ++ { ++ "und-Mroo": "Noto Sans Mro" ++ }, ++ { ++ "und-Mult": "Noto Sans Multani" ++ }, ++ { ++ "und-Nbat": "Noto Sans Nabataean" ++ }, ++ { ++ "und-Newa": "Noto Sans Newa" ++ }, ++ { ++ "und-Narb": "Noto Sans Old North Arabian" ++ }, ++ { ++ "und-Perm": "Noto Sans Old Permic" ++ }, ++ { ++ "und-Hmng": "Noto Sans Pahawh Hmong" ++ }, ++ { ++ "und-Palm": "Noto Sans Palmyrene" ++ }, ++ { ++ "und-Pauc": "Noto Sans Pau Cin Hau" ++ }, ++ { ++ "und-Shrd": "Noto Sans Sharada" ++ }, ++ { ++ "und-Sora": "Noto Sans Sora Sompeng" ++ }, ++ { ++ "und-Gong": "Noto Sans Gunjala Gondi" ++ }, ++ { ++ "und-Rohg": "Noto Sans Hanifi Rohingya" ++ }, ++ { ++ "und-Khoj": "Noto Sans Khojki" ++ }, ++ { ++ "und-Gonm": "Noto Sans Masaram Gondi" ++ }, ++ { ++ "und-Wcho": "Noto Sans Wancho" ++ }, ++ { ++ "und-Wara": "Noto Sans Warang Citi" ++ }, ++ { ++ "und-Gran": "Noto Sans Grantha" ++ }, ++ { ++ "und-Modi": "Noto Sans Modi" ++ }, ++ { ++ "und-Dogr": "Noto Serif Dogra" ++ }, ++ { ++ "und-Medf": "Noto Sans Medefaidrin" ++ }, ++ { ++ "und-Soyo": "Noto Sans Soyombo" ++ }, ++ { ++ "und-Takr": "Noto Sans Takri" ++ }, ++ { ++ "und-Yezi": "Noto Serif Yezidi" ++ }, ++ { ++ "und-Zsym": "HM Symbol" ++ }, ++ { ++ "und-Math": "Noto Sans Math" ++ } ++ ] ++ } ++ ], ++ "font_file_map" : [ ++ { ++ "DejaVuMathTeXGyre-Regular": "DejaVuMathTeXGyre.ttf" ++ }, ++ { ++ "FTSymbol": "FTSymbol.ttf" ++ }, ++ { ++ "FTToken": "FTToken.ttf" ++ }, ++ { ++ "FTToken2": "FTToken2.ttf" ++ }, ++ { ++ "FTToken3": "FTToken3.ttf" ++ }, ++ { ++ "FTTokens": "FTTokens.ttf" ++ }, ++ { ++ "方正仿宋-简": "FZFangS-SC.ttf" ++ }, ++ { ++ "FZFangS-SC": "FZFangS-SC.ttf" ++ }, ++ { ++ "方正仿宋-繁": "FZFangS-TC.ttf" ++ }, ++ { ++ "FZFangS-TC": "FZFangS-TC.ttf" ++ }, ++ { ++ "FZHeiT-SC Bold": "FZHeiT-SC-Bold.ttf" ++ }, ++ { ++ "FZHeiT-SC Light": "FZHeiT-SC-Light.ttf" ++ }, ++ { ++ "FZHeiT-SC": "FZHeiT-SC-Regular.ttf" ++ }, ++ { ++ "FZHeiT-TC Bold": "FZHeiT-TC-Bold.ttf" ++ }, ++ { ++ "方正黑體-繁 Bold": "FZHeiT-TC-Bold.ttf" ++ }, ++ { ++ "FZHeiT-TC Light": "FZHeiT-TC-Light.ttf" ++ }, ++ { ++ "方正黑體-繁 Light": "FZHeiT-TC-Light.ttf" ++ }, ++ { ++ "FZHeiT-TC": "FZHeiT-TC-Regular.ttf" ++ }, ++ { ++ "方正黑體-繁": "FZHeiT-TC-Regular.ttf" ++ }, ++ { ++ "方正楷体-简": "FZKaiT-SC.ttf" ++ }, ++ { ++ "FZKaiT-SC": "FZKaiT-SC.ttf" ++ }, ++ { ++ "方正楷體-繁": "FZKaiT-TC.ttf" ++ }, ++ { ++ "FZKaiT-TC": "FZKaiT-TC.ttf" ++ }, ++ { ++ "方正隶体-简": "FZLiT-SC.ttf" ++ }, ++ { ++ "FZLiT-SC": "FZLiT-SC.ttf" ++ }, ++ { ++ "方正隸變-繁": "FZLiB-TC.ttf" ++ }, ++ { ++ "FZLiB-TC": "FZLiB-TC.ttf" ++ }, ++ { ++ "方正隶书-简": "FZLiS-SC.ttf" ++ }, ++ { ++ "FZLiS-SC": "FZLiS-SC.ttf" ++ }, ++ { ++ "方正隸書-繁": "FZLiS-TC.ttf" ++ }, ++ { ++ "FZLiS-TC": "FZLiS-TC.ttf" ++ }, ++ { ++ "方正喵呜-简": "FZMiaoW-SC.ttf" ++ }, ++ { ++ "FZMiaoW-SC": "FZMiaoW-SC.ttf" ++ }, ++ { ++ "方正喵體-繁": "FZMiaoT-TC.ttf" ++ }, ++ { ++ "FZMiaoT-TC": "FZMiaoT-TC.ttf" ++ }, ++ { ++ "方正手书-简": "FZShouS-SC.ttf" ++ }, ++ { ++ "FZShouS-SC": "FZShouS-SC.ttf" ++ }, ++ { ++ "方正手書-繁": "FZShouS-TC.ttf" ++ }, ++ { ++ "FZShouS-TC": "FZShouS-TC.ttf" ++ }, ++ { ++ "方正书宋-简": "FZShuS-SC.ttf" ++ }, ++ { ++ "FZShuS-SC": "FZShuS-SC.ttf" ++ }, ++ { ++ "方正書宋-繁": "FZShuS-TC.ttf" ++ }, ++ { ++ "FZShuS-TC": "FZShuS-TC.ttf" ++ }, ++ { ++ "方正小标宋-简": "FZXiaoBS-SC.ttf" ++ }, ++ { ++ "FZXiaoBS-SC": "FZXiaoBS-SC.ttf" ++ }, ++ { ++ "方正小標宋-繁": "FZXiaoBS-TC.ttf" ++ }, ++ { ++ "FZXiaoBS-TC": "FZXiaoBS-TC.ttf" ++ }, ++ { ++ "方正行楷-简": "FZXingK-SC.ttf" ++ }, ++ { ++ "FZXingK-SC": "FZXingK-SC.ttf" ++ }, ++ { ++ "方正行楷-繁": "FZXingK-TC.ttf" ++ }, ++ { ++ "FZXingK-TC": "FZXingK-TC.ttf" ++ }, ++ { ++ "FZYuanT-SC Bold": "FZYuanT-SC-Bold.ttf" ++ }, ++ { ++ "FZYuanT-SC Light": "FZYuanT-SC-Light.ttf" ++ }, ++ { ++ "FZYuanT-SC": "FZYuanT-SC-Regular.ttf" ++ }, ++ { ++ "FZYuanT-TC Bold": "FZYuanT-TC-Bold.ttf" ++ }, ++ { ++ "方正圓體-繁 Bold": "FZYuanT-TC-Bold.ttf" ++ }, ++ { ++ "FZYuanT-TC Light": "FZYuanT-TC-Light.ttf" ++ }, ++ { ++ "方正圓體-繁 Light": "FZYuanT-TC-Light.ttf" ++ }, ++ { ++ "FZYuanT-TC": "FZYuanT-TC-Regular.ttf" ++ }, ++ { ++ "方正圓體-繁": "FZYuanT-TC-Regular.ttf" ++ }, ++ { ++ "HMOS Color Emoji": "HMOSColorEmojiCompat.ttf" ++ }, ++ { ++ "HMOS Color Emoji Flags": "HMOSColorEmojiFlags.ttf" ++ }, ++ { ++ "HM Symbol Regular": "HMSymbolVF.ttf" ++ }, ++ { ++ "HarmonyOS Sans": "HarmonyOS_Sans.ttf" ++ }, ++ { ++ "HarmonyOS Sans Condensed": "HarmonyOS_Sans_Condensed.ttf" ++ }, ++ { ++ "HarmonyOS Sans Condensed Italic": "HarmonyOS_Sans_Condensed_Italic.ttf" ++ }, ++ { ++ "HarmonyOS Sans Digit": "HarmonyOS_Sans_Digit.ttf" ++ }, ++ { ++ "HarmonyOS Sans Digit": "HarmonyOS_Sans_Digit_Medium.ttf" ++ }, ++ { ++ "HarmonyOS Sans Italic": "HarmonyOS_Sans_Italic.ttf" ++ }, ++ { ++ "HarmonyOS Sans Naskh Arabic": "HarmonyOS_Sans_Naskh_Arabic.ttf" ++ }, ++ { ++ "HarmonyOS Sans Naskh Arabic UI": "HarmonyOS_Sans_Naskh_Arabic_UI.ttf" ++ }, ++ { ++ "HarmonyOS Sans SC": "HarmonyOS_Sans_SC.ttf" ++ }, ++ { ++ "HarmonyOS Sans TC": "HarmonyOS_Sans_TC.ttf" ++ }, ++ { ++ "Noto Sans Adlam Regular": "NotoSansAdlam[wght].ttf" ++ }, ++ { ++ "Noto Sans Anatolian Hieroglyphs Regular": "NotoSansAnatolianHieroglyphs-Regular.ttf" ++ }, ++ { ++ "Noto Sans Armenian Regular": "NotoSansArmenian[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Avestan Regular": "NotoSansAvestan-Regular.ttf" ++ }, ++ { ++ "Noto Sans Balinese Regular": "NotoSansBalinese[wght].ttf" ++ }, ++ { ++ "Noto Sans Bamum Regular": "NotoSansBamum[wght].ttf" ++ }, ++ { ++ "Noto Sans Bassa Vah Regular": "NotoSansBassaVah[wght].ttf" ++ }, ++ { ++ "Noto Sans Batak Regular": "NotoSansBatak-Regular.ttf" ++ }, ++ { ++ "Noto Sans Bengali UI Bold": "NotoSansBengaliUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Bengali UI Medium": "NotoSansBengaliUI-Medium.ttf" ++ }, ++ { ++ "Noto Sans Bengali UI Regular": "NotoSansBengaliUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Bengali UI SemiBold": "NotoSansBengaliUI-SemiBold.ttf" ++ }, ++ { ++ "Noto Sans Bengali Regular": "NotoSansBengali[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Bhaiksuki Regular": "NotoSansBhaiksuki-Regular.ttf" ++ }, ++ { ++ "Noto Sans Brahmi Regular": "NotoSansBrahmi-Regular.ttf" ++ }, ++ { ++ "Noto Sans Buginese Regular": "NotoSansBuginese-Regular.ttf" ++ }, ++ { ++ "Noto Sans Buhid Regular": "NotoSansBuhid-Regular.ttf" ++ }, ++ { ++ "Noto Sans CJK JP": "NotoSansCJK-Regular.ttc" ++ }, ++ { ++ "Noto Sans Canadian Aboriginal Regular": "NotoSansCanadianAboriginal[wght].ttf" ++ }, ++ { ++ "Noto Sans Carian Regular": "NotoSansCarian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Chakma Regular": "NotoSansChakma-Regular.ttf" ++ }, ++ { ++ "Noto Sans Cham Regular": "NotoSansCham[wght].ttf" ++ }, ++ { ++ "Noto Sans Cherokee Regular": "NotoSansCherokee[wght].ttf" ++ }, ++ { ++ "Noto Sans Coptic Regular": "NotoSansCoptic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Cuneiform Regular": "NotoSansCuneiform-Regular.ttf" ++ }, ++ { ++ "Noto Sans Cypriot Regular": "NotoSansCypriot-Regular.ttf" ++ }, ++ { ++ "Noto Sans Deseret Regular": "NotoSansDeseret-Regular.ttf" ++ }, ++ { ++ "Noto Sans Devanagari UI Bold": "NotoSansDevanagariUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Devanagari UI Medium": "NotoSansDevanagariUI-Medium.ttf" ++ }, ++ { ++ "Noto Sans Devanagari UI Regular": "NotoSansDevanagariUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Devanagari UI SemiBold": "NotoSansDevanagariUI-SemiBold.ttf" ++ }, ++ { ++ "Noto Sans Devanagari Regular": "NotoSansDevanagari[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Egyptian Hieroglyphs Regular": "NotoSansEgyptianHieroglyphs-Regular.ttf" ++ }, ++ { ++ "Noto Sans Elbasan Regular": "NotoSansElbasan-Regular.ttf" ++ }, ++ { ++ "Noto Sans Ethiopic Regular": "NotoSansEthiopic[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Georgian Regular": "NotoSansGeorgian[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Glagolitic Regular": "NotoSansGlagolitic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Gothic Regular": "NotoSansGothic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Grantha Regular": "NotoSansGrantha-Regular.ttf" ++ }, ++ { ++ "Noto Sans Gujarati UI Bold": "NotoSansGujaratiUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Gujarati UI Regular": "NotoSansGujaratiUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Gujarati Regular": "NotoSansGujarati[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Gunjala Gondi Regular": "NotoSansGunjalaGondi[wght].ttf" ++ }, ++ { ++ "Noto Sans Gurmukhi UI Bold": "NotoSansGurmukhiUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Gurmukhi UI Medium": "NotoSansGurmukhiUI-Medium.ttf" ++ }, ++ { ++ "Noto Sans Gurmukhi UI Regular": "NotoSansGurmukhiUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Gurmukhi UI SemiBold": "NotoSansGurmukhiUI-SemiBold.ttf" ++ }, ++ { ++ "Noto Sans Gurmukhi Regular": "NotoSansGurmukhi[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Hanifi Rohingya Regular": "NotoSansHanifiRohingya[wght].ttf" ++ }, ++ { ++ "Noto Sans Hanunoo Regular": "NotoSansHanunoo-Regular.ttf" ++ }, ++ { ++ "Noto Sans Hatran Regular": "NotoSansHatran-Regular.ttf" ++ }, ++ { ++ "Noto Sans Hebrew Regular": "NotoSansHebrew[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Imperial Aramaic Regular": "NotoSansImperialAramaic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Inscriptional Pahlavi Regular": "NotoSansInscriptionalPahlavi-Regular.ttf" ++ }, ++ { ++ "Noto Sans Inscriptional Parthian Regular": "NotoSansInscriptionalParthian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Javanese Regular": "NotoSansJavanese[wght].ttf" ++ }, ++ { ++ "Noto Sans Kaithi Regular": "NotoSansKaithi-Regular.ttf" ++ }, ++ { ++ "Noto Sans Kannada UI Bold": "NotoSansKannadaUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Kannada UI Medium": "NotoSansKannadaUI-Medium.ttf" ++ }, ++ { ++ "Noto Sans Kannada UI Regular": "NotoSansKannadaUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Kannada UI SemiBold": "NotoSansKannadaUI-SemiBold.ttf" ++ }, ++ { ++ "Noto Sans Kannada Regular": "NotoSansKannada[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Kayah Li Regular": "NotoSansKayahLi[wght].ttf" ++ }, ++ { ++ "Noto Sans Kharoshthi Regular": "NotoSansKharoshthi-Regular.ttf" ++ }, ++ { ++ "Noto Sans Khmer Regular": "NotoSansKhmer[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Khojki Regular": "NotoSansKhojki-Regular.ttf" ++ }, ++ { ++ "Noto Sans Lao Regular": "NotoSansLao[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Lepcha Regular": "NotoSansLepcha-Regular.ttf" ++ }, ++ { ++ "Noto Sans Limbu Regular": "NotoSansLimbu-Regular.ttf" ++ }, ++ { ++ "Noto Sans Linear A Regular": "NotoSansLinearA-Regular.ttf" ++ }, ++ { ++ "Noto Sans Linear B Regular": "NotoSansLinearB-Regular.ttf" ++ }, ++ { ++ "Noto Sans Lisu Regular": "NotoSansLisu[wght].ttf" ++ }, ++ { ++ "Noto Sans Lycian Regular": "NotoSansLycian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Lydian Regular": "NotoSansLydian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Malayalam UI Bold": "NotoSansMalayalamUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Malayalam UI Medium": "NotoSansMalayalamUI-Medium.ttf" ++ }, ++ { ++ "Noto Sans Malayalam UI Regular": "NotoSansMalayalamUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Malayalam UI SemiBold": "NotoSansMalayalamUI-SemiBold.ttf" ++ }, ++ { ++ "Noto Sans Malayalam Regular": "NotoSansMalayalam[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Mandaic Regular": "NotoSansMandaic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Manichaean Regular": "NotoSansManichaean-Regular.ttf" ++ }, ++ { ++ "Noto Sans Marchen Regular": "NotoSansMarchen-Regular.ttf" ++ }, ++ { ++ "Noto Sans Masaram Gondi Regular": "NotoSansMasaramGondi-Regular.ttf" ++ }, ++ { ++ "Noto Sans Medefaidrin Regular": "NotoSansMedefaidrin[wght].ttf" ++ }, ++ { ++ "Noto Sans Meetei Mayek Regular": "NotoSansMeeteiMayek[wght].ttf" ++ }, ++ { ++ "Noto Sans Meroitic Regular": "NotoSansMeroitic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Miao Regular": "NotoSansMiao-Regular.ttf" ++ }, ++ { ++ "Noto Sans Modi Regular": "NotoSansModi-Regular.ttf" ++ }, ++ { ++ "Noto Sans Mongolian Regular": "NotoSansMongolian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Mono Regular": "NotoSansMono[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Mro Regular": "NotoSansMro-Regular.ttf" ++ }, ++ { ++ "Noto Sans Multani Regular": "NotoSansMultani-Regular.ttf" ++ }, ++ { ++ "Noto Sans Myanmar Regular": "NotoSansMyanmar[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans NKo Regular": "NotoSansNKo-Regular.ttf" ++ }, ++ { ++ "Noto Sans Nabataean Regular": "NotoSansNabataean-Regular.ttf" ++ }, ++ { ++ "Noto Sans New Tai Lue Regular": "NotoSansNewTaiLue[wght].ttf" ++ }, ++ { ++ "Noto Sans Newa Regular": "NotoSansNewa-Regular.ttf" ++ }, ++ { ++ "Noto Sans Ogham Regular": "NotoSansOgham-Regular.ttf" ++ }, ++ { ++ "Noto Sans Ol Chiki Regular": "NotoSansOlChiki[wght].ttf" ++ }, ++ { ++ "Noto Sans Old Italic Regular": "NotoSansOldItalic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Old North Arabian Regular": "NotoSansOldNorthArabian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Old Permic Regular": "NotoSansOldPermic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Old Persian Regular": "NotoSansOldPersian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Old South Arabian Regular": "NotoSansOldSouthArabian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Old Turkic Regular": "NotoSansOldTurkic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Oriya Regular": "NotoSansOriya[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Osage Regular": "NotoSansOsage-Regular.ttf" ++ }, ++ { ++ "Noto Sans Osmanya Regular": "NotoSansOsmanya-Regular.ttf" ++ }, ++ { ++ "Noto Sans Pahawh Hmong Regular": "NotoSansPahawhHmong-Regular.ttf" ++ }, ++ { ++ "Noto Sans Palmyrene Regular": "NotoSansPalmyrene-Regular.ttf" ++ }, ++ { ++ "Noto Sans Pau Cin Hau Regular": "NotoSansPauCinHau-Regular.ttf" ++ }, ++ { ++ "Noto Sans Phags-Pa Regular": "NotoSansPhags-Pa-Regular.ttf" ++ }, ++ { ++ "Noto Sans Phoenician Regular": "NotoSansPhoenician-Regular.ttf" ++ }, ++ { ++ "Noto Sans Rejang Regular": "NotoSansRejang-Regular.ttf" ++ }, ++ { ++ "Noto Sans Runic Regular": "NotoSansRunic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Samaritan Regular": "NotoSansSamaritan-Regular.ttf" ++ }, ++ { ++ "Noto Sans Saurashtra Regular": "NotoSansSaurashtra-Regular.ttf" ++ }, ++ { ++ "Noto Sans Sharada Regular": "NotoSansSharada-Regular.ttf" ++ }, ++ { ++ "Noto Sans Shavian Regular": "NotoSansShavian-Regular.ttf" ++ }, ++ { ++ "Noto Sans Sinhala UI Bold": "NotoSansSinhalaUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Sinhala UI Medium": "NotoSansSinhalaUI-Medium.ttf" ++ }, ++ { ++ "Noto Sans Sinhala UI Regular": "NotoSansSinhalaUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Sinhala UI SemiBold": "NotoSansSinhalaUI-SemiBold.ttf" ++ }, ++ { ++ "Noto Sans Sinhala Regular": "NotoSansSinhala[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Sora Sompeng Regular": "NotoSansSoraSompeng[wght].ttf" ++ }, ++ { ++ "Noto Sans Soyombo Regular": "NotoSansSoyombo-Regular.ttf" ++ }, ++ { ++ "Noto Sans Sundanese Regular": "NotoSansSundanese[wght].ttf" ++ }, ++ { ++ "Noto Sans Syloti Nagri Regular": "NotoSansSylotiNagri-Regular.ttf" ++ }, ++ { ++ "Noto Sans Symbols Regular": "NotoSansSymbols-Regular.ttf" ++ }, ++ { ++ "Noto Sans Symbols 2 Regular": "NotoSansSymbols2-Regular.ttf" ++ }, ++ { ++ "Noto Sans Syriac Eastern Regular": "NotoSansSyriacEastern[wght].ttf" ++ }, ++ { ++ "Noto Sans Syriac Western Regular": "NotoSansSyriacWestern[wght].ttf" ++ }, ++ { ++ "Noto Sans Tagalog Regular": "NotoSansTagalog-Regular.ttf" ++ }, ++ { ++ "Noto Sans Tagbanwa Regular": "NotoSansTagbanwa-Regular.ttf" ++ }, ++ { ++ "Noto Sans Tai Le Regular": "NotoSansTaiLe-Regular.ttf" ++ }, ++ { ++ "Noto Sans Tai Tham Regular": "NotoSansTaiTham[wght].ttf" ++ }, ++ { ++ "Noto Sans Tai Viet Regular": "NotoSansTaiViet-Regular.ttf" ++ }, ++ { ++ "Noto Sans Takri Regular": "NotoSansTakri-Regular.ttf" ++ }, ++ { ++ "Noto Sans Tamil UI Bold": "NotoSansTamilUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Tamil UI Medium": "NotoSansTamilUI-Medium.ttf" ++ }, ++ { ++ "Noto Sans Tamil UI Regular": "NotoSansTamilUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Tamil UI SemiBold": "NotoSansTamilUI-SemiBold.ttf" ++ }, ++ { ++ "Noto Sans Tamil Regular": "NotoSansTamil[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Telugu UI Bold": "NotoSansTeluguUI-Bold.ttf" ++ }, ++ { ++ "Noto Sans Telugu UI Medium": "NotoSansTeluguUI-Medium.ttf" ++ }, ++ { ++ "Noto Sans Telugu UI Regular": "NotoSansTeluguUI-Regular.ttf" ++ }, ++ { ++ "Noto Sans Telugu UI SemiBold": "NotoSansTeluguUI-SemiBold.ttf" ++ }, ++ { ++ "Noto Sans Telugu Regular": "NotoSansTelugu[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Thaana Regular": "NotoSansThaana[wght].ttf" ++ }, ++ { ++ "Noto Sans Thai Regular": "NotoSansThai[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Tifinagh Regular": "NotoSansTifinagh-Regular.ttf" ++ }, ++ { ++ "Noto Sans Ugaritic Regular": "NotoSansUgaritic-Regular.ttf" ++ }, ++ { ++ "Noto Sans Vai Regular": "NotoSansVai-Regular.ttf" ++ }, ++ { ++ "Noto Sans Wancho Regular": "NotoSansWancho-Regular.ttf" ++ }, ++ { ++ "Noto Sans Warang Citi Regular": "NotoSansWarangCiti-Regular.ttf" ++ }, ++ { ++ "Noto Sans Yi Regular": "NotoSansYi-Regular.ttf" ++ }, ++ { ++ "Noto Sans Regular": "NotoSans[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Ahom Regular": "NotoSerifAhom-Regular.ttf" ++ }, ++ { ++ "Noto Serif Armenian Regular": "NotoSerifArmenian[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Bengali Regular": "NotoSerifBengali[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif CJK JP": "NotoSerifCJK-Regular.ttc" ++ }, ++ { ++ "Noto Serif Devanagari Regular": "NotoSerifDevanagari[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Dogra Regular": "NotoSerifDogra-Regular.ttf" ++ }, ++ { ++ "Noto Serif Ethiopic Regular": "NotoSerifEthiopic[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Georgian Regular": "NotoSerifGeorgian[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Gujarati Regular": "NotoSerifGujarati[wght].ttf" ++ }, ++ { ++ "Noto Serif Gurmukhi Regular": "NotoSerifGurmukhi[wght].ttf" ++ }, ++ { ++ "Noto Serif Hebrew Regular": "NotoSerifHebrew[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Kannada Regular": "NotoSerifKannada[wght].ttf" ++ }, ++ { ++ "Noto Serif Khmer Regular": "NotoSerifKhmer[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Lao Regular": "NotoSerifLao[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Malayalam Regular": "NotoSerifMalayalam[wght].ttf" ++ }, ++ { ++ "Noto Serif Myanmar Regular": "NotoSerifMyanmar[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Sinhala Regular": "NotoSerifSinhala[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Tamil Regular": "NotoSerifTamil[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Telugu Regular": "NotoSerifTelugu[wght].ttf" ++ }, ++ { ++ "Noto Serif Thai Regular": "NotoSerifThai[wdth,wght].ttf" ++ }, ++ { ++ "Noto Serif Tibetan Regular": "NotoSerifTibetan[wght].ttf" ++ }, ++ { ++ "Noto Serif Yezidi Regular": "NotoSerifYezidi[wght].ttf" ++ }, ++ { ++ "Noto Serif Regular": "NotoSerif[wdth,wght].ttf" ++ }, ++ { ++ "Noto Sans Regular": "Roboto-Regular.ttf" ++ }, ++ { ++ "Noto Sans Math Regular": "NotoSansMath-Regular.ttf" ++ }, ++ { ++ "FangS-SC": "FangS-SC.ttf" ++ }, ++ { ++ "仿宋-简": "FangS-SC.ttf" ++ }, ++ { ++ "FT Thymes Regular": "FTThymes-Regular.ttf" ++ }, ++ { ++ "HeiT-SC": "HeiT-SC-Regular.ttf" ++ }, ++ { ++ "ShuS-SC ": "ShuS-SC.ttf" ++ }, ++ { ++ "书宋-简": "ShuS-SC.ttf" ++ }, ++ { ++ "KaiT-SC": "KaiT-SC.ttf" ++ }, ++ { ++ "楷体-简": "KaiT-SC.ttf" + } + ] +} @@ -3812,6 +5109,3 @@ index fca2f34ded..65955a7041 100644 OutputStream* rawOut = fOut; StringStream body; fOut = &body; --- -2.25.1 - diff --git a/attachment/scripts/__init__.py b/attachment/scripts/__init__.py index b77650f002ba0e7f9ee77b4d2ce1ec4baeeaada9..cd2197e415a897151b8f8258ef42693678459991 100644 --- a/attachment/scripts/__init__.py +++ b/attachment/scripts/__init__.py @@ -1,12 +1,3 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. \ No newline at end of file +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. \ No newline at end of file diff --git a/attachment/scripts/artifacts_files.json b/attachment/scripts/artifacts_files.json new file mode 100644 index 0000000000000000000000000000000000000000..31a2e2e42ab5cdcfc9fc851e9db75333e6516625 --- /dev/null +++ b/attachment/scripts/artifacts_files.json @@ -0,0 +1,55 @@ +{ + "darwin-arm64": { + "src/out/host_release/gen/frontend_server.dart.snapshot": "frontend_server.dart.snapshot", + "src/out/host_release/gen_snapshot": "gen_snapshot", + "src/out/host_release/icudtl.dat": "icudtl.dat", + "src/out/host_release/impellerc": "impellerc", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin": "isolate_snapshot.bin", + "src/out/host_release/libpath_ops.dylib": "libpath_ops.dylib", + "src/out/host_release/libtessellator.dylib": "libtessellator.dylib", + "src/out/host_release/shader_lib/": "shader_lib", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin": "vm_isolate_snapshot.bin", + "src/out/host_release/gen/const_finder.dart.snapshot": "const_finder.dart.snapshot" + + }, + "darwin-x64": { + "src/out/host_release/flutter_tester": "flutter_tester", + "src/out/host_release/gen/frontend_server.dart.snapshot": "frontend_server.dart.snapshot", + "src/out/host_release/gen_snapshot": "gen_snapshot", + "src/out/host_release/icudtl.dat": "icudtl.dat", + "src/out/host_release/impellerc": "impellerc", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin": "isolate_snapshot.bin", + "src/out/host_release/libpath_ops.dylib": "libpath_ops.dylib", + "src/out/host_release/libtessellator.dylib": "libtessellator.dylib", + "src/out/host_release/shader_lib/": "shader_lib", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin": "vm_isolate_snapshot.bin", + "src/out/host_release/gen/const_finder.dart.snapshot": "const_finder.dart.snapshot" + }, + "windows-x64": { + "src/out/host_release/flutter_tester.exe": "flutter_tester.exe", + "src/out/host_release/gen/frontend_server.dart.snapshot": "frontend_server.dart.snapshot", + "src/out/host_release/gen_snapshot.exe": "gen_snapshot.exe", + "src/out/host_release/icudtl.dat": "icudtl.dat", + "src/out/host_release/impellerc.exe": "impellerc.exe", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin": "isolate_snapshot.bin", + "src/out/host_release/path_ops.dll": "path_ops.dll", + "src/out/host_release/libtessellator.dll": "libtessellator.dll", + "src/out/host_release/shader_lib/": "shader_lib", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin": "vm_isolate_snapshot.bin", + "src/out/host_release/gen/const_finder.dart.snapshot": "const_finder.dart.snapshot" + }, + "linux-x64": { + "src/out/host_release/flutter_tester": "flutter_tester", + "src/out/host_release/gen/frontend_server.dart.snapshot": "frontend_server.dart.snapshot", + "src/out/host_release/gen_snapshot": "gen_snapshot", + "src/out/host_release/icudtl.dat": "icudtl.dat", + "src/out/host_release/impellerc": "impellerc", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin": "isolate_snapshot.bin", + "src/out/host_release/libpath_ops.so": "libpath_ops.so", + "src/out/host_release/libtessellator.so": "libtessellator.so", + "src/out/host_release/shader_lib/": "shader_lib", + "src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin": "vm_isolate_snapshot.bin", + "src/out/host_release/gen/const_finder.dart.snapshot": "const_finder.dart.snapshot" + } +} + diff --git a/attachment/scripts/auto_compile.py b/attachment/scripts/auto_compile.py index 3dab798b0f7fceefc7e225ddecf1d4d678966014..124b912ae8feff4368219deb39cb242f44842a63 100644 --- a/attachment/scripts/auto_compile.py +++ b/attachment/scripts/auto_compile.py @@ -20,6 +20,8 @@ import subprocess import sys import traceback import zipfile +import argparse +from pathlib import Path from obs import ObsClient, PutObjectHeader # 使用华为obs @@ -28,14 +30,16 @@ from obs import ObsClient, PutObjectHeader OS_NAME = platform.system().lower() IS_WINDOWS = OS_NAME.startswith("win") IS_MAC = OS_NAME.startswith("darwin") -FLUTTER_ENGINE_PATH = os.path.join(os.getcwd(), 'src', 'flutter') -OHOS_ENGINE_TYPE_OUT = {'ohos-arm64' : 'ohos_debug_unopt_arm64', - 'ohos-arm64-profile' : 'ohos_profile_arm64', - 'ohos-arm64-release' : 'ohos_release_arm64', - 'ohos-x64' : 'ohos_debug_unopt_x64', - 'ohos-x64-profile' : 'ohos_profile_x64', - 'ohos-x64-release' : 'ohos_release_x64', - } +engine_project_root_dir = Path(os.path.realpath(__file__)).parents[4] +FLUTTER_ENGINE_PATH = os.path.join(engine_project_root_dir.__str__(), 'src', 'flutter') +OHOS_ENGINE_TYPE_OUT = { + 'ohos-arm64': 'ohos_debug_unopt_arm64', + 'ohos-arm64-profile': 'ohos_profile_arm64', + 'ohos-arm64-release': 'ohos_release_arm64', + 'ohos-x64': 'ohos_debug_unopt_x64', + 'ohos-x64-profile': 'ohos_profile_x64', + 'ohos-x64-release': 'ohos_release_x64', +} UPLOAD_TEMPLATE = "upload_template.json" @@ -46,189 +50,213 @@ SECRET_KEY = os.getenv("SecretAccessKey") # 服务器地址 华南-广州 SERVER = "https://obs.cn-south-1.myhuaweicloud.com" -# OBS桶 +# OBS桶 FLUTTER_OHOS = 'flutter-ohos' + def log(msg): - print(f'================{msg}============') + print(f'================{msg}============') + def runGitCommand(command): - result = subprocess.run(command, capture_output=True, text=True, shell=True) - if result.returncode != 0: - raise Exception(f"Git command failed: {result.stderr}") - return result.stdout.strip() + result = subprocess.run(command, capture_output=True, text=True, shell=True) + if result.returncode != 0: + raise Exception(f"Git command failed: {result.stderr}") + return result.stdout.strip() + def runPyCommand(command): - if IS_WINDOWS: - proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - else: - proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) + if IS_WINDOWS: + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + else: + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) - # 获取实时输出 - for line in iter(proc.stdout.readline, b''): - print(line.decode('utf-8').strip()) + # 获取实时输出 + for line in iter(proc.stdout.readline, b''): + print(line.decode('utf-8').strip()) + + # 等待命令执行完成 + proc.wait() - # 等待命令执行完成 - proc.wait() def getRemoteTags(repoPath, remoteName='origin'): - # 获取远程仓库的所有标签 - tagsOutput = runGitCommand(f'git -C {repoPath} ls-remote --tags {remoteName}') + # 获取远程仓库的所有标签 + tagsOutput = runGitCommand(f'git -C {repoPath} ls-remote --tags {remoteName}') + + # 分割输出,每一行都是一个tag + tags = tagsOutput.split('\n') - # 分割输出,每一行都是一个tag - tags = tagsOutput.split('\n') + # 去除空行和解析tag信息 + parsedTags = [line.split()[0] for line in tags if line] - # 去除空行和解析tag信息 - parsedTags = [line.split()[0] for line in tags if line] + return parsedTags - return parsedTags # 在指定目录及其子目录中查找指定的文件 def findFile(directory, filename): - for root, dirs, files in os.walk(directory): - if filename in files: - return (os.path.join(root, filename)) + for root, dirs, files in os.walk(directory): + if filename in files: + return (os.path.join(root, filename)) + # 获取上传对象的进度 def uploadCallback(transferredAmount, totalAmount, totalSeconds): - # 获取上传平均速率(KB/S) - speed = int(transferredAmount / totalSeconds / 1024) - # 获取上传进度百分比 - progress = int(transferredAmount * 100.0 / totalAmount) - print("\r", end="") - print("Speed: {} KB/S progress: {}%: ".format(speed, progress), "▓" * (progress // 2), end="") - sys.stdout.flush() - if progress == 100: - print("") + # 获取上传平均速率(KB/S) + speed = int(transferredAmount / totalSeconds / 1024) + # 获取上传进度百分比 + progress = int(transferredAmount * 100.0 / totalAmount) + print("\r", end="") + print("Speed: {} KB/S progress: {}%: ".format(speed, progress), "▓" * (progress // 2), end="") + sys.stdout.flush() + if progress == 100: + print("") + # 检查TAG版本 def checkRemoteTagsUpdates(): - # 获取远程TAG的最新提交哈希 - remoteTags = getRemoteTags(FLUTTER_ENGINE_PATH) - remoteLatestTag = remoteTags[-1] + # 获取远程TAG的最新提交哈希 + remoteTags = getRemoteTags(FLUTTER_ENGINE_PATH) + remoteLatestTag = remoteTags[-1] - # 获取本地分支的最新提交哈希 - localLatestCommit = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') + # 获取本地分支的最新提交哈希 + localLatestCommit = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') + + if remoteLatestTag != localLatestCommit: + log("Remote repository has updates.") + return True + else: + log("Local repository is up to date.") + return False - if remoteLatestTag != localLatestCommit: - log("Remote repository has updates.") - return True - else: - log("Local repository is up to date.") - return False # 检查分支更新 def checkRemoteBranchUpdates(repoPath, remoteName='origin', branch='dev'): - # 切换到你的Git仓库目录 - os.chdir(repoPath) + # 切换到你的Git仓库目录 + os.chdir(repoPath) - # 获取远程分支的最新提交哈希 - remoteLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse {remoteName}/{branch}') + # 获取远程分支的最新提交哈希 + remoteLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse {remoteName}/{branch}') - # 获取本地分支的最新提交哈希 - localLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse HEAD') + # 获取本地分支的最新提交哈希 + localLatestCommit = runGitCommand(f'git -C {repoPath} rev-parse HEAD') - if remoteLatestCommit != localLatestCommit: - log("Remote repository has updates.") - return True - else: - log("Local repository is up to date.") - return False + if remoteLatestCommit != localLatestCommit: + log("Remote repository has updates.") + return True + else: + log("Local repository is up to date.") + return False # 获取编译产物 def getCompileFiles(buildType): - zipfiles = ['artifacts.zip','linux-x64.zip','windows-x64.zip','darwin-x64.zip','symbols.zip'] + zipfiles = ['artifacts.zip', 'linux-x64.zip', 'windows-x64.zip', 'darwin-x64.zip', 'symbols.zip'] + + files = [] + for fileName in zipfiles: + if IS_WINDOWS and fileName != 'windows-x64.zip': + continue + if IS_MAC and fileName != 'darwin-x64.zip': + continue - files = [] - for fileName in zipfiles: - if IS_WINDOWS and fileName != 'windows-x64.zip': - continue - if IS_MAC and fileName != 'darwin-x64.zip': - continue + files.append( + findFile( + os.path.join(engine_project_root_dir.__str__(), 'src', 'out', buildType), fileName + ) + ) - files.append(findFile(os.path.join(os.getcwd(), 'src', 'out', buildType), fileName)) + return files - return files def uploadExtraFiles(localVersion): - log("uploadExtraFiles ") - if not os.path.exists(UPLOAD_TEMPLATE): - log(f"File not exist: {UPLOAD_TEMPLATE}") - return - with open(UPLOAD_TEMPLATE, 'r') as jsonFile: - jsonData = json.load(jsonFile) - tag = jsonData["tag"] - if not tag: - tag = localVersion; - log(f"tag = {tag}") - uploadFiles = jsonData["files"] - for key in uploadFiles: - value = uploadFiles[key] - if os.path.exists(value): - uploadServer(tag, key, value) - else: - log(f"Not exist file: {value}") + log("uploadExtraFiles ") + if not os.path.exists(UPLOAD_TEMPLATE): + log(f"File not exist: {UPLOAD_TEMPLATE}") + return + with open(UPLOAD_TEMPLATE, 'r') as jsonFile: + jsonData = json.load(jsonFile) + tag = jsonData["tag"] + if not tag: + tag = localVersion + log(f"tag = {tag}") + uploadFiles = jsonData["files"] + for key in uploadFiles: + value = uploadFiles[key] + if os.path.exists(value): + uploadServer(tag, key, value) + else: + log(f"Not exist file: {value}") + # 上传服务器 def uploadServer(version, buildType, filePath): - try: - log(f'upload: {filePath}') - - bucketName = FLUTTER_OHOS - obsClient = ObsClient(access_key_id=ACCESS_KEY, secret_access_key=SECRET_KEY, server=SERVER) - - # 上传对象的附加头域 - headers = PutObjectHeader() - # 【可选】待上传对象的MIME类型 - headers.contentType = 'text/plain' - - # https://storage.flutter-io.cn/flutter_infra_release/flutter/cececddab019a56da828c41d55cb54484278e880/ohos-arm64-profile/linux-x64.zip - fileName = os.path.basename(filePath) - objectKey = f'flutter_infra_release/flutter/{version}/{buildType}/{fileName}' - log(f'objectKey: {objectKey}') - - # 待上传文件/文件夹的完整路径,如aa/bb.txt,或aa/ - file_path = filePath - - # 文件上传 - resp = obsClient.putFile(bucketName, objectKey, file_path, headers=headers, progressCallback=uploadCallback) - # 返回码为2xx时,接口调用成功,否则接口调用失败 - if resp.status < 300: - print('Put Content Succeeded') - print('requestId:', resp.requestId) - print('etag:', resp.body.etag) - else: - print('Put Content Failed') - print('requestId:', resp.requestId) - print('errorCode:', resp.errorCode) - print('errorMessage:', resp.errorMessage) - - except: - log('Put Content Failed') - log(traceback.format_exc()) + try: + log(f'upload: {filePath}') + + bucketName = FLUTTER_OHOS + obsClient = ObsClient(access_key_id=ACCESS_KEY, secret_access_key=SECRET_KEY, server=SERVER) + + # 上传对象的附加头域 + headers = PutObjectHeader() + # 【可选】待上传对象的MIME类型 + headers.contentType = 'text/plain' + + # https://storage.flutter-io.cn/flutter_infra_release/flutter/cececddab019a56da828c41d55cb54484278e880/ohos-arm64-profile/linux-x64.zip + fileName = os.path.basename(filePath) + objectKey = f'flutter_infra_release/flutter/{version}/{buildType}/{fileName}' + log(f'objectKey: {objectKey}') + + # 待上传文件/文件夹的完整路径,如aa/bb.txt,或aa/ + file_path = filePath + + # 文件上传 + resp = obsClient.putFile( + bucketName, objectKey, file_path, headers=headers, progressCallback=uploadCallback + ) + # 返回码为2xx时,接口调用成功,否则接口调用失败 + if resp.status < 300: + print('Put Content Succeeded') + print('requestId:', resp.requestId) + print('etag:', resp.body.etag) + else: + print('Put Content Failed') + print('requestId:', resp.requestId) + print('errorCode:', resp.errorCode) + print('errorMessage:', resp.errorMessage) + + except: + log('Put Content Failed') + log(traceback.format_exc()) def main(): - if checkRemoteTagsUpdates() : - localVersion = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') - log(localVersion) + if checkRemoteTagsUpdates(): + parser = argparse.ArgumentParser( + prog='auto_compile', description='upload artifacts', epilog='upload artifacts' + ) + parser.add_argument('-t', '--tag') + args = parser.parse_args() + if args.tag: + version = args.tag + else: + version = runGitCommand(f'git -C {FLUTTER_ENGINE_PATH} rev-parse HEAD') + log(version) + # 获取编译产物 + for buildType in OHOS_ENGINE_TYPE_OUT: + zipfiles = getCompileFiles(OHOS_ENGINE_TYPE_OUT[buildType]) + for filePath in zipfiles: + if not filePath or not os.path.exists(filePath): + continue + uploadServer(version, buildType, filePath) - # 获取编译产物 - for buildType in OHOS_ENGINE_TYPE_OUT: - zipfiles = getCompileFiles(OHOS_ENGINE_TYPE_OUT[buildType]) - for filePath in zipfiles: - if not filePath or not os.path.exists(filePath): - continue - uploadServer(localVersion, buildType, filePath) + uploadExtraFiles(version) + log('上传完成') - uploadExtraFiles(localVersion) - log('上传完成') + else: + log("本地代码已经是最新") - else : - log("本地代码已经是最新") if __name__ == "__main__": - exit(main()) + exit(main()) diff --git a/attachment/scripts/excute_util.py b/attachment/scripts/excute_util.py index 17e7f28c7c1d7c4728b94c05171fdf09ba8e4318..5983925b4ccf405fdcdcaa19754a2de6bd7aef77 100644 --- a/attachment/scripts/excute_util.py +++ b/attachment/scripts/excute_util.py @@ -1,15 +1,6 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. #!/usr/bin/python import subprocess diff --git a/attachment/scripts/file_util.py b/attachment/scripts/file_util.py index 28d779a6929a84914da322b3ca6d44525322360c..a7a302ffe057ca622b20eb94bb35b17f9c0e7fa5 100644 --- a/attachment/scripts/file_util.py +++ b/attachment/scripts/file_util.py @@ -1,15 +1,6 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. #!/usr/bin/python import shutil diff --git a/attachment/scripts/ohos.py b/attachment/scripts/ohos.py index d60c405775fcb9c163d2784360cc1b7097be03d3..224eafb2fa2e62d26bd8b5fa72d01fb3884db638 100644 --- a/attachment/scripts/ohos.py +++ b/attachment/scripts/ohos.py @@ -1,18 +1,9 @@ #!/usr/bin/env python3 # coding=utf-8 # -# Copyright (c) 2021-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. import argparse import json @@ -26,7 +17,7 @@ import sys import zipfile from datetime import datetime -SUPPORT_BUILD_NAMES = ("clean", "config", "har", "compile", "zip", "zip2", "upload") +SUPPORT_BUILD_NAMES = ("clean", "config", "har", "compile", "zip", "zip2", "upload", "host") SUPPORT_BUILD_TYPES = ("debug", "profile", "release") SUPPORT_ABIS = { "x86": "x86", @@ -198,6 +189,7 @@ def engineConfig(buildInfo, args): + unixCommand + "--no-goma " + "--no-prebuilt-dart-sdk " + + "--full-dart-sdk " + "--embedder-for-target " + "--disable-desktop-embeddings " + "--no-build-embedder-examples " @@ -298,7 +290,7 @@ def zipFiles(buildInfo, useZip2=False, args=any): prefixInZip = os.path.join("src", "out", outputName) excludes = ["obj", "exe.unstripped", "so.unstripped"] if IS_WINDOWS: - excludes.extend([".*\.ilk", ".*\.pdb"]) + excludes.extend([r".*\.ilk", r".*\.pdb"]) zipFileDir(fileIn, fileName, prefixInZip, excludes=excludes, useZip2=useZip2) @@ -340,6 +332,9 @@ def addParseParam(parser): parser.add_argument( "--ohos-cpu", type=str, choices=['x64', 'x86', 'arm64', 'arm'], default="arm64" ) + parser.add_argument( + "--host-cpu", type=str, choices=['x64', 'arm64'], default="x64" + ) def updateCode(args): @@ -362,6 +357,32 @@ def checkEnvironment(): exit(1) +def buildLocalEngine(buildType, args): + OPT = "--unoptimized --no-lto " if buildType == "debug" else "" + extraParam = args.gn_extra_param + osName = platform.system().lower() + hostAppend = f"--mac-cpu {args.host_cpu}" if osName == "darwin" else "" + runCommand( + "%s " % os.path.join("src", "flutter", "tools", "gn") + + "--runtime-mode %s " % buildType + + OPT + + "--no-goma " + + "--no-prebuilt-dart-sdk " + + "--full-dart-sdk " + + "--disable-desktop-embeddings " + + "--no-build-embedder-examples " + + "--verbose " + + hostAppend + + extraParam.replace("\\", ""), + checkCode=False, + timeout=600, + ) + append1 = "_unopt" if buildType == "debug" else "" + append2 = "_arm64" if args.host_cpu == "arm64" else "" + outputName = f"host_{buildType}{append1}{append2}" + runCommand(f"ninja -C src/out/{outputName}") + + def uploadFiles(): runCommand("python3 src/flutter/attachment/scripts/auto_compile.py") @@ -388,6 +409,8 @@ def buildByNameAndType(args): zipFiles(buildInfo, False, args) elif "zip2" == buildName: zipFiles(buildInfo, True, args) + elif "host" == buildName: + buildLocalEngine(buildType, args) else: logging.warning("Other name=%s" % buildName) diff --git a/attachment/scripts/ohos_create_flutter_har.py b/attachment/scripts/ohos_create_flutter_har.py index cc481911fe2dfe8a7faf5db65e6d39e3ad93c2c2..cc15fa1ddcd16c194eb18d8b3e6da2a79839a6aa 100644 --- a/attachment/scripts/ohos_create_flutter_har.py +++ b/attachment/scripts/ohos_create_flutter_har.py @@ -1,17 +1,6 @@ -#!/usr/bin/env python3 -# -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. """Create a HAR incorporating all the components required to build a Flutter application""" diff --git a/attachment/scripts/ohos_reverse_patch.py b/attachment/scripts/ohos_reverse_patch.py index c43013503816f47fdca3bbb1df549c0fee3848f5..f0e44b1063f8bdf4afa45a55fb13b5ef93ff0e92 100644 --- a/attachment/scripts/ohos_reverse_patch.py +++ b/attachment/scripts/ohos_reverse_patch.py @@ -1,15 +1,6 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. #!/usr/bin/python import sys diff --git a/attachment/scripts/ohos_setup.py b/attachment/scripts/ohos_setup.py index 742ca96f1592c0c561679c2af3b8df4ae850b998..44757f9837cd4d20e2fab7223a70be9b4d636400 100644 --- a/attachment/scripts/ohos_setup.py +++ b/attachment/scripts/ohos_setup.py @@ -1,15 +1,6 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. #!/usr/bin/python import sys diff --git a/attachment/scripts/ohos_setup_pre.py b/attachment/scripts/ohos_setup_pre.py index 10c287f22c10ee6ec09dcc8c5e4b901e8f47d736..ad5366edf877a5debb87cfd4c76080d8163a4d6e 100644 --- a/attachment/scripts/ohos_setup_pre.py +++ b/attachment/scripts/ohos_setup_pre.py @@ -1,15 +1,6 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. #!/usr/bin/python import ohos_setup diff --git a/attachment/scripts/upload_dart_sdk.py b/attachment/scripts/upload_dart_sdk.py new file mode 100644 index 0000000000000000000000000000000000000000..8513b73dc67ab32d1469c2d88915dd7b83574d41 --- /dev/null +++ b/attachment/scripts/upload_dart_sdk.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. + +import os +import logging +import argparse +import platform +from pathlib import Path +from utils import getArch, getEnginePath, runGitCommand, upload + +engine_path = getEnginePath() + +logging.basicConfig() +log = logging.getLogger() +log.setLevel(logging.INFO) + + +def main(): + parser = argparse.ArgumentParser( + prog='upload_dart_sdk', description='upload dart sdk', epilog='upload dart sdk' + ) + parser.add_argument('-t', '--tag') + parser.add_argument('-f', '--file') + parser.add_argument('--arch', type=str, choices=['x64', 'arm64'], default="x64") + args = parser.parse_args() + osArch = args.arch + osName = platform.system().lower() + file_name = f'dart-sdk-{osName}-{osArch}.zip' + if args.file: + file_path = args.file + else: + file_path = Path(engine_path).joinpath(file_name).__str__() + flutter_path = Path(engine_path).joinpath('src/flutter').__str__() + if args.tag: + version = args.tag + else: + version = runGitCommand(f'git -C {flutter_path} rev-parse HEAD') + log.info(version) + upload(version, file_path) + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/upload_flutter_patched_sdk.py b/attachment/scripts/upload_flutter_patched_sdk.py new file mode 100644 index 0000000000000000000000000000000000000000..5e0842c80fe77b7cc7c25401c930a24a70afae87 --- /dev/null +++ b/attachment/scripts/upload_flutter_patched_sdk.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. + +import logging +import argparse +from pathlib import Path +from utils import getEnginePath, runGitCommand +from utils import upload + +engine_path = getEnginePath() + +logging.basicConfig() +log = logging.getLogger() +log.setLevel(logging.INFO) + + +def main(): + parser = argparse.ArgumentParser( + prog='upload flutter patched sdk', + description='upload flutter_patched_sdk', + epilog='upload flutter_patched_sdk' + ) + parser.add_argument('-t', '--tag') + parser.add_argument('-d', '--patched_sdk') + parser.add_argument('-p', '--patched_sdk_product') + args = parser.parse_args() + patched_sdk = 'flutter_patched_sdk.zip' + patched_sdk_product = 'flutter_patched_sdk_product.zip' + if args.patched_sdk and args.patched_sdk_product: + patched_sdk_path = args.patched_sdk + patched_sdk_product_path = args.patched_sdk_product + else: + patched_sdk_path = Path(engine_path).joinpath(patched_sdk).__str__() + patched_sdk_product_path = Path(engine_path).joinpath(patched_sdk_product).__str__() + if args.tag: + version = args.tag + else: + flutter_path = Path(engine_path).joinpath('src/flutter').__str__() + version = runGitCommand(f'git -C {flutter_path} rev-parse HEAD') + log.info(version) + upload(version, patched_sdk_path) + upload(version, patched_sdk_product_path) + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/upload_sky_engine.py b/attachment/scripts/upload_sky_engine.py new file mode 100644 index 0000000000000000000000000000000000000000..5fd8fdde1eb027172ba698bae26aeb6c9c71b7fa --- /dev/null +++ b/attachment/scripts/upload_sky_engine.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. + +import logging +import argparse +from pathlib import Path +from utils import getEnginePath, runGitCommand +from utils import upload + +engine_path = getEnginePath() + +logging.basicConfig() +log = logging.getLogger() +log.setLevel(logging.INFO) + + +def main(): + parser = argparse.ArgumentParser( + prog='upload sky_engine', description='upload sky_engine', epilog='upload sky_engine' + ) + parser.add_argument('-t', '--tag') + parser.add_argument('-f', '--file') + args = parser.parse_args() + file_name = 'sky_engine.zip' + if args.file: + file_path = args.file + else: + file_path = Path(engine_path).joinpath(file_name).__str__() + if args.tag: + version = args.tag + else: + flutter_path = Path(engine_path).joinpath('src/flutter').__str__() + version = runGitCommand(f'git -C {flutter_path} rev-parse HEAD') + log.info(version) + upload(version, file_path) + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/utils.py b/attachment/scripts/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3169f035897e280024f5df7eb91d6d77af8292aa --- /dev/null +++ b/attachment/scripts/utils.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. + +import logging +import platform +import os +import subprocess +from pathlib import Path +import sys +from obs import ObsClient, PutObjectHeader + +log = logging.getLogger(__name__) + +FLUTTER_OHOS = 'flutter-ohos' + +# OBS 环境变量配置key信息 +ACCESS_KEY = os.getenv("AccessKeyID") +SECRET_KEY = os.getenv("SecretAccessKey") + +# 服务器地址 华南-广州 +SERVER = "https://obs.cn-south-1.myhuaweicloud.com" + + +def upload(version, file_path): + bucketName = FLUTTER_OHOS + obsClient = ObsClient(access_key_id=ACCESS_KEY, secret_access_key=SECRET_KEY, server=SERVER) + headers = PutObjectHeader() + headers.contentType = 'text/plain' + file_name = os.path.basename(file_path) + objectKey = f'flutter_infra_release/flutter/{version}/{file_name}' + print(f'objectKey: {objectKey}') + resp = obsClient.putFile( + bucketName, objectKey, file_path, headers=headers, progressCallback=uploadCallback + ) + if resp.status < 300: + print('Put Content Succeeded') + print('requestId:', resp.requestId) + print('etag:', resp.body.etag) + else: + print('Put Content Failed') + print('requestId:', resp.requestId) + print('errorCode:', resp.errorCode) + print('errorMessage:', resp.errorMessage) + + +def getEnginePath(): + return Path(os.path.realpath(__file__)).parents[4] + + +def getArch(): + os = platform.system().lower() + cpu_arch = platform.machine() + if cpu_arch == 'arm64': + return f'{os}-{cpu_arch}' + elif cpu_arch == 'x86_64': + return f'{os}-x64' + elif cpu_arch == 'AMD64': + return f'{os}-x64' + else: + log.error(f"Error: {os}-{cpu_arch} unsupported arch") + exit(1) + + +def runGitCommand(command): + result = subprocess.run(command, capture_output=True, text=True, shell=True) + if result.returncode != 0: + raise Exception(f"Git command failed: {result.stderr}") + return result.stdout.strip() + + +# 获取上传对象的进度 +def uploadCallback(transferredAmount, totalAmount, totalSeconds): + # 获取上传平均速率(KB/S) + speed = int(transferredAmount / totalSeconds / 1024) + # 获取上传进度百分比 + progress = int(transferredAmount * 100.0 / totalAmount) + print("\r", end="") + print("Speed: {} KB/S progress: {}%: ".format(speed, progress), "▓" * (progress // 2), end="") + sys.stdout.flush() + if progress == 100: + print("") diff --git a/attachment/scripts/zip_artifacts.py b/attachment/scripts/zip_artifacts.py new file mode 100644 index 0000000000000000000000000000000000000000..96f9e0ad0647fbe9d9e67ca84f245ee1ae8e797f --- /dev/null +++ b/attachment/scripts/zip_artifacts.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. + +import json +import os +import zipfile +import logging +from utils import getArch +from pathlib import PurePath +from pathlib import Path + +log = logging.getLogger(__name__) + +artifact_json = "artifacts_files.json" + + +def getFileMap(): + script_path = os.path.realpath(__file__) + script_dir = PurePath(script_path).parent + zip_artifact_json = script_dir.joinpath(artifact_json).__str__() + with open(zip_artifact_json, 'r') as jsonFile: + jsonData = json.load(jsonFile) + return jsonData + + +# BUILD.gn file does not exist in out/host_release/shader_lib. +# However, Google's flutter artifacts.zip contains it, so I add it manually here +# See. https://storage.flutter-io.cn/flutter_infra_release/flutter/edd8546116457bdf1c5bdfb13ecb9463d2bb5ed4/darwin-arm64/artifacts.zip + +shader_flutter_build = '''# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +copy("flutter") { + sources = [ "runtime_effect.glsl" ] + outputs = [ "$root_out_dir/shader_lib/flutter/{{source_file_part}}" ] +} +''' + +shader_impeller_build = '''# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +copy("impeller") { + sources = [ + "blending.glsl", + "branching.glsl", + "color.glsl", + "constants.glsl", + "conversions.glsl", + "dithering.glsl", + "external_texture_oes.glsl", + "gaussian.glsl", + "gradient.glsl", + "path.glsl", + "texture.glsl", + "tile_mode.glsl", + "transform.glsl", + "types.glsl", + ] + outputs = [ "$root_out_dir/shader_lib/impeller/{{source_file_part}}" ] +} +''' + +shader_gn_build = '''# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +group("shader_lib") { + deps = [ + "./flutter", + "./impeller", + ] +} +''' + + +def genZipFile(): + engine_project_root_dir = Path(os.path.realpath(__file__)).parents[4] + files_map = getFileMap()[getArch()] + with zipfile.ZipFile(engine_project_root_dir.joinpath('artifacts.zip'), 'w', + zipfile.ZIP_DEFLATED) as zipf: + for file_to_zip in files_map: + path = engine_project_root_dir.joinpath(file_to_zip) + if not path.exists(): + log.error(f"Error: file {path} does not exist") + exit(2) + else: + if path.is_file(): + log.info('Compressing:' + path.__str__()) + zipf.write(path, files_map[file_to_zip]) + elif Path(path).is_dir(): + dir_name_in_zip = files_map[file_to_zip] + for entry in path.rglob("*"): + log.info( + 'Compressing:' + Path(dir_name_in_zip).joinpath(entry.relative_to(path)).__str__() + ) + zipf.write(entry, Path(dir_name_in_zip).joinpath(entry.relative_to(path))) + zipf.writestr('shader_lib/flutter/BUILD.gn', shader_flutter_build) + zipf.writestr('shader_lib/impeller/BUILD.gn', shader_impeller_build) + zipf.writestr('shader_lib/BUILD.gn', shader_gn_build) + + +def main(): + genZipFile() + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/zip_dart_sdk.py b/attachment/scripts/zip_dart_sdk.py new file mode 100644 index 0000000000000000000000000000000000000000..3fb725c027f8e742716d0de6c71dffe61e0a60b9 --- /dev/null +++ b/attachment/scripts/zip_dart_sdk.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. + +import argparse +import os +import zipfile +import platform +import logging +from pathlib import Path + +log = logging.getLogger(__name__) + + +def genZipFile(): + parser = argparse.ArgumentParser() + parser.add_argument('--arch', type=str, choices=['x64', 'arm64'], default="x64") + args = parser.parse_args() + osArch = args.arch + osName = platform.system().lower() + suffix = "_arm64" if osArch == "arm64" else "" + engine_project_root_dir = Path(os.path.realpath(__file__)).parents[4] + dart_sdk_path = engine_project_root_dir.joinpath(f"src/out/host_release{suffix}/dart-sdk") + host_release_path = engine_project_root_dir.joinpath(f"src/out/host_release{suffix}/") + + print(dart_sdk_path) + with zipfile.ZipFile(engine_project_root_dir.joinpath(f'dart-sdk-{osName}-{osArch}.zip'), 'w', + zipfile.ZIP_DEFLATED) as zipf: + for entry in dart_sdk_path.rglob("*"): + if (entry.is_dir()): + continue + else: + print(entry.relative_to(host_release_path)) + zipf.write(entry, entry.relative_to(host_release_path)) + + +def main(): + genZipFile() + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/zip_flutter_patched_sdk.py b/attachment/scripts/zip_flutter_patched_sdk.py new file mode 100644 index 0000000000000000000000000000000000000000..ededfba045572ff48ff04641310a1b84e8fc4898 --- /dev/null +++ b/attachment/scripts/zip_flutter_patched_sdk.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. + +import os +import zipfile +import logging +from pathlib import Path + +log = logging.getLogger(__name__) + + +def genZipFile(is_product): + if is_product: + product_suffix = '_product' + sdk_rel_path = 'src/out/ohos_release_arm64/flutter_patched_sdk/' + zip_file_name = 'flutter_patched_sdk_product.zip' + else: + product_suffix = '' + sdk_rel_path = 'src/out/ohos_debug_unopt_arm64/flutter_patched_sdk/' + zip_file_name = 'flutter_patched_sdk.zip' + print(f'zipping {zip_file_name}...') + engine_project_root_path = Path(os.path.realpath(__file__)).parents[4] + patched_sdk_path = engine_project_root_path.joinpath(sdk_rel_path) + zip_file_prefix = Path('flutter_patched_sdk' + product_suffix) + with zipfile.ZipFile(engine_project_root_path.joinpath(zip_file_name), 'w', + zipfile.ZIP_DEFLATED) as zipf: + for entry in patched_sdk_path.rglob("*.dill"): + if (entry.is_dir()): + continue + else: + zip_path = zip_file_prefix.joinpath(entry.relative_to(patched_sdk_path)) + print(zip_path) + zipf.write(entry, zip_path) + + +def main(): + genZipFile(True) + genZipFile(False) + + +if __name__ == "__main__": + exit(main()) diff --git a/attachment/scripts/zip_sky_engine.py b/attachment/scripts/zip_sky_engine.py new file mode 100644 index 0000000000000000000000000000000000000000..8a8dad8c1c55bfc4d014f7adfeb9cdba3d23f205 --- /dev/null +++ b/attachment/scripts/zip_sky_engine.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# coding=utf-8 +# +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_HW file. + +import os +import zipfile +import logging +from pathlib import Path +from utils import getArch + +log = logging.getLogger(__name__) + + +def genZipFile(): + engine_project_root_dir = Path(os.path.realpath(__file__)).parents[4] + sky_engine_path = engine_project_root_dir.joinpath("src/out/host_release/gen/dart-pkg/sky_engine") + host_release_path = engine_project_root_dir.joinpath("src/out/host_release/gen/dart-pkg") + arch = getArch() + with zipfile.ZipFile(engine_project_root_dir.joinpath('sky_engine.zip'), 'w', + zipfile.ZIP_DEFLATED) as zipf: + for entry in sky_engine_path.rglob("*"): + if (entry.is_dir()): + continue + elif (entry.is_symlink()): + link = str(entry) + real = str(entry.readlink()) + print(f'found sym_link: {link} -> {real}') + zipf.write(real, entry.relative_to(host_release_path)) + else: + print(entry.relative_to(host_release_path)) + zipf.write(entry, entry.relative_to(host_release_path)) + + +def main(): + genZipFile() + + +if __name__ == "__main__": + exit(main()) diff --git a/fml/BUILD.gn b/fml/BUILD.gn index bc70dd0f79a47a5b4df373ce29a00f62158a833d..c4e3708b376d7125afb6837fd71442b8160db534 100644 --- a/fml/BUILD.gn +++ b/fml/BUILD.gn @@ -364,11 +364,16 @@ if (enable_unittests) { "time/time_delta_unittest.cc", "time/time_point_unittest.cc", "time/time_unittest.cc", - "platform/ohos/timerfd_unittests.cpp", - "platform/ohos/paths_ohos_unittests.cpp", - "platform/ohos/napi_util_unittests.cpp", ] + if (is_ohos) { + sources += [ + "platform/ohos/timerfd_unittests.cpp", + "platform/ohos/paths_ohos_unittests.cpp", + "platform/ohos/napi_util_unittests.cpp", + ] + } + if (is_mac) { sources += [ "platform/darwin/cf_utils_unittests.mm", diff --git a/fml/platform/ohos/message_loop_ohos.cc b/fml/platform/ohos/message_loop_ohos.cc index c918e9e66ccc861f3218867f7bc9b90fdd76148a..02566ddc814c674bfa66ff33a25543b2515b9ba5 100644 --- a/fml/platform/ohos/message_loop_ohos.cc +++ b/fml/platform/ohos/message_loop_ohos.cc @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/fml/platform/ohos/message_loop_ohos.h" diff --git a/fml/platform/ohos/message_loop_ohos.h b/fml/platform/ohos/message_loop_ohos.h index dcb826f62d8411d094cbaa73bd11ee1f6a589bd7..df2ea4a8ee863f7e0421be67430a6b9ba2e4c66c 100644 --- a/fml/platform/ohos/message_loop_ohos.h +++ b/fml/platform/ohos/message_loop_ohos.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef FLUTTER_FML_PLATFORM_OHOS_MESSAGE_LOOP_OHOS_H_ diff --git a/fml/platform/ohos/message_loop_ohos_test.cc b/fml/platform/ohos/message_loop_ohos_test.cc index 1aa1db255e040ed052207884bf55782ec751987a..c1f3ac572f09b5c2157b66b31822e2bf9f922719 100644 --- a/fml/platform/ohos/message_loop_ohos_test.cc +++ b/fml/platform/ohos/message_loop_ohos_test.cc @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/fml/message_loop.h" diff --git a/fml/platform/ohos/message_loop_ohos_test.h b/fml/platform/ohos/message_loop_ohos_test.h index f0e74721e39d4d9bc2b0dd634c175256363b1681..047963e890aa2f563842c79f3c08ca36ec0d47ed 100644 --- a/fml/platform/ohos/message_loop_ohos_test.h +++ b/fml/platform/ohos/message_loop_ohos_test.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef FLUTTER_FML_PLATFORM_OHOS_LOOP_TEST_H_ diff --git a/fml/platform/ohos/napi_util.cc b/fml/platform/ohos/napi_util.cc index 5d233ed337d240eeae88f07fec0371ff40b2262d..9bb10ea0485005bd325927f8dfa991ecfa14e3e4 100644 --- a/fml/platform/ohos/napi_util.cc +++ b/fml/platform/ohos/napi_util.cc @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #include "flutter/fml/platform/ohos/napi_util.h" diff --git a/fml/platform/ohos/napi_util.h b/fml/platform/ohos/napi_util.h index 2acb4c3302f95cef8ca35617f0aec7141823c285..4734e90ddf84b8760cbed09b53445305c3b97cbf 100644 --- a/fml/platform/ohos/napi_util.h +++ b/fml/platform/ohos/napi_util.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #ifndef OHOS_FLUTTER_NAPI_UTIL_H diff --git a/fml/platform/ohos/napi_util_unittests.cpp b/fml/platform/ohos/napi_util_unittests.cpp index a5e67eb19f777e1800dc2b32cacbc27256398165..b47d732d7a490113ac9e9c7bb111cdbc17835c34 100644 --- a/fml/platform/ohos/napi_util_unittests.cpp +++ b/fml/platform/ohos/napi_util_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include "flutter/fml/platform/ohos/napi_util.h" diff --git a/fml/platform/ohos/ohos_trace_event.cc b/fml/platform/ohos/ohos_trace_event.cc index 18f90a07e649dbf7b7b48197f3cc7e4df8f664a3..317c0455bda93e71c06769e8514af5b424405b1b 100644 --- a/fml/platform/ohos/ohos_trace_event.cc +++ b/fml/platform/ohos/ohos_trace_event.cc @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include "flutter/fml/trace_event.h" diff --git a/fml/platform/ohos/paths_ohos.cc b/fml/platform/ohos/paths_ohos.cc index 056bdd3770dc917d8aaf0025fc1b548eccd9d9a2..77b951d3166a947820e970b4be8c94c5fccf12aa 100644 --- a/fml/platform/ohos/paths_ohos.cc +++ b/fml/platform/ohos/paths_ohos.cc @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/fml/platform/ohos/paths_ohos.h" diff --git a/fml/platform/ohos/paths_ohos.h b/fml/platform/ohos/paths_ohos.h index 494d1516a128955d749d18317ee627b872d33f02..27970a27f975999a283e95aca70d8858bcb3cee0 100644 --- a/fml/platform/ohos/paths_ohos.h +++ b/fml/platform/ohos/paths_ohos.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef FLUTTER_FML_PLATFORM_OHOS_PATHS_OHOS_H_ diff --git a/fml/platform/ohos/paths_ohos_unittests.cpp b/fml/platform/ohos/paths_ohos_unittests.cpp index 2267050aad4fcb5ece960c3593c2a31457bedec8..e33325b55d1b3cf13ffec358d61711ffaf533f00 100644 --- a/fml/platform/ohos/paths_ohos_unittests.cpp +++ b/fml/platform/ohos/paths_ohos_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include "flutter/fml/platform/ohos/paths_ohos.h" diff --git a/fml/platform/ohos/timerfd.cc b/fml/platform/ohos/timerfd.cc index 4329da26b063d393d0888430d33109917bafb0a8..2604bac18833f05356d8b897459dbaf39bf331b5 100644 --- a/fml/platform/ohos/timerfd.cc +++ b/fml/platform/ohos/timerfd.cc @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/fml/platform/ohos/timerfd.h" diff --git a/fml/platform/ohos/timerfd.h b/fml/platform/ohos/timerfd.h index b2715d83f63faf46136f2abc506dcf046e5b8467..e899e8f9431a1b9f0cb81ba90d6456ede6e85050 100644 --- a/fml/platform/ohos/timerfd.h +++ b/fml/platform/ohos/timerfd.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef FLUTTER_FML_PLATFORM_OHOS_TIMER_FD_H_ diff --git a/fml/platform/ohos/timerfd_unittests.cpp b/fml/platform/ohos/timerfd_unittests.cpp index 6da8a3f2f74cda75708b49593684aa15bb501dba..f2e3ecbbcea2f46da69328aecba65325327e6b8f 100644 --- a/fml/platform/ohos/timerfd_unittests.cpp +++ b/fml/platform/ohos/timerfd_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include #include diff --git a/shell/common/animator.cc b/shell/common/animator.cc index a0704c7b8d26f09bd45098b246f4ae9255ade2c4..ece4c9834aa47ef0d10e0fa54c4f1965749d458d 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -19,6 +19,7 @@ namespace { // for further discussion on why this is necessary. constexpr fml::TimeDelta kNotifyIdleTaskWaitTime = fml::TimeDelta::FromMilliseconds(51); +constexpr uint32_t DVSYNC_BUFFER_COUNT = 2; } // namespace @@ -38,7 +39,7 @@ Animator::Animator(Delegate& delegate, task_runners.GetPlatformTaskRunner() == task_runners.GetRasterTaskRunner() ? 1 - : 2)), + : DVSYNC_BUFFER_COUNT)), #endif // SHELL_ENABLE_METAL pending_frame_semaphore_(1), weak_factory_(this) { diff --git a/shell/common/vsync_waiter.cc b/shell/common/vsync_waiter.cc index a23904f2d4f2713b8ed291f4ddd181d30470611b..1fc436ca3ce6481b21ed68d03fd96c0d7329f92e 100644 --- a/shell/common/vsync_waiter.cc +++ b/shell/common/vsync_waiter.cc @@ -87,8 +87,9 @@ void VsyncWaiter::ScheduleSecondaryCallback(uintptr_t id, void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time, fml::TimePoint frame_target_time, bool pause_secondary_tasks) { +#if !defined(FML_OS_OHOS) FML_DCHECK(fml::TimePoint::Now() >= frame_start_time); - +#endif Callback callback; std::vector secondary_callbacks; diff --git a/shell/common/vsync_waiter.h b/shell/common/vsync_waiter.h index cfce4524df4d7a59c90ff8a1fb3ce459b61ca9c9..1d4a193adb27f6bf81b8b8889dc9428cb52284fe 100644 --- a/shell/common/vsync_waiter.h +++ b/shell/common/vsync_waiter.h @@ -31,7 +31,9 @@ class VsyncWaiter : public std::enable_shared_from_this { /// See also |PointerDataDispatcher::ScheduleSecondaryVsyncCallback| and /// |Animator::ScheduleMaybeClearTraceFlowIds|. void ScheduleSecondaryCallback(uintptr_t id, const fml::closure& callback); - + // For DVsync control + virtual void DisableDVsync() {} + virtual void EnableDVsync() {} protected: // On some backends, the |FireCallback| needs to be made from a static C // method. diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 84548cee193d2a885072d0b358a0806dd746d674..e9f11044a738b427b881a87b3fa7562d1c6bcf8c 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -1,15 +1,6 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. assert(is_ohos) @@ -90,7 +81,9 @@ source_set("flutter_ohos_sources") { "./accessibility/ohos_accessibility_manager.h", "./accessibility/native_accessibility_channel.h", "./accessibility/ohos_accessibility_ddl.h", - "./utils/ddl_utils.h" + "./utils/ddl_utils.h", + "./utils/ohos_utils.h", + "./utils/arkui_accessibility_constant.h" ] #configs += [ "//flutter/shell/platform/ohos/config:gtk" ] @@ -126,7 +119,8 @@ source_set("flutter_ohos_sources") { "./accessibility/ohos_accessibility_features.cpp", "./accessibility/ohos_accessibility_manager.cpp", "./accessibility/native_accessibility_channel.cpp", - "./accessibility/ohos_accessibility_ddl.cpp" + "./accessibility/ohos_accessibility_ddl.cpp", + "./utils/ohos_utils.cpp" ] # Set flag to stop headers being directly included (library users should not do this) @@ -247,6 +241,7 @@ executable("flutter_ohos_unittests") { ldflags += ["-lnative_window"] ldflags += ["-lnative_vsync"] ldflags += ["-limage_ndk.z"] + ldflags += ["-ldeviceinfo_ndk.z"] ldflags += ["-lrawfile.z"] ldflags += ["-lnative_image"] ldflags += ["-lpixelmap_ndk.z"] diff --git a/shell/platform/ohos/accessibility/native_accessibility_channel.cpp b/shell/platform/ohos/accessibility/native_accessibility_channel.cpp index 1d3e8a7a3aa374ae7bbfcaea280754673fbfa46d..68f52cf1a3144e0fffcf88db85152a58eb5ca0e7 100644 --- a/shell/platform/ohos/accessibility/native_accessibility_channel.cpp +++ b/shell/platform/ohos/accessibility/native_accessibility_channel.cpp @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include "native_accessibility_channel.h" #include "flutter/shell/platform/ohos/ohos_shell_holder.h" @@ -73,7 +64,7 @@ namespace flutter { { auto ohos_shell_holder = reinterpret_cast(shellHolderId); - ohos_shell_holder->GetPlatformView()->PlatformView::DispatchSemanticsAction(id, action, fml::MallocMapping()); + ohos_shell_holder->GetPlatformView()->PlatformView::DispatchSemanticsAction(id, action, std::move(args)); } /** @@ -83,8 +74,7 @@ namespace flutter { flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) { - auto ohos_a11y_bridge = OhosAccessibilityBridge::GetInstance(); - ohos_a11y_bridge->updateSemantics(update, actions); + OhosAccessibilityBridge::GetInstance()->UpdateSemantics(update, actions); } /** @@ -102,7 +92,33 @@ namespace flutter { void NativeAccessibilityChannel::AccessibilityMessageHandler::Announce( std::unique_ptr& message) { - auto ohos_a11y_bridge = OhosAccessibilityBridge::GetInstance(); - ohos_a11y_bridge->Announce(message); + OhosAccessibilityBridge::GetInstance()->Announce(message); + } + + /** + * 利用通道内部类AccessibilityMessageHandler处理主动点击给定id组件事件 + */ + void NativeAccessibilityChannel::AccessibilityMessageHandler::OnTap( + int32_t nodeId) + { + OhosAccessibilityBridge::GetInstance()->OnTap(nodeId); + } + + /** + * 利用通道内部类AccessibilityMessageHandler处理主动长按给定id组件事件 + */ + void NativeAccessibilityChannel::AccessibilityMessageHandler::OnLongPress( + int32_t nodeId) + { + OhosAccessibilityBridge::GetInstance()->OnLongPress(nodeId); + } + + /** + * 利用通道内部类AccessibilityMessageHandler处理提示文字事件 + */ + void NativeAccessibilityChannel::AccessibilityMessageHandler::OnTooltip( + std::unique_ptr& message) + { + OhosAccessibilityBridge::GetInstance()->OnTooltip(message); } } \ No newline at end of file diff --git a/shell/platform/ohos/accessibility/native_accessibility_channel.h b/shell/platform/ohos/accessibility/native_accessibility_channel.h index 29d6e895c459d9ab18537c3e57330d0774021bd2..a82a8ab047a57e8ffb88356174d45b51805f2300 100644 --- a/shell/platform/ohos/accessibility/native_accessibility_channel.h +++ b/shell/platform/ohos/accessibility/native_accessibility_channel.h @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #ifndef OHOS_NATIVE_ACCESSIBILITY_CHANNEL_H #define OHOS_NATIVE_ACCESSIBILITY_CHANNEL_H diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_bridge.cpp b/shell/platform/ohos/accessibility/ohos_accessibility_bridge.cpp index 5bda8bfaea0e5a4f3de851e011763c650b5243fb..97aa8119b79c487fd9e3423ff28d0beae9e29c59 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_bridge.cpp +++ b/shell/platform/ohos/accessibility/ohos_accessibility_bridge.cpp @@ -1,74 +1,82 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include "ohos_accessibility_bridge.h" #include -#include -#include +#include #include #include "flutter/fml/logging.h" #include "flutter/shell/platform/ohos/ohos_logging.h" #include "flutter/shell/common/platform_view.h" #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/ohos/ohos_shell_holder.h" -#include "third_party/skia/include/core/SkMatrix.h" -#include "third_party/skia/include/core/SkScalar.h" - -#define OHOS_API_VERSION 13 -#define ARKUI_SUCCEED_CODE 0 -#define ARKUI_FAILED_CODE -1 -#define ARKUI_BAD_PARAM_CODE -2 -#define ARKUI_OOM_CODE -3 -#define ARKUI_ACCESSIBILITY_CALL_CHECK(X) \ - do { \ - int32_t RET = X; \ - if (RET != ARKUI_SUCCEED_CODE) { \ - LOGE("Failed arkui a11y function call, error code:%{public}d", RET); \ - } \ - } while (false) \ +#include "flutter/shell/platform/ohos/ohos_xcomponent_adapter.h" namespace flutter { -OhosAccessibilityBridge* OhosAccessibilityBridge::bridgeInstance = nullptr; +const int32_t OhosAccessibilityBridge::OHOS_API_VERSION = OH_GetSdkApiVersion(); -OhosAccessibilityBridge* OhosAccessibilityBridge::GetInstance() -{ - if(!bridgeInstance) { - bridgeInstance = new OhosAccessibilityBridge(); +std::unique_ptr OhosAccessibilityBridge::bridgeInstance_ = nullptr; + +/** + * flutter无障碍相关语义树、句柄指针provider等参数 + * 跟随xcomponentid显示切换,而加载对应xcomponent的语义树和provider指针 + * @NOTE: 当屏幕同时显示多个xcomponent时,无法通过聚焦事件而触发xcomponentid改变 + */ +void OhosAccessibilityBridge::AccessibiltiyChangesWithXComponentId() +{ + auto xcompMap = XComponentAdapter::GetInstance()->xcomponetMap_; + // 获取当前显示的xcomponetid + std::string currXcompId = XComponentAdapter::GetInstance()->currentXComponentId_; + if (xcomponentId_ == currXcompId) { return; } + + auto it = xcompMap.find(currXcompId); + if (!xcompMap.empty() && it != xcompMap.end()) { + // 更新xcompid,shellholderId,provider指针 + xcomponentId_ = currXcompId; + native_shell_holder_id_ = std::stoll(it->second->shellholderId_); + g_flutterSemanticsTree = g_flutterSemanticsTreeXComponents[xcomponentId_]; + g_parentChildIdVec = g_parentChildIdVecXComponents[xcomponentId_]; + FML_DLOG(INFO) << "AccessibiltiyChangesWithXComponentId -> xcomponentid:" << xcomponentId_; + } else { + xcomponentId_ = "oh_flutter_1"; + g_flutterSemanticsTree = g_flutterSemanticsTreeXComponents[xcomponentId_]; + g_parentChildIdVec = g_parentChildIdVecXComponents[xcomponentId_]; + FML_DLOG(INFO) << "AccessibiltiyChangesWithXComponentId -> xcomponentid:" << xcomponentId_; } - return bridgeInstance; } -void OhosAccessibilityBridge::DestroyInstance() { - delete bridgeInstance; - bridgeInstance = nullptr; +/** + * 采用局部静态变量配合call-once特性,实现线程安全的单例模式 + */ +OhosAccessibilityBridge* OhosAccessibilityBridge::GetInstance() +{ + static std::once_flag onceFlag; + std::call_once(onceFlag, []() { + bridgeInstance_.reset(new OhosAccessibilityBridge()); + }); + return bridgeInstance_.get(); } -OhosAccessibilityBridge::OhosAccessibilityBridge() {} +OhosAccessibilityBridge::OhosAccessibilityBridge() + : isFlutterNavigated_(false), + isAccessibilityEnabled_(false) {} /** * 监听当前ohos平台是否开启无障碍屏幕朗读服务 */ void OhosAccessibilityBridge::OnOhosAccessibilityStateChange( - int64_t shellHolderId, - bool ohosAccessibilityEnabled) + bool ohosAccessibilityEnabled, int64_t shellholderId) { - native_shell_holder_id_ = shellHolderId; + native_shell_holder_id_ = shellholderId; + AccessibiltiyChangesWithXComponentId(); nativeAccessibilityChannel_ = std::make_shared(); accessibilityFeatures_ = std::make_shared(); if (ohosAccessibilityEnabled) { + isAccessibilityEnabled_ = ohosAccessibilityEnabled; nativeAccessibilityChannel_->OnOhosAccessibilityEnabled(native_shell_holder_id_); } else { accessibilityFeatures_->SetAccessibleNavigation(false, native_shell_holder_id_); @@ -76,412 +84,334 @@ void OhosAccessibilityBridge::OnOhosAccessibilityStateChange( } } -void OhosAccessibilityBridge::SetNativeShellHolderId(int64_t id) +/** + * build the id mapping betwween parent node and its children nodes + */ +void OhosAccessibilityBridge::BuildParentChildNodeIdRelation( + const SemanticsNodeExtent& node) { - this->native_shell_holder_id_ = id; + if (!IsNodeVisible(node)) { return; } + for (const auto& childId : node.childrenInTraversalOrder) { + auto childNode = GetFlutterSemanticsNode(childId); + if (!IsNodeVisible(childNode)) { continue; } + g_parentChildIdVec.emplace_back(std::make_pair(node.id, childId)); + } } /** - * 从dart侧传递到c++侧的flutter无障碍语义树节点更新过程 + * 从dart侧传递到c++侧的flutter无障碍语义树节点更新过程, + * 路由新页面、滑动页面等操作会自动触发该语义树的更新 */ -void OhosAccessibilityBridge::updateSemantics( +void OhosAccessibilityBridge::UpdateSemantics( flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) { - FML_DLOG(INFO) << ("OhosAccessibilityBridge::UpdateSemantics()"); + FML_DLOG(INFO) << "OhosAccessibilityBridge::UpdateSemantics()"; + std::vector updatedFlutterNodes; - // 当flutter页面更新时,自动请求id=0节点组件获焦(滑动组件除外) - if (IS_FLUTTER_NAVIGATE) { - RequestFocusWhenPageUpdate(); - IS_FLUTTER_NAVIGATE = false; + // 当flutter页面状态更新(路由新页面)时,自动请求root节点组件获焦(规避滑动组件更新干扰) + if (isFlutterNavigated_) { + RequestFocusWhenPageUpdate(0); + isFlutterNavigated_ = false; } /** 获取并分析每个语义节点的更新属性 */ - for (auto& item : update) { - // 获取当前更新的节点node - const flutter::SemanticsNode& node = item.second; - - // set struct SemanticsNodeExtent - auto nodeEx = SetAndGetSemanticsNodeExtent(node); - - //print semantics node and flags info for debugging - GetSemanticsNodeDebugInfo(node); - GetSemanticsFlagsDebugInfo(node); - - /** - * 构建flutter无障碍语义节点树 - * NOTE: 若使用g_flutterSemanticsTree.insert({node.id, node})方式 - * 来添加新增的语义节点会导致已有key值自动忽略,不会更新原有key对应的value - */ - g_flutterSemanticsTree[node.id] = node; - - if(!IsNodeVisible(node)) { - continue; - } - - // 获取当前flutter节点的全部子节点数量,并构建父子节点id映射关系 - int32_t childNodeCount = node.childrenInTraversalOrder.size(); - for (int32_t i = 0; i < childNodeCount; i++) { - g_parentChildIdVec.emplace_back( - std::make_pair(node.id, node.childrenInTraversalOrder[i])); - FML_DLOG(INFO) << "UpdateSemantics parentChildIdMap -> (" << node.id - << ", " << node.childrenInTraversalOrder[i] << ")"; - } - - // 当滑动节点产生滑动,并执行滑动处理 - if (HasScrolled(node)) { - LOGD("UpdateSemantics -> has scrolled"); - if (OH_GetSdkApiVersion() >= 13) { - ArkUI_AccessibilityElementInfo* (*OH_ArkUI_CreateAccessibilityElementInfo)(void) = - OhosAccessibilityDDL::DLLoadCreateElemInfoFunc("OH_ArkUI_CreateAccessibilityElementInfo"); - if (OH_ArkUI_CreateAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_CreateAccessibilityElementInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityElementInfo* _elementInfo = OH_ArkUI_CreateAccessibilityElementInfo(); - - FlutterNodeToElementInfoById(_elementInfo, static_cast(node.id)); - FlutterScrollExecution(node, _elementInfo); - - void (*OH_ArkUI_DestoryAccessibilityElementInfo)(ArkUI_AccessibilityElementInfo*) = - OhosAccessibilityDDL::DLLoadDestroyElemFunc("OH_ArkUI_DestoryAccessibilityElementInfo"); - if (OH_ArkUI_DestoryAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_DestoryAccessibilityElementInfo is null, %{public}s", dlerror()); - } - OH_ArkUI_DestoryAccessibilityElementInfo(_elementInfo); - _elementInfo = nullptr; - } - } - // 判断是否触发liveRegion活动区,当前节点是否活跃 - if (node.HasFlag(FLAGS_::kIsLiveRegion)) { - FML_DLOG(INFO) << "UpdateSemantics -> LiveRegion, node.id=" << node.id; - FlutterPageUpdate(ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_CONTENT_UPDATE); - } - } - - // 遍历更新的actions,并将所有的actions的id添加进actionMap - for (const auto& item : actions) { - const flutter::CustomAccessibilityAction action = item.second; - GetCustomActionDebugInfo(action); - g_actions_mp[action.id] = action; - } - // 打印flutter语义树的不同节点的属性信息 - for (const auto& item : g_flutterSemanticsTree) { - FML_DLOG(INFO) << "g_flutterSemanticsTree -> {" << item.first << ", " - << item.second.id << "}"; - } - for (const auto& item : g_parentChildIdVec) { - FML_DLOG(INFO) << "g_parentChildIdVec -> (" << item.first << ", " - << item.second << ")"; - } - //打印按层次遍历排序的flutter语义树节点id数组 - std::vector levelOrderTraversalTree = GetLevelOrderTraversalTree(0); - for (const auto& item: levelOrderTraversalTree) { - FML_DLOG(INFO) << "LevelOrderTraversalTree: { " << item << " }"; - } - - FML_DLOG(INFO) << "=== UpdateSemantics is end ==="; + for (const auto& item : update) { + // 获取当前更新的节点node + const auto& node = item.second; + FML_DLOG(INFO) << "*#*#* node.id=" << node.id; + // 更新扩展的SemanticsNode信息 + auto nodeEx = UpdatetSemanticsNodeExtent(node); + + // 构建flutter无障碍语义节点树 + g_flutterSemanticsTree[nodeEx.id] = nodeEx; + // 构建flutter节点的父子id映射关系 + BuildParentChildNodeIdRelation(nodeEx); + + //print semantics node and flags info for debugging + GetSemanticsNodeDebugInfo(nodeEx); + GetSemanticsFlagsDebugInfo(nodeEx); + + if (!IsNodeVisible(nodeEx)) { continue; } + + // 若当前节点为获焦 + if (IsNodeFocused(nodeEx)) { + inputFocusedNode = nodeEx; + } + // 若当前节点和更新前节点信息不同,则加入更新节点数组 + if (nodeEx.hadPreviousConfig) { + updatedFlutterNodes.emplace_back(nodeEx); + FML_DLOG(INFO) << "updatedFlutterNodes -> node.id=" << nodeEx.id; + } + } + + // 将更新后的flutter语义树和父子节点id映射缓存,保存到相应的xcomponent里面 + g_flutterSemanticsTreeXComponents[xcomponentId_] = g_flutterSemanticsTree; + g_parentChildIdVecXComponents[xcomponentId_] = g_parentChildIdVec; + + // 页面内容更新事件 + Flutter_SendAccessibilityAsyncEvent(0, + ArkUI_AccessibilityEventType:: + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_CONTENT_UPDATE); + LOGD("Flutter_SendAccessibilityAsyncEvent -> PAGE_CONTENT_UPDATE"); + + /* 针对更新后的节点进行事件处理 */ + for (auto& nodeEx: updatedFlutterNodes) { + FML_DLOG(INFO) << "*#*#* updated node.id=" << nodeEx.id; + + // 当滑动节点产生滑动,并执行滑动处理 + if (HasScrolled(nodeEx)) { + LOGD("UpdateSemantics -> nodeId = %{public}d has scrolled", nodeEx.id); + auto OH_ArkUI_CreateAccessibilityElementInfo = + OhosAccessibilityDDL::DLLoadCreateElemInfoFunc(ArkUIAccessibilityConstant::ARKUI_CREATE_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_CreateAccessibilityElementInfo); + auto* _elementInfo = OH_ArkUI_CreateAccessibilityElementInfo(); + + FlutterSetElementInfoProperties(_elementInfo, static_cast(nodeEx.id)); + // flutter滑动组件滑动处理逻辑 + FlutterScrollExecution(nodeEx, _elementInfo); + + // 屏幕朗读状态下双指滑动,获焦节点绿框实时跟随节点滑动 + Flutter_SendAccessibilityAsyncEvent( + static_cast(accessibilityFocusedNode.id), + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_FOCUS_NODE_UPDATE); + + auto OH_ArkUI_DestoryAccessibilityElementInfo = + OhosAccessibilityDDL::DLLoadDestroyElemFunc(ArkUIAccessibilityConstant::ARKUI_DESTORY_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_DestoryAccessibilityElementInfo); + OH_ArkUI_DestoryAccessibilityElementInfo(_elementInfo); + _elementInfo = nullptr; + } + + // 判断是否触发liveRegion活动区,当前节点是否活跃 nodeEx.HasFlag(FLAGS_::kIsLiveRegion) + if (nodeEx.HasFlag(FLAGS_::kIsLiveRegion) && HasChangedLabel(nodeEx)) { + FML_DLOG(INFO) << "liveRegion -> page content update, nodeEx.id=" << nodeEx.id; + Flutter_SendAccessibilityAsyncEvent(static_cast(nodeEx.id), + ArkUI_AccessibilityEventType:: + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_CONTENT_UPDATE); + } + } + // calculate the global tranfomr matrix for each node + ComputeGlobalTransform(); + // 输出flutter语义树相关重要语义信息debug日志 + GetSemanticsDebugInfo(); + FML_DLOG(INFO) << "=== UpdateSemantics() is finished ==="; } /** * flutter可滑动组件的滑动逻辑处理实现 */ void OhosAccessibilityBridge::FlutterScrollExecution( - flutter::SemanticsNode node, + SemanticsNodeExtent node, ArkUI_AccessibilityElementInfo* elementInfoFromList) { - if (OH_GetSdkApiVersion() >= 13) { - double nodePosition = node.scrollPosition; - double nodeScrollExtentMax = node.scrollExtentMax; - double nodeScrollExtentMin = node.scrollExtentMin; - double infinity = std::numeric_limits::infinity(); - - // 设置flutter可滑动的最大范围值 - if (nodeScrollExtentMax == infinity) { - nodeScrollExtentMax = SCROLL_EXTENT_FOR_INFINITY; - if (nodePosition > SCROLL_POSITION_CAP_FOR_INFINITY) { - nodePosition = SCROLL_POSITION_CAP_FOR_INFINITY; - } - } - if (nodeScrollExtentMin == infinity) { - nodeScrollExtentMax += SCROLL_EXTENT_FOR_INFINITY; - if (nodePosition < -SCROLL_POSITION_CAP_FOR_INFINITY) { - nodePosition = -SCROLL_POSITION_CAP_FOR_INFINITY; - } - nodePosition += SCROLL_EXTENT_FOR_INFINITY; - } else { - nodeScrollExtentMax -= node.scrollExtentMin; - nodePosition -= node.scrollExtentMin; - } + if (OHOS_API_VERSION < 13) { return; } + double nodePosition = node.scrollPosition; + double nodeScrollExtentMax = node.scrollExtentMax; + double nodeScrollExtentMin = node.scrollExtentMin; + double infinity = std::numeric_limits::infinity(); - if (node.HasAction(ACTIONS_::kScrollUp) || - node.HasAction(ACTIONS_::kScrollDown)) { - } else if (node.HasAction(ACTIONS_::kScrollLeft) || - node.HasAction(ACTIONS_::kScrollRight)) { + // 设置flutter可滑动的最大范围值 + if (nodeScrollExtentMax == infinity) { + nodeScrollExtentMax = SCROLL_EXTENT_FOR_INFINITY; + if (nodePosition > SCROLL_POSITION_CAP_FOR_INFINITY) { + nodePosition = SCROLL_POSITION_CAP_FOR_INFINITY; } - - // 当可滑动组件存在滑动子节点 - if (node.scrollChildren > 0) { - // 配置当前滑动组件的子节点总数 - int32_t itemCount = node.scrollChildren; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetItemCount)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetItemCount"); - if (OH_ArkUI_AccessibilityElementInfoSetItemCount == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetItemCount is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetItemCount(elementInfoFromList, itemCount)); - - // 设置当前页面可见的起始滑动index - int32_t startItemIndex = node.scrollIndex; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetStartItemIndex)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetStartItemIndex"); - if (OH_ArkUI_AccessibilityElementInfoSetStartItemIndex == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetStartItemIndex is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetStartItemIndex(elementInfoFromList, startItemIndex)); - - // 计算当前滑动位置页面的可见子滑动节点数量 - int visibleChildren = 0; - // handle hidden children at the beginning and end of the list. - for (const auto& childId : node.childrenInHitTestOrder) { - auto childNode = GetFlutterSemanticsNode(childId); - if (!childNode.HasFlag(FLAGS_::kIsHidden)) { - visibleChildren += 1; - } - } - // 当可见滑动子节点数量超过滑动组件总子节点数量 - if (node.scrollIndex + visibleChildren > node.scrollChildren) { - FML_DLOG(WARNING) - << "FlutterScrollExecution -> Scroll index is out of bounds"; - } - // 当滑动击中子节点数量为0 - if (!node.childrenInHitTestOrder.size()) { - FML_DLOG(WARNING) << "FlutterScrollExecution -> Had scrollChildren but no " - "childrenInHitTestOrder"; - } - // 设置当前页面可见的末尾滑动index - int32_t endItemIndex = node.scrollIndex + visibleChildren - 1; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetEndItemIndex)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetEndItemIndex"); - if (OH_ArkUI_AccessibilityElementInfoSetEndItemIndex == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetEndItemIndex is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetEndItemIndex(elementInfoFromList, endItemIndex) - ); + } + if (nodeScrollExtentMin == infinity) { + nodeScrollExtentMax += SCROLL_EXTENT_FOR_INFINITY; + if (nodePosition < -SCROLL_POSITION_CAP_FOR_INFINITY) { + nodePosition = -SCROLL_POSITION_CAP_FOR_INFINITY; } + nodePosition += SCROLL_EXTENT_FOR_INFINITY; + } else { + nodeScrollExtentMax -= node.scrollExtentMin; + nodePosition -= node.scrollExtentMin; } -} -/** - * 当页面内容/状态更新事件,在页面转换、切换、调整大小时发送页面状态更新事件 - */ -void OhosAccessibilityBridge::FlutterPageUpdate( - ArkUI_AccessibilityEventType eventType) -{ - if (provider_ == nullptr) { - FML_DLOG(ERROR) << "PageStateUpdate ->" - "AccessibilityProvider = nullptr"; - return; + if (node.HasAction(ACTIONS_::kScrollUp) || + node.HasAction(ACTIONS_::kScrollDown)) { + } else if (node.HasAction(ACTIONS_::kScrollLeft) || + node.HasAction(ACTIONS_::kScrollRight)) { + LOGD("current flutterNode has scroll up/down/left/right"); } - if (OH_GetSdkApiVersion() >= 13) { - ArkUI_AccessibilityEventInfo* (*OH_ArkUI_CreateAccessibilityEventInfo)(void) = - OhosAccessibilityDDL::DLLoadCreateEventInfoFunc("OH_ArkUI_CreateAccessibilityEventInfo"); - if (OH_ArkUI_CreateAccessibilityEventInfo == nullptr) { - LOGE("OH_ArkUI_CreateAccessibilityEventInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityEventInfo* pageUpdateEventInfo = OH_ArkUI_CreateAccessibilityEventInfo(); - int32_t (*OH_ArkUI_AccessibilityEventSetEventType)(ArkUI_AccessibilityEventInfo*, ArkUI_AccessibilityEventType) = - OhosAccessibilityDDL::DLLoadSetEventFunc("OH_ArkUI_AccessibilityEventSetEventType"); - if (OH_ArkUI_AccessibilityEventSetEventType == nullptr) { - LOGE("OH_ArkUI_AccessibilityEventSetEventType is null, %{public}s", dlerror()); - } + // 当可滑动组件存在滑动子节点 + if (node.scrollChildren > 0) { + // 配置当前滑动组件的子节点总数 + int32_t itemCount = node.scrollChildren; + auto OH_ArkUI_AccessibilityElementInfoSetItemCount = + OhosAccessibilityDDL::DLLoadSetElemIntFunc(ArkUIAccessibilityConstant::ARKUI_SET_ITEM_COUNT); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetItemCount); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityEventSetEventType(pageUpdateEventInfo, eventType) - ); - - auto callback = [](int32_t errorCode) { - FML_DLOG(WARNING) << "PageStateUpdate callback-> errorCode =" << errorCode; - }; + OH_ArkUI_AccessibilityElementInfoSetItemCount(elementInfoFromList, itemCount)); - void (*OH_ArkUI_SendAccessibilityAsyncEvent)(ArkUI_AccessibilityProvider*, ArkUI_AccessibilityEventInfo*, void (*callback)(int32_t)) = - OhosAccessibilityDDL::DLLoadSendAsyncEventFunc("OH_ArkUI_SendAccessibilityAsyncEvent"); - if (OH_ArkUI_SendAccessibilityAsyncEvent == nullptr) { - LOGE("OH_ArkUI_SendAccessibilityAsyncEvent is null, %{public}s", dlerror()); - } - OH_ArkUI_SendAccessibilityAsyncEvent(provider_, pageUpdateEventInfo, callback); + // 设置当前页面可见的起始滑动index + int32_t startItemIndex = node.scrollIndex; + auto OH_ArkUI_AccessibilityElementInfoSetStartItemIndex = + OhosAccessibilityDDL::DLLoadSetElemIntFunc(ArkUIAccessibilityConstant::ARKUI_SET_START_ITEM_IDX); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetStartItemIndex); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetStartItemIndex(elementInfoFromList, startItemIndex)); - void (*OH_ArkUI_DestoryAccessibilityEventInfo)(ArkUI_AccessibilityEventInfo*) = - OhosAccessibilityDDL::DLLoadDestroyEventFunc("OH_ArkUI_DestoryAccessibilityEventInfo"); - if (OH_ArkUI_DestoryAccessibilityEventInfo == nullptr) { - LOGE("OH_ArkUI_DestoryAccessibilityEventInfo is null, %{public}s", dlerror()); + // 设置当前获焦节点的当前index + int32_t currItemIndex = accessibilityFocusedNode.id; + auto OH_ArkUI_AccessibilityElementInfoSetCurrentItemIndex = + OhosAccessibilityDDL::DLLoadSetElemIntFunc(ArkUIAccessibilityConstant::ARKUI_SET_CURR_ITEM_IDX); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetCurrentItemIndex); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetCurrentItemIndex(elementInfoFromList, currItemIndex)); + + // 计算当前滑动位置页面的可见子滑动节点数量 + int visibleChildren = 0; + // handle hidden children at the beginning and end of the list. + for (const auto& childId : node.childrenInHitTestOrder) { + auto childNode = GetFlutterSemanticsNode(childId); + if (!childNode.HasFlag(FLAGS_::kIsHidden)) { + visibleChildren += 1; + } } - OH_ArkUI_DestoryAccessibilityEventInfo(pageUpdateEventInfo); - pageUpdateEventInfo = nullptr; + // 当可见滑动子节点数量超过滑动组件总子节点数量 + if (node.scrollIndex + visibleChildren > node.scrollChildren) { + FML_DLOG(WARNING) + << "FlutterScrollExecution -> Scroll index is out of bounds"; + } + // 当滑动击中子节点数量为0 + if (!node.childrenInHitTestOrder.size()) { + FML_DLOG(WARNING) << "FlutterScrollExecution -> Had scrollChildren but no " + "childrenInHitTestOrder"; + } + // 设置当前页面可见的末尾滑动index + int32_t endItemIndex = node.scrollIndex + visibleChildren - 1; + auto OH_ArkUI_AccessibilityElementInfoSetEndItemIndex = + OhosAccessibilityDDL::DLLoadSetElemIntFunc(ArkUIAccessibilityConstant::ARKUI_SET_END_ITEM_IDX); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetEndItemIndex); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetEndItemIndex(elementInfoFromList, endItemIndex)); } } /** * 特定节点的焦点请求 (当页面更新时自动请求id=0节点获焦) */ -void OhosAccessibilityBridge::RequestFocusWhenPageUpdate() -{ - if (provider_ == nullptr) { - FML_DLOG(ERROR) << "RequestFocusWhenPageUpdate ->" - "AccessibilityProvider = nullptr"; - return; - } - if (OH_GetSdkApiVersion() >= 13) { - ArkUI_AccessibilityEventInfo* (*OH_ArkUI_CreateAccessibilityEventInfo)(void) = - OhosAccessibilityDDL::DLLoadCreateEventInfoFunc("OH_ArkUI_CreateAccessibilityEventInfo"); - if (OH_ArkUI_CreateAccessibilityEventInfo == nullptr) { - LOGE("OH_ArkUI_CreateAccessibilityEventInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityEventInfo* reqFocusEventInfo = OH_ArkUI_CreateAccessibilityEventInfo(); - - ArkUI_AccessibilityElementInfo* (*OH_ArkUI_CreateAccessibilityElementInfo)(void) = - OhosAccessibilityDDL::DLLoadCreateElemInfoFunc("OH_ArkUI_CreateAccessibilityElementInfo"); - if (OH_ArkUI_CreateAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_CreateAccessibilityElementInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityElementInfo* elementInfo = OH_ArkUI_CreateAccessibilityElementInfo(); - - int32_t (*OH_ArkUI_AccessibilityEventSetEventType)(ArkUI_AccessibilityEventInfo*, ArkUI_AccessibilityEventType) = - OhosAccessibilityDDL::DLLoadSetEventFunc("OH_ArkUI_AccessibilityEventSetEventType"); - if (OH_ArkUI_AccessibilityEventSetEventType == nullptr) { - LOGE("OH_ArkUI_AccessibilityEventSetEventType is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityEventSetEventType( - reqFocusEventInfo, - ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_REQUEST_ACCESSIBILITY_FOCUS) - ); - - int32_t requestFocusId = 0; - int32_t (*OH_ArkUI_AccessibilityEventSetRequestFocusId)(ArkUI_AccessibilityEventInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetReqFocusFunc("OH_ArkUI_AccessibilityEventSetRequestFocusId"); - if (OH_ArkUI_AccessibilityEventSetRequestFocusId == nullptr) { - LOGE("OH_ArkUI_AccessibilityEventSetRequestFocusId is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityEventSetRequestFocusId(reqFocusEventInfo, - requestFocusId) - ); - - int32_t (*OH_ArkUI_AccessibilityEventSetElementInfo)(ArkUI_AccessibilityEventInfo*, ArkUI_AccessibilityElementInfo*) = - OhosAccessibilityDDL::DLLoadSetEventElemFunc("OH_ArkUI_AccessibilityEventSetElementInfo"); - if (OH_ArkUI_AccessibilityEventSetElementInfo == nullptr) { - LOGE("OH_ArkUI_AccessibilityEventSetElementInfo is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityEventSetElementInfo(reqFocusEventInfo, elementInfo) - ); - - auto callback = [](int32_t errorCode) { - FML_DLOG(WARNING) << "PageStateUpdate callback-> errorCode =" << errorCode; - }; - - void (*OH_ArkUI_SendAccessibilityAsyncEvent)(ArkUI_AccessibilityProvider*, ArkUI_AccessibilityEventInfo*, void (*callback)(int32_t)) = - OhosAccessibilityDDL::DLLoadSendAsyncEventFunc("OH_ArkUI_SendAccessibilityAsyncEvent"); - if (OH_ArkUI_SendAccessibilityAsyncEvent == nullptr) { - LOGE("OH_ArkUI_SendAccessibilityAsyncEvent is null, %{public}s", dlerror()); - } - OH_ArkUI_SendAccessibilityAsyncEvent(provider_, reqFocusEventInfo, callback); - - void (*OH_ArkUI_DestoryAccessibilityEventInfo)(ArkUI_AccessibilityEventInfo*) = - OhosAccessibilityDDL::DLLoadDestroyEventFunc("OH_ArkUI_DestoryAccessibilityEventInfo"); - if (OH_ArkUI_DestoryAccessibilityEventInfo == nullptr) { - LOGE("OH_ArkUI_DestoryAccessibilityEventInfo is null, %{public}s", dlerror()); - } - OH_ArkUI_DestoryAccessibilityEventInfo(reqFocusEventInfo); - reqFocusEventInfo = nullptr; - - void (*OH_ArkUI_DestoryAccessibilityElementInfo)(ArkUI_AccessibilityElementInfo*) = - OhosAccessibilityDDL::DLLoadDestroyElemFunc("OH_ArkUI_DestoryAccessibilityElementInfo"); - if (OH_ArkUI_DestoryAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_DestoryAccessibilityElementInfo is null, %{public}s", dlerror()); - } - OH_ArkUI_DestoryAccessibilityElementInfo(elementInfo); - elementInfo = nullptr; - } +void OhosAccessibilityBridge::RequestFocusWhenPageUpdate(int32_t requestFocusId) +{ + if (OHOS_API_VERSION < 13) { return; } + std::lock_guard lock(XComponentAdapter::GetInstance()->mutex_); + auto provider_ = XComponentAdapter::GetInstance()->GetAccessibilityProvider(xcomponentId_); + CHECK_NULL_PTR_RET_VOID(provider_, RequestFocusWhenPageUpdate); + + auto OH_ArkUI_CreateAccessibilityEventInfo = + OhosAccessibilityDDL::DLLoadCreateEventInfoFunc(ArkUIAccessibilityConstant::ARKUI_CREATE_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_CreateAccessibilityEventInfo); + auto* reqFocusEventInfo = OH_ArkUI_CreateAccessibilityEventInfo(); + + auto OH_ArkUI_CreateAccessibilityElementInfo = + OhosAccessibilityDDL::DLLoadCreateElemInfoFunc(ArkUIAccessibilityConstant::ARKUI_CREATE_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_CreateAccessibilityElementInfo); + auto* elementInfo = OH_ArkUI_CreateAccessibilityElementInfo(); + + auto OH_ArkUI_AccessibilityEventSetEventType = + OhosAccessibilityDDL::DLLoadSetEventFunc(ArkUIAccessibilityConstant::ARKUI_SET_EVENT_TYPE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityEventSetEventType); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityEventSetEventType( + reqFocusEventInfo, + ArkUI_AccessibilityEventType:: + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_REQUEST_ACCESSIBILITY_FOCUS) + ); + + auto OH_ArkUI_AccessibilityEventSetRequestFocusId = + OhosAccessibilityDDL::DLLoadSetReqFocusFunc(ArkUIAccessibilityConstant::ARKUI_SET_REQ_FOCUSED_ID); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityEventSetRequestFocusId); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityEventSetRequestFocusId(reqFocusEventInfo, requestFocusId) + ); + + auto OH_ArkUI_AccessibilityEventSetElementInfo = + OhosAccessibilityDDL::DLLoadSetEventElemFunc(ArkUIAccessibilityConstant::ARKUI_EVENT_SET_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityEventSetElementInfo); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityEventSetElementInfo(reqFocusEventInfo, elementInfo) + ); + + auto callback = [](int32_t errorCode) { + FML_DLOG(WARNING) << "PageStateUpdate callback-> errorCode =" << errorCode; + }; + + auto OH_ArkUI_SendAccessibilityAsyncEvent = + OhosAccessibilityDDL::DLLoadSendAsyncEventFunc(ArkUIAccessibilityConstant::ARKUI_SEND_A11Y_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_SendAccessibilityAsyncEvent); + OH_ArkUI_SendAccessibilityAsyncEvent(provider_, reqFocusEventInfo, callback); + + auto OH_ArkUI_DestoryAccessibilityEventInfo = + OhosAccessibilityDDL::DLLoadDestroyEventFunc(ArkUIAccessibilityConstant::ARKUI_DESTORY_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_DestoryAccessibilityEventInfo); + OH_ArkUI_DestoryAccessibilityEventInfo(reqFocusEventInfo); + reqFocusEventInfo = nullptr; + + auto OH_ArkUI_DestoryAccessibilityElementInfo = + OhosAccessibilityDDL::DLLoadDestroyElemFunc(ArkUIAccessibilityConstant::ARKUI_DESTORY_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_DestoryAccessibilityElementInfo); + OH_ArkUI_DestoryAccessibilityElementInfo(elementInfo); + elementInfo = nullptr; } /** - * 主动播报特定文本 + * 业务侧通过无障碍通道主动播报自定义文本内容 */ void OhosAccessibilityBridge::Announce(std::unique_ptr& message) { - if (provider_ == nullptr) { - FML_DLOG(ERROR) << "announce ->" - "AccessibilityProvider = nullptr"; - return; - } - if (OH_GetSdkApiVersion() >= 13) { - // 创建并设置屏幕朗读事件 - ArkUI_AccessibilityEventInfo* (*OH_ArkUI_CreateAccessibilityEventInfo)(void) = - OhosAccessibilityDDL::DLLoadCreateEventInfoFunc("OH_ArkUI_CreateAccessibilityEventInfo"); - if (OH_ArkUI_CreateAccessibilityEventInfo == nullptr) { - LOGE("OH_ArkUI_CreateAccessibilityEventInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityEventInfo* announceEventInfo = OH_ArkUI_CreateAccessibilityEventInfo(); - - - int32_t (*OH_ArkUI_AccessibilityEventSetEventType)(ArkUI_AccessibilityEventInfo*, ArkUI_AccessibilityEventType) = - OhosAccessibilityDDL::DLLoadSetEventFunc("OH_ArkUI_AccessibilityEventSetEventType"); - if (OH_ArkUI_AccessibilityEventSetEventType == nullptr) { - LOGE("OH_ArkUI_AccessibilityEventSetEventType is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityEventSetEventType( - announceEventInfo, - ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ANNOUNCE_FOR_ACCESSIBILITY) - ); - - int32_t (*OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility)(ArkUI_AccessibilityEventInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetEventStringFunc("OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility"); - if (OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility == nullptr) { - LOGE("OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility( - announceEventInfo, message.get()) - ); - FML_DLOG(INFO) << ("announce -> message: ") << (message.get()); + if (!isAccessibilityEnabled_) { return; } + Flutter_SendAccessibilityAnnounceEvent( + message, ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ANNOUNCE_FOR_ACCESSIBILITY); + LOGD("Announce -> message: %{public}s", message.get()); +} - auto callback = [](int32_t errorCode) { - FML_DLOG(WARNING) << "announce callback-> errorCode =" << errorCode; - }; +/** + * 业务侧通过无障碍通道主动点击给定id的组件节点 + */ +void OhosAccessibilityBridge::OnTap(int32_t nodeId) +{ + if (!isAccessibilityEnabled_) { return; } + Flutter_SendAccessibilityAsyncEvent(static_cast(nodeId), + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_CLICKED); + LOGD("OnTap -> nodeId: %{public}d", nodeId); +} - void (*OH_ArkUI_SendAccessibilityAsyncEvent)(ArkUI_AccessibilityProvider*, ArkUI_AccessibilityEventInfo*, void (*callback)(int32_t)) = - OhosAccessibilityDDL::DLLoadSendAsyncEventFunc("OH_ArkUI_SendAccessibilityAsyncEvent"); - if (OH_ArkUI_SendAccessibilityAsyncEvent == nullptr) { - LOGE("OH_ArkUI_SendAccessibilityAsyncEvent is null, %{public}s", dlerror()); - } - OH_ArkUI_SendAccessibilityAsyncEvent(provider_, announceEventInfo, callback); +/** + * 业务侧通过无障碍通道主动长按给定id的组件节点 + */ +void OhosAccessibilityBridge::OnLongPress(int32_t nodeId) +{ + if (!isAccessibilityEnabled_) { return; } + Flutter_SendAccessibilityAsyncEvent(static_cast(nodeId), + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_LONG_CLICKED); + LOGD("OnLongPress -> nodeId: %{public}d", nodeId); +} - void (*OH_ArkUI_DestoryAccessibilityEventInfo)(ArkUI_AccessibilityEventInfo*) = - OhosAccessibilityDDL::DLLoadDestroyEventFunc("OH_ArkUI_DestoryAccessibilityEventInfo"); - if (OH_ArkUI_DestoryAccessibilityEventInfo == nullptr) { - LOGE("OH_ArkUI_DestoryAccessibilityEventInfo is null, %{public}s", dlerror()); - } - OH_ArkUI_DestoryAccessibilityEventInfo(announceEventInfo); - announceEventInfo = nullptr; - } +/** + * 业务侧通过无障碍通道主动长按给定id的组件节点 + */ +void OhosAccessibilityBridge::OnTooltip(std::unique_ptr& message) +{ + if (!isAccessibilityEnabled_) { return; } + Flutter_SendAccessibilityAsyncEvent(static_cast(ROOT_NODE_ID), + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_STATE_UPDATE); + Flutter_SendAccessibilityAnnounceEvent( + message, ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ANNOUNCE_FOR_ACCESSIBILITY); + LOGD("OnTooltip -> message: %{public}s", message.get()); } //获取根节点 -flutter::SemanticsNode OhosAccessibilityBridge::GetFlutterRootSemanticsNode() +SemanticsNodeExtent OhosAccessibilityBridge::GetFlutterRootSemanticsNode() { if (!g_flutterSemanticsTree.size()) { - FML_DLOG(ERROR) - << "GetFlutterRootSemanticsNode -> g_flutterSemanticsTree.size()=0"; + LOGE("GetFlutterRootSemanticsNode: g_flutterSemanticsTree.size()=0"); return {}; } if (g_flutterSemanticsTree.find(0) == g_flutterSemanticsTree.end()) { - FML_DLOG(ERROR) << "GetFlutterRootSemanticsNode -> g_flutterSemanticsTree " - "has no keys = 0"; + LOGE("GetFlutterRootSemanticsNod: g_flutterSemanticsTree has no root id"); return {}; } return g_flutterSemanticsTree.at(0); @@ -490,206 +420,27 @@ flutter::SemanticsNode OhosAccessibilityBridge::GetFlutterRootSemanticsNode() /** * 根据nodeid获取或创建flutter语义节点 */ -flutter::SemanticsNode OhosAccessibilityBridge::GetFlutterSemanticsNode( +SemanticsNodeExtent OhosAccessibilityBridge::GetFlutterSemanticsNode( int32_t id) { - flutter::SemanticsNode node; if (g_flutterSemanticsTree.count(id) > 0) { return g_flutterSemanticsTree.at(id); - FML_DLOG(INFO) << "GetFlutterSemanticsNode get node.id=" << id; } else { - FML_DLOG(ERROR) << "GetFlutterSemanticsNode g_flutterSemanticsTree = null" << id; + LOGE("GetFlutterSemanticsNode g_flutterSemanticsTree = null"); return {}; } } -/** - * flutter的语义节点初始化配置给arkui创建的elementInfos - */ -void OhosAccessibilityBridge::FlutterTreeToArkuiTree( - ArkUI_AccessibilityElementInfoList* elementInfoList) -{ - if (g_flutterSemanticsTree.size() == 0) { - FML_DLOG(ERROR) << "OhosAccessibilityBridge::FlutterTreeToArkuiTree " - "g_flutterSemanticsTree.size() = 0"; - return; - } - if (OH_GetSdkApiVersion() >= 13) { - // 将flutter语义节点树传递给arkui的无障碍elementinfo - for (const auto& item : g_flutterSemanticsTree) { - flutter::SemanticsNode flutterNode = item.second; - - // 创建elementinfo,系统自动加入到elementinfolist - ArkUI_AccessibilityElementInfo* (*OH_ArkUI_AddAndGetAccessibilityElementInfo)(ArkUI_AccessibilityElementInfoList*) = - OhosAccessibilityDDL::DLLoadGetElemFunc("OH_ArkUI_AddAndGetAccessibilityElementInfo"); - if (OH_ArkUI_AddAndGetAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_AddAndGetAccessibilityElementInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityElementInfo* elementInfo = - OH_ArkUI_AddAndGetAccessibilityElementInfo(elementInfoList); - if (elementInfo == nullptr) { - FML_DLOG(INFO) << "OhosAccessibilityBridge::FlutterTreeToArkuiTree " - "elementInfo is null"; - return; - } - // 设置elementinfo的屏幕坐标范围 - int32_t left = static_cast(flutterNode.rect.fLeft); - int32_t top = static_cast(flutterNode.rect.fTop); - int32_t right = static_cast(flutterNode.rect.fRight); - int32_t bottom = static_cast(flutterNode.rect.fBottom); - ArkUI_AccessibleRect rect = {left, top, right, bottom}; - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetScreenRect)(ArkUI_AccessibilityElementInfo*, ArkUI_AccessibleRect*) = - OhosAccessibilityDDL::DLLoadSetElemSreenRectFunc("OH_ArkUI_AccessibilityElementInfoSetScreenRect"); - if (OH_ArkUI_AccessibilityElementInfoSetScreenRect == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetScreenRect is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetScreenRect(elementInfo, &rect) - ); - - // 设置elementinfo的action类型 - std::string widget_type = GetNodeComponentType(flutterNode); - FlutterSetElementInfoOperationActions(elementInfo, widget_type); - - // 设置elementid - int32_t (*OH_ArkUI_AccessibilityElementInfoSetElementId)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetElementId"); - if (OH_ArkUI_AccessibilityElementInfoSetElementId == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetElementId is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetElementId(elementInfo, flutterNode.id) - ); - - // 设置父节点id - int32_t parentId = GetParentId(flutterNode.id); - int32_t (*OH_ArkUI_AccessibilityElementInfoSetParentId)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetParentId"); - if (OH_ArkUI_AccessibilityElementInfoSetParentId == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetParentId is null, %{public}s", dlerror()); - } - if (flutterNode.id == 0) { - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetParentId(elementInfo, ARKUI_ACCESSIBILITY_ROOT_PARENT_ID) - ); - } else { - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetParentId(elementInfo, parentId)); - } - - // 设置孩子节点 - int32_t childCount = flutterNode.childrenInTraversalOrder.size(); - auto childrenIdsVec = flutterNode.childrenInTraversalOrder; - std::sort(childrenIdsVec.begin(), childrenIdsVec.end()); - int64_t childNodeIds[childCount]; - for (int32_t i = 0; i < childCount; i++) { - childNodeIds[i] = static_cast(childrenIdsVec[i]); - FML_DLOG(INFO) << "FlutterTreeToArkuiTree flutterNode.id= " - << flutterNode.id << " childCount= " << childCount - << " childNodeId=" << childNodeIds[i]; - } - int32_t (*OH_ArkUI_AccessibilityElementInfoSetChildNodeIds)(ArkUI_AccessibilityElementInfo*, int32_t, int64_t*) = - OhosAccessibilityDDL::DLLoadSetElemChildFunc("OH_ArkUI_AccessibilityElementInfoSetChildNodeIds"); - if (OH_ArkUI_AccessibilityElementInfoSetChildNodeIds == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetChildNodeIds is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetChildNodeIds(elementInfo, childCount, childNodeIds) - ); - - // 配置常用属性 - int32_t (*OH_ArkUI_AccessibilityElementInfoSetEnabled)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetEnabled"); - if (OH_ArkUI_AccessibilityElementInfoSetEnabled == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetEnabled is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetEnabled(elementInfo, true)); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetClickable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetClickable"); - if (OH_ArkUI_AccessibilityElementInfoSetClickable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetClickable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetClickable(elementInfo, true)); - int32_t (*OH_ArkUI_AccessibilityElementInfoSetCheckable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetCheckable"); - if (OH_ArkUI_AccessibilityElementInfoSetCheckable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetCheckable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetCheckable(elementInfo, true)); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetFocusable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetFocusable"); - if (OH_ArkUI_AccessibilityElementInfoSetFocusable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetFocusable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetFocusable(elementInfo, true)); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetVisible)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetVisible"); - if (OH_ArkUI_AccessibilityElementInfoSetVisible == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetVisible is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetVisible(elementInfo, true)); - - // 设置组件类型 - std::string componentTypeName = GetNodeComponentType(flutterNode); - int32_t (*OH_ArkUI_AccessibilityElementInfoSetComponentType)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetComponentType"); - if (OH_ArkUI_AccessibilityElementInfoSetComponentType == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetComponentType is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetComponentType(elementInfo, componentTypeName.c_str()) - ); - - std::string contents = componentTypeName + "_content"; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetContents)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetContents"); - if (OH_ArkUI_AccessibilityElementInfoSetContents == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetContents is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetContents(elementInfo, contents.c_str()) - ); - - // 设置无障碍相关属性 - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityText)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityText"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityText == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityText is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetAccessibilityText(elementInfo, flutterNode.label.c_str()) - ); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel(elementInfo, "yes")); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup(elementInfo, false)); - } - } -} - /** * 获取当前elementid的父节点id */ int32_t OhosAccessibilityBridge::GetParentId(int64_t elementId) { if (!g_parentChildIdVec.size()) { - FML_DLOG(INFO) << "OhosAccessibilityBridge::GetParentId parentChildIdMap.size()=0"; + FML_DLOG(WARNING) << "OhosAccessibilityBridge::GetParentId parentChildIdMap.size()=0"; return ARKUI_ACCESSIBILITY_ROOT_PARENT_ID; } - if (elementId == -1) { + if (elementId == -1 || elementId == 0) { return ARKUI_ACCESSIBILITY_ROOT_PARENT_ID; } int32_t childElementId = static_cast(elementId); @@ -704,292 +455,101 @@ int32_t OhosAccessibilityBridge::GetParentId(int64_t elementId) /** * 设置并获取xcomponet上渲染的组件的屏幕绝对坐标rect */ -void OhosAccessibilityBridge::SetAbsoluteScreenRect(int32_t flutterNodeId, +void OhosAccessibilityBridge::SetAbsoluteScreenRect(SemanticsNodeExtent& flutterNode, float left, float top, float right, float bottom) { - g_screenRectMap[flutterNodeId] = - std::make_pair(std::make_pair(left, top), std::make_pair(right, bottom)); - FML_DLOG(INFO) << "SetAbsoluteScreenRect -> insert { " << flutterNodeId - << ", <" << left << ", " << top << ", " << right << ", " - << bottom << "> } is succeed"; + g_screenRectMap[flutterNode.id] = AbsoluteRect{left, top, right, bottom}; + FML_DLOG(INFO) << "SetAbsoluteScreenRect -> id=" << flutterNode.id + << ", {" << left << ", " << top << ", " << right << ", "<< bottom << "> }"; } -std::pair, std::pair> -OhosAccessibilityBridge::GetAbsoluteScreenRect(int32_t flutterNodeId) +AbsoluteRect OhosAccessibilityBridge::GetAbsoluteScreenRect(SemanticsNodeExtent& flutterNode) { - if (!g_screenRectMap.empty() && g_screenRectMap.count(flutterNodeId) > 0) { - return g_screenRectMap.at(flutterNodeId); + if (!g_screenRectMap.empty() && g_screenRectMap.count(flutterNode.id) > 0) { + return g_screenRectMap.at(flutterNode.id); } else { FML_DLOG(ERROR) << "GetAbsoluteScreenRect -> flutterNodeId=" - << flutterNodeId << " is not found !"; + << flutterNode.id << " is not found !"; return {}; } } /** - * flutter无障碍语义树的子节点相对坐标系转化为屏幕绝对坐标的映射算法 - * 目前暂未考虑旋转、透视场景,不影响屏幕朗读功能 + * 获取flutter相对-绝对坐标映射的真实缩放系数 */ -void OhosAccessibilityBridge::ConvertChildRelativeRectToScreenRect( - flutter::SemanticsNode currNode) -{ - // 获取当前flutter节点的相对rect - auto currLeft = static_cast(currNode.rect.fLeft); - auto currTop = static_cast(currNode.rect.fTop); - auto currRight = static_cast(currNode.rect.fRight); - auto currBottom = static_cast(currNode.rect.fBottom); - - // 获取当前flutter节点的缩放、平移、透视等矩阵坐标转换 - SkMatrix transform = currNode.transform.asM33(); - auto _kMScaleX = transform.get(SkMatrix::kMScaleX); - auto _kMTransX = transform.get(SkMatrix::kMTransX); - auto _kMScaleY = transform.get(SkMatrix::kMScaleY); - auto _kMTransY = transform.get(SkMatrix::kMTransY); - /** 以下矩阵坐标变换参数(如:旋转/错切、透视)场景目前暂不考虑 - * NOTE: SkMatrix::kMSkewX, SkMatrix::kMSkewY, - * SkMatrix::kMPersp0, SkMatrix::kMPersp1, SkMatrix::kMPersp2 - */ - - // 获取当前flutter节点的父节点的相对rect - int32_t parentId = GetParentId(currNode.id); - auto parentNode = GetFlutterSemanticsNode(parentId); - auto parentRight = parentNode.rect.fRight; - auto parentBottom = parentNode.rect.fBottom; - - // 获取当前flutter节点的父节点的绝对坐标 - auto _rectPairs = GetAbsoluteScreenRect(parentNode.id); - auto realParentLeft = _rectPairs.first.first; - auto realParentTop = _rectPairs.first.second; - auto realParentRight = _rectPairs.second.first; - auto realParentBottom = _rectPairs.second.second; - - // 获取root节点的绝对坐标, 即xcomponent屏幕长宽 - auto _rootRect = GetAbsoluteScreenRect(0); - auto rootHeight = _rootRect.second.second; - - // 真实缩放系数 - float realScaleFactor = realParentRight / parentRight * 1.0; - float newLeft; - float newTop; - float newRight; - float newBottom; - - if (_kMScaleX > 1 && _kMScaleY > 1) { - // 子节点相对父节点进行变化(缩放、 平移) - newLeft = currLeft + _kMTransX * _kMScaleX; - newTop = currTop + _kMTransY * _kMScaleY; - newRight = currRight * _kMScaleX; - newBottom = currBottom * _kMScaleY; - // 更新当前flutter节点currNode的相对坐标 -> 屏幕绝对坐标 - SetAbsoluteScreenRect(currNode.id, newLeft, newTop, newRight, newBottom); - } else { - // 若当前节点的相对坐标与父亲节点的相对坐标值相同,则直接继承坐标值 - if (currRight == parentRight && currBottom == parentBottom) { - newLeft = realParentLeft; - newTop = realParentTop; - newRight = realParentRight; - newBottom = realParentBottom; - } else { - // 子节点的屏幕绝对坐标转换,包括offset偏移值计算、缩放系数变换 - newLeft = (currLeft + _kMTransX) * realScaleFactor + realParentLeft; - newTop = (currTop + _kMTransY) * realScaleFactor + realParentTop; - newRight = (currLeft + _kMTransX + currRight) * realScaleFactor + realParentLeft; - newBottom = (currTop + _kMTransY + currBottom) * realScaleFactor + realParentTop; - } - // 若子节点rect超过父节点则跳过显示(单个屏幕显示不下,滑动再重新显示) - const bool IS_OVER_SCREEN_AREA = newLeft < realParentLeft || - newTop < realParentTop || - newRight > realParentRight || - newBottom > realParentBottom || - newLeft >= newRight || - newTop >= newBottom; - if (IS_OVER_SCREEN_AREA) { - FML_DLOG(ERROR) << "ConvertChildRelativeRectToScreenRect childRect is " - "bigger than parentRect -> { nodeId: " - << currNode.id << ", (" << newLeft << ", " << newTop - << ", " << newRight << ", " << newBottom << ")}"; - // 防止滑动场景下绿框坐标超出屏幕范围,进行正则化处理 - newTop -= rootHeight; - newBottom -= rootHeight; - SetAbsoluteScreenRect(currNode.id, newLeft, newTop, newRight, newBottom); - } else { - SetAbsoluteScreenRect(currNode.id, newLeft, newTop, newRight, newBottom); - } - } - FML_DLOG(INFO) << "ConvertChildRelativeRectToScreenRect -> { nodeId: " - << currNode.id << ", (" << newLeft << ", " << newTop << ", " - << newRight << ", " << newBottom << ")}"; +std::pair OhosAccessibilityBridge::GetRealScaleFactor() +{ + auto secondNode = GetFlutterSemanticsNode(1); + SkMatrix transform = secondNode.transform.asM33(); + auto scaleX = transform.get(SkMatrix::kMScaleX); + auto scaleY = transform.get(SkMatrix::kMScaleY); + return std::make_pair(scaleX, scaleY); } /** - * 实现对特定id的flutter节点到arkui的elementinfo节点转化 + * calculate the global transform matrix for each node */ -void OhosAccessibilityBridge::FlutterNodeToElementInfoById( - ArkUI_AccessibilityElementInfo* elementInfoFromList, - int64_t elementId) +void OhosAccessibilityBridge::ComputeGlobalTransform() { - if (elementInfoFromList == nullptr) { - FML_DLOG(INFO) << "OhosAccessibilityBridge::FlutterNodeToElementInfoById " - "elementInfoFromList is null"; - return; - } - FML_DLOG(INFO) << "FlutterNodeToElementInfoById elementId = " << elementId; - - if (OH_GetSdkApiVersion() >= 13) { - // 当elementId = -1或0时,创建root节点 - if (elementId == 0 || elementId == -1) { - // 获取flutter的root节点 - flutter::SemanticsNode flutterNode = GetFlutterSemanticsNode(static_cast(0)); - - // 设置elementinfo的屏幕坐标范围 - int32_t left = static_cast(flutterNode.rect.fLeft); - int32_t top = static_cast(flutterNode.rect.fTop); - int32_t right = static_cast(flutterNode.rect.fRight); - int32_t bottom = static_cast(flutterNode.rect.fBottom); - ArkUI_AccessibleRect rect = {left, top, right, bottom}; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetScreenRect)(ArkUI_AccessibilityElementInfo*, ArkUI_AccessibleRect*) = - OhosAccessibilityDDL::DLLoadSetElemSreenRectFunc("OH_ArkUI_AccessibilityElementInfoSetScreenRect"); - if (OH_ArkUI_AccessibilityElementInfoSetScreenRect == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetScreenRect is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetScreenRect(elementInfoFromList, &rect) - ); - - // 设置root节点的屏幕绝对坐标rect - SetAbsoluteScreenRect(0, left, top, right, bottom); - - // 设置elementinfo的action类型 - std::string widget_type = "root"; - FlutterSetElementInfoOperationActions(elementInfoFromList, widget_type); - - // 根据flutternode信息配置对应的elementinfo - int32_t (*OH_ArkUI_AccessibilityElementInfoSetElementId)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetElementId"); - if (OH_ArkUI_AccessibilityElementInfoSetElementId == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetElementId is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetElementId(elementInfoFromList, 0)); - - // NOTE: arkui无障碍子系统强制设置root的父节点id = -2100000 (严禁更改) - int32_t (*OH_ArkUI_AccessibilityElementInfoSetParentId)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetParentId"); - if (OH_ArkUI_AccessibilityElementInfoSetParentId == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetParentId is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetParentId(elementInfoFromList, ARKUI_ACCESSIBILITY_ROOT_PARENT_ID) - ); - - // 设置无障碍播报文本 - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityText)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityText"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityText == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityText is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetAccessibilityText( - elementInfoFromList, flutterNode.label.empty() ? flutterNode.hint.c_str() : flutterNode.label.c_str()) - ); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel(elementInfoFromList, "yes") - ); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup(elementInfoFromList, false) - ); - - // 配置child节点信息 - int32_t childCount = flutterNode.childrenInTraversalOrder.size(); - auto childrenIdsVec = flutterNode.childrenInTraversalOrder; - std::sort(childrenIdsVec.begin(), childrenIdsVec.end()); - int64_t childNodeIds[childCount]; - for (int32_t i = 0; i < childCount; i++) { - childNodeIds[i] = static_cast(childrenIdsVec[i]); - FML_DLOG(INFO) - << "FlutterNodeToElementInfoById -> elementid=0 childCount=" - << childCount << " childNodeIds=" << childNodeIds[i]; - } - int32_t (*OH_ArkUI_AccessibilityElementInfoSetChildNodeIds)(ArkUI_AccessibilityElementInfo*, int32_t, int64_t*) = - OhosAccessibilityDDL::DLLoadSetElemChildFunc("OH_ArkUI_AccessibilityElementInfoSetChildNodeIds"); - if (OH_ArkUI_AccessibilityElementInfoSetChildNodeIds == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetChildNodeIds is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetChildNodeIds(elementInfoFromList, childCount, childNodeIds) - ); - - // 配置root节点常用属性 - int32_t (*OH_ArkUI_AccessibilityElementInfoSetEnabled)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetEnabled"); - if (OH_ArkUI_AccessibilityElementInfoSetEnabled == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetEnabled is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetEnabled(elementInfoFromList, true)); + std::queue semanticsQue; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetClickable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetClickable"); - if (OH_ArkUI_AccessibilityElementInfoSetClickable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetClickable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetClickable(elementInfoFromList, true)); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetFocusable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetFocusable"); - if (OH_ArkUI_AccessibilityElementInfoSetFocusable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetFocusable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetFocusable(elementInfoFromList, true)); - - int32_t (*OH_ArkUI_AccessibilityElementInfoSetVisible)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetVisible"); - if (OH_ArkUI_AccessibilityElementInfoSetVisible == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetVisible is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetVisible(elementInfoFromList, true)); + auto root = GetFlutterSemanticsNode(0); + semanticsQue.push(root); + g_globalTransformMap[root.id] = root.transform; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetComponentType)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetComponentType"); - if (OH_ArkUI_AccessibilityElementInfoSetComponentType == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetComponentType is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityElementInfoSetComponentType(elementInfoFromList, "root")); + while (!semanticsQue.empty()) { + uint32_t queSize = semanticsQue.size(); + for (uint32_t i=0; i= 1时,根据flutter节点信息配置elementinfo无障碍属性 - FlutterSetElementInfoProperties(elementInfoFromList, elementId); - } + for (const auto& childId: currNode.childrenInTraversalOrder) { + auto childNode = GetFlutterSemanticsNode(childId); + semanticsQue.push(childNode); + g_globalTransformMap[childId] = g_globalTransformMap[currNode.id] * childNode.transform; + } } - FML_DLOG(INFO) << "=== OhosAccessibilityBridge::FlutterNodeToElementInfoById is end ==="; + } +} + +SkPoint OhosAccessibilityBridge::ApplyTransform( + SkPoint& point, const SkM44& transform) { + SkV4 vector = transform.map(point.x(), point.y(), 0, 1); + return SkPoint::Make(vector.x / vector.w, vector.y / vector.w); } /** - * 判断源字符串是否包含目标字符串 + * convert local(relative) rect to global(absolut) rect + * @param node flutter semantics node */ -bool OhosAccessibilityBridge::Contains(const std::string source, - const std::string target) +void OhosAccessibilityBridge::RelativeRectToScreenRect(SemanticsNodeExtent& node) { - return source.find(target) != std::string::npos; + auto [left, top, right, bottom] = node.rect; + SkM44 globalTransform = g_globalTransformMap[node.id]; + + SkPoint points[4] = { + SkPoint::Make(left, top), // top-left point + SkPoint::Make(right, top), // top-right point + SkPoint::Make(right, bottom), // bottom-right point + SkPoint::Make(left, bottom) // bottom-left point + }; + + for (auto& point : points) { + point = ApplyTransform(point, globalTransform); + } + + SkRect globalRect; + bool checkResult = globalRect.setBoundsCheck(points, 4); + if (!checkResult) { + FML_DLOG(WARNING) << "RelativeRectToScreenRect -> Transformed points can't make a rect "; + } + globalRect.setBounds(points, 4); + + SetAbsoluteScreenRect(node, globalRect.left(), globalRect.top(), + globalRect.right(), globalRect.bottom()); } /** @@ -999,432 +559,372 @@ void OhosAccessibilityBridge::FlutterSetElementInfoOperationActions( ArkUI_AccessibilityElementInfo* elementInfoFromList, std::string widget_type) { - if (OH_GetSdkApiVersion() >= 13) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetOperationActions)(ArkUI_AccessibilityElementInfo*, int32_t, ArkUI_AccessibleAction*) = - OhosAccessibilityDDL::DLLoadSetElemOperActionsFunc("OH_ArkUI_AccessibilityElementInfoSetOperationActions"); - if (OH_ArkUI_AccessibilityElementInfoSetOperationActions == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetOperationActions is null, %{public}s", dlerror()); - } - if (widget_type == "textfield") { - // set elementinfo action types - int32_t actionTypeNum = 10; - ArkUI_AccessibleAction actions[actionTypeNum]; - - actions[0].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS; - actions[0].description = "获取焦点"; - - actions[1].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS; - actions[1].description = "清除焦点"; - - actions[2].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK; - actions[2].description = "点击操作"; - - actions[3].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_LONG_CLICK; - actions[3].description = "长按操作"; - - actions[4].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_COPY; - actions[4].description = "文本复制"; - - actions[5].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_PASTE; - actions[5].description = "文本粘贴"; - - actions[6].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CUT; - actions[6].description = "文本剪切"; - - actions[7].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SELECT_TEXT; - actions[7].description = "文本选择"; - - actions[8].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_TEXT; - actions[8].description = "文本内容设置"; - - actions[9].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_CURSOR_POSITION; - actions[9].description = "光标位置设置"; - - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetOperationActions(elementInfoFromList, actionTypeNum, actions) - ); - } else if (widget_type == "scrollable") { - // if node is a scrollable component - int32_t actionTypeNum = 5; - ArkUI_AccessibleAction actions[actionTypeNum]; - - actions[0].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS; - actions[0].description = "获取焦点"; - - actions[1].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS; - actions[1].description = "清除焦点"; - - actions[2].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK; - actions[2].description = "点击动作"; - - actions[3].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_FORWARD; - actions[3].description = "向上滑动"; - - actions[4].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_BACKWARD; - actions[4].description = "向下滑动"; - - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetOperationActions(elementInfoFromList, actionTypeNum, actions) - ); - } else { - // set common component action types - int32_t actionTypeNum = 3; - ArkUI_AccessibleAction actions[actionTypeNum]; - - actions[0].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS; - actions[0].description = "获取焦点"; + if (OHOS_API_VERSION < 13) { return; } + auto OH_ArkUI_AccessibilityElementInfoSetOperationActions = + OhosAccessibilityDDL::DLLoadSetElemOperActionsFunc(ArkUIAccessibilityConstant::ARKUI_SET_ACTIONS); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetOperationActions); + if (OHOSUtils::Contains(widget_type, EDIT_TEXT_WIDGET_NAME) || + OHOSUtils::Contains(widget_type, EDIT_MULTILINE_TEXT_WIDGET_NAME)) { + // set elementinfo action types + int32_t actionTypeNum = 10; + ArkUI_AccessibleAction actions[actionTypeNum]; + int32_t idx = 0; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS; + actions[idx++].description = "获取焦点"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS; + actions[idx++].description = "清除焦点"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK; + actions[idx++].description = "点击操作"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_LONG_CLICK; + actions[idx++].description = "长按操作"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_COPY; + actions[idx++].description = "文本复制"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_PASTE; + actions[idx++].description = "文本粘贴"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CUT; + actions[idx++].description = "文本剪切"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SELECT_TEXT; + actions[idx++].description = "文本选择"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_TEXT; + actions[idx++].description = "文本内容设置"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_CURSOR_POSITION; + actions[idx].description = "光标位置设置"; - actions[1].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS; - actions[1].description = "清除焦点"; + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetOperationActions(elementInfoFromList, actionTypeNum, actions) + ); + } else if (OHOSUtils::Contains(widget_type, SCROLL_WIDGET_NAME)) { + // if node is a scrollable component + int32_t actionTypeNum = 5; + ArkUI_AccessibleAction actions[actionTypeNum]; + int32_t idx = 0; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS; + actions[idx++].description = "获取焦点"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS; + actions[idx++].description = "清除焦点"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK; + actions[idx++].description = "点击动作"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_FORWARD; + actions[idx++].description = "向上滑动"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_BACKWARD; + actions[idx].description = "向下滑动"; - actions[2].actionType = ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK; - actions[2].description = "点击动作"; + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetOperationActions(elementInfoFromList, actionTypeNum, actions) + ); + } else { + // set common component action types + int32_t actionTypeNum = 3; + ArkUI_AccessibleAction actions[actionTypeNum]; + int32_t idx = 0; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS; + actions[idx++].description = "获取焦点"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS; + actions[idx++].description = "清除焦点"; + actions[idx].actionType = ArkUI_Accessibility_ActionType:: + ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK; + actions[idx].description = "点击动作"; - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetOperationActions(elementInfoFromList, actionTypeNum, actions) - ); - } + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetOperationActions(elementInfoFromList, actionTypeNum, actions) + ); } } /** + * 实现对特定id的flutter节点到arkui的elementinfo节点转化, * 根据flutter节点信息配置elementinfo无障碍属性 */ void OhosAccessibilityBridge::FlutterSetElementInfoProperties( ArkUI_AccessibilityElementInfo* elementInfoFromList, int64_t elementId) { - if (OH_GetSdkApiVersion() >= 13) { - flutter::SemanticsNode flutterNode = GetFlutterSemanticsNode(static_cast(elementId)); - - // set elementinfo id - int32_t (*OH_ArkUI_AccessibilityElementInfoSetElementId)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetElementId"); - if (OH_ArkUI_AccessibilityElementInfoSetElementId == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetElementId is null, %{public}s", dlerror()); + if (OHOS_API_VERSION < 13) { return; } + auto flutterNode = GetFlutterSemanticsNode(static_cast(elementId > 0 ? elementId : 0)); + if (!g_flutterSemanticsTree.count(flutterNode.id)) { + LOGE("FlutterSetElementInfoProperties: GetFlutterSemanticsNode id=%{public}ld null", elementId); + } + + // 设置当前节点id + auto OH_ArkUI_AccessibilityElementInfoSetElementId = + OhosAccessibilityDDL::DLLoadSetElemIntFunc(ArkUIAccessibilityConstant::ARKUI_SET_NODE_ID); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetElementId); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetElementId(elementInfoFromList, flutterNode.id) + ); + + // 相对-绝对坐标映射 + ArkUI_AccessibleRect rect; + if (elementId < 1) { // 若当前节点为root + int32_t left = flutterNode.rect.fLeft; + int32_t top = flutterNode.rect.fTop; + int32_t right = flutterNode.rect.fRight; + int32_t bottom = flutterNode.rect.fBottom; + SetAbsoluteScreenRect(flutterNode, left, top, right, bottom); + rect = {static_cast(left), static_cast(top), + static_cast(right), static_cast(bottom)}; + } else { // 若当前节点为id >= 1的节点 + RelativeRectToScreenRect(flutterNode); + auto [left, top, right, bottom] = GetAbsoluteScreenRect(flutterNode); + rect = {static_cast(left), static_cast(top), + static_cast(right), static_cast(bottom)}; + } + auto OH_ArkUI_AccessibilityElementInfoSetScreenRect = + OhosAccessibilityDDL::DLLoadSetElemSreenRectFunc(ArkUIAccessibilityConstant::ARKUI_SET_SCREEN_RECT); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetScreenRect); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetScreenRect(elementInfoFromList, &rect) + ); + + // 配置arkui的elementinfo可操作动作属性 + // 设置root节点的action类型 + std::string widgeType = GetNodeComponentType(flutterNode); + if (elementId < 1) { + FlutterSetElementInfoOperationActions(elementInfoFromList, OTHER_WIDGET_NAME); + } else { + FlutterSetElementInfoOperationActions(elementInfoFromList, widgeType); + } + + // 设置当前节点的父节点id + int32_t parentId = GetParentId(elementId); + auto OH_ArkUI_AccessibilityElementInfoSetParentId = + OhosAccessibilityDDL::DLLoadSetElemIntFunc(ArkUIAccessibilityConstant::ARKUI_SET_PARENT_ID); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetParentId); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetParentId(elementInfoFromList, parentId) + ); + FML_DLOG(INFO) << "FlutterSetElementInfoProperties GetParentId = " << parentId; + + // 设置可朗读文本 + std::string text = flutterNode.label + flutterNode.value; + auto OH_ArkUI_AccessibilityElementInfoSetAccessibilityText = + OhosAccessibilityDDL::DLLoadSetElemStringFunc(ArkUIAccessibilityConstant::ARKUI_SET_A11Y_TEXT); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetAccessibilityText); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetAccessibilityText(elementInfoFromList, text.c_str()) + ); + FML_DLOG(INFO) << "FlutterSetElementInfoProperties SetAccessibilityText = " << text; + + // 设置无障碍content文本 + auto OH_ArkUI_AccessibilityElementInfoSetContents = + OhosAccessibilityDDL::DLLoadSetElemStringFunc(ArkUIAccessibilityConstant::ARKUI_SET_CONTENTS); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetContents); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetContents(elementInfoFromList, text.c_str()) + ); + // 设置hint提示文本 + std::string hint = flutterNode.hint; + auto OH_ArkUI_AccessibilityElementInfoSetHintText = + OhosAccessibilityDDL::DLLoadSetElemStringFunc(ArkUIAccessibilityConstant::ARKUI_SET_HINT); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetHintText); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetHintText(elementInfoFromList, hint.c_str()) + ); + + // 设置当前节点的全部孩子节点 + int32_t childCount = flutterNode.childrenInTraversalOrder.size(); + if (childCount > 0) { + auto childrenIdsVec = flutterNode.childrenInTraversalOrder; + std::sort(childrenIdsVec.begin(), childrenIdsVec.end()); + int64_t childNodeIds[childCount]; + for (int32_t i = 0; i < childCount; i++) { + childNodeIds[i] = static_cast(childrenIdsVec[i]); + FML_DLOG(INFO) << "FlutterSetElementInfoProperties -> elementid=" << elementId + << " childCount=" << childCount + << " childNodeIds=" << childNodeIds[i]; } + auto OH_ArkUI_AccessibilityElementInfoSetChildNodeIds = + OhosAccessibilityDDL::DLLoadSetElemChildFunc(ArkUIAccessibilityConstant::ARKUI_SET_CHILD_IDS); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetChildNodeIds); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetElementId(elementInfoFromList, flutterNode.id) + OH_ArkUI_AccessibilityElementInfoSetChildNodeIds(elementInfoFromList, childCount, childNodeIds) ); + } - // convert relative rect to absolute rect - ConvertChildRelativeRectToScreenRect(flutterNode); - auto rectPairs = GetAbsoluteScreenRect(flutterNode.id); - // set screen rect in xcomponent - int32_t left = rectPairs.first.first; - int32_t top = rectPairs.first.second; - int32_t right = rectPairs.second.first; - int32_t bottom = rectPairs.second.second; - ArkUI_AccessibleRect rect = {left, top, right, bottom}; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetScreenRect)(ArkUI_AccessibilityElementInfo*, ArkUI_AccessibleRect*) = - OhosAccessibilityDDL::DLLoadSetElemSreenRectFunc("OH_ArkUI_AccessibilityElementInfoSetScreenRect"); - if (OH_ArkUI_AccessibilityElementInfoSetScreenRect == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetScreenRect is null, %{public}s", dlerror()); - } + // 判断当前节点组件是否enabled + if (IsNodeEnabled(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetEnabled = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_ENABLED); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetEnabled); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetScreenRect(elementInfoFromList, &rect) + OH_ArkUI_AccessibilityElementInfoSetEnabled(elementInfoFromList, true) ); - FML_DLOG(INFO) << "FlutterNodeToElementInfoById -> node.id= " - << flutterNode.id << " SceenRect = (" << left << ", " << top - << ", " << right << ", " << bottom << ")"; - - // 配置arkui的elementinfo可操作动作属性 - if (IsTextField(flutterNode)) { - // 若当前flutter节点为文本输入框组件 - std::string widget_type = "textfield"; - FlutterSetElementInfoOperationActions(elementInfoFromList, widget_type); - } else if (IsScrollableWidget(flutterNode) || IsNodeScrollable(flutterNode)) { - // 若当前flutter节点为可滑动组件类型 - std::string widget_type = "scrollable"; - FlutterSetElementInfoOperationActions(elementInfoFromList, widget_type); - } else { - // 若当前flutter节点为通用组件 - std::string widget_type = "common"; - FlutterSetElementInfoOperationActions(elementInfoFromList, widget_type); - } - - // set current elementinfo parent id - int32_t parentId = GetParentId(elementId); - int32_t (*OH_ArkUI_AccessibilityElementInfoSetParentId)(ArkUI_AccessibilityElementInfo*, int32_t) = - OhosAccessibilityDDL::DLLoadSetElemIntFunc("OH_ArkUI_AccessibilityElementInfoSetParentId"); - if (OH_ArkUI_AccessibilityElementInfoSetParentId == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetParentId is null, %{public}s", dlerror()); - } + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetEnabled -> true"; + } + // 判断当前节点是否可点击 + if (IsNodeClickable(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetClickable = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_CLICKABLE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetClickable); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetParentId(elementInfoFromList, parentId) + OH_ArkUI_AccessibilityElementInfoSetClickable(elementInfoFromList, true) ); - FML_DLOG(INFO) << "FlutterNodeToElementInfoById GetParentId = " << parentId; - - // set accessibility text for announcing - std::string text = flutterNode.label; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityText)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityText"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityText == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityText is null, %{public}s", dlerror()); - } + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetClickable -> true"; + } + // 判断当前节点是否可获焦点 + if (IsNodeFocusable(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetFocusable = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_FOCUSABLE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetFocusable); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetAccessibilityText(elementInfoFromList, text.c_str()) + OH_ArkUI_AccessibilityElementInfoSetFocusable(elementInfoFromList, true) ); - FML_DLOG(INFO) << "FlutterNodeToElementInfoById SetAccessibilityText = " - << text; - - //set contents (same as AccessibilityText) - int32_t (*OH_ArkUI_AccessibilityElementInfoSetContents)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetContents"); - if (OH_ArkUI_AccessibilityElementInfoSetContents == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetContents is null, %{public}s", dlerror()); - } + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetFocusable -> true"; + } + if (IsNodeFocused(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_A11Y_FOCUSED); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetContents(elementInfoFromList, text.c_str()) + OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused(elementInfoFromList, true) ); - - std::string hint = flutterNode.hint; - int32_t (*OH_ArkUI_AccessibilityElementInfoSetHintText)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetHintText"); - if (OH_ArkUI_AccessibilityElementInfoSetHintText == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetHintText is null, %{public}s", dlerror()); - } + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused -> true"; + } + // 判断当前节点是否为密码输入框 + if (IsNodePassword(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetIsPassword = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_IS_PASSWORD); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetIsPassword); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetHintText(elementInfoFromList, hint.c_str()) + OH_ArkUI_AccessibilityElementInfoSetIsPassword(elementInfoFromList, true) ); - - // set chidren elementinfo ids - int32_t childCount = flutterNode.childrenInTraversalOrder.size(); - auto childrenIdsVec = flutterNode.childrenInTraversalOrder; - std::sort(childrenIdsVec.begin(), childrenIdsVec.end()); - int64_t childNodeIds[childCount]; - for (int32_t i = 0; i < childCount; i++) { - childNodeIds[i] = static_cast(childrenIdsVec[i]); - FML_DLOG(INFO) << "FlutterNodeToElementInfoById -> elementid=" << elementId - << " childCount=" << childCount - << " childNodeIds=" << childNodeIds[i]; - } - int32_t (*OH_ArkUI_AccessibilityElementInfoSetChildNodeIds)(ArkUI_AccessibilityElementInfo*, int32_t, int64_t*) = - OhosAccessibilityDDL::DLLoadSetElemChildFunc("OH_ArkUI_AccessibilityElementInfoSetChildNodeIds"); - if (OH_ArkUI_AccessibilityElementInfoSetChildNodeIds == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetChildNodeIds is null, %{public}s", dlerror()); - } + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetIsPassword -> true"; + } + // 判断当前节点是否具备checkable状态 (如:checkbox, radio button) + if (IsNodeCheckable(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetCheckable = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_CHECKABLE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetCheckable); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetChildNodeIds(elementInfoFromList, childCount, childNodeIds) + OH_ArkUI_AccessibilityElementInfoSetCheckable(elementInfoFromList, true) ); - - /** - * 根据当前flutter节点的SemanticsFlags特性,配置对应的elmentinfo属性 - */ - // 判断当前节点组件是否enabled - if (IsNodeEnabled(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetEnabled)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetEnabled"); - if (OH_ArkUI_AccessibilityElementInfoSetEnabled == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetEnabled is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetEnabled(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetEnabled -> true"; - } - // 判断当前节点是否可点击 - if (IsNodeClickable(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetClickable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetClickable"); - if (OH_ArkUI_AccessibilityElementInfoSetClickable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetClickable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetClickable(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetClickable -> true"; - } - // 判断当前节点是否可获焦点 - if (IsNodeFocusable(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetFocusable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetFocusable"); - if (OH_ArkUI_AccessibilityElementInfoSetFocusable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetFocusable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetFocusable(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetFocusable -> true"; - } - // 判断当前节点是否为密码输入框 - if (IsNodePassword(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetIsPassword)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetIsPassword"); - if (OH_ArkUI_AccessibilityElementInfoSetIsPassword == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetIsPassword is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetIsPassword(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetIsPassword -> true"; - } - // 判断当前节点是否具备checkable状态 (如:checkbox, radio button) - if (IsNodeCheckable(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetCheckable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetCheckable"); - if (OH_ArkUI_AccessibilityElementInfoSetCheckable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetCheckable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetCheckable(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetCheckable -> true"; - } - // 判断当前节点(check box/radio button)是否checked/unchecked - if (IsNodeChecked(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetChecked)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetChecked"); - if (OH_ArkUI_AccessibilityElementInfoSetChecked == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetChecked is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetChecked(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetChecked -> true"; - } - // 判断当前节点组件是否可显示 - if (IsNodeVisible(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetVisible)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetVisible"); - if (OH_ArkUI_AccessibilityElementInfoSetVisible == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetVisible is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetVisible(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetVisible -> true"; - } - // 判断当前节点组件是否选中 - if (IsNodeSelected(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetSelected)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetSelected"); - if (OH_ArkUI_AccessibilityElementInfoSetSelected == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetSelected is null, %{public}s", dlerror()); - } - OH_ArkUI_AccessibilityElementInfoSetSelected(elementInfoFromList, true); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetSelected -> true"; - } - // 判断当前节点组件是否可滑动 - if (IsNodeScrollable(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetScrollable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetScrollable"); - if (OH_ArkUI_AccessibilityElementInfoSetScrollable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetScrollable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetScrollable(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetScrollable -> true"; - } - // 判断当前节点组件是否可编辑(文本输入框) - if (IsTextField(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetEditable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetEditable"); - if (OH_ArkUI_AccessibilityElementInfoSetEditable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetEditable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetEditable(elementInfoFromList, true) - ); - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetEditable -> true"; - } - // 判断当前节点组件是否为滑动条 - if (IsSlider(flutterNode)) { - FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetRangeInfo -> true"; - } - // 判断当前节点组件是否支持长按 - if (IsNodeHasLongPress(flutterNode)) { - int32_t (*OH_ArkUI_AccessibilityElementInfoSetLongClickable)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetLongClickable"); - if (OH_ArkUI_AccessibilityElementInfoSetLongClickable == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetLongClickable is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetLongClickable(elementInfoFromList, true) - ); - FML_DLOG(INFO) - << "flutterNode.id=" << flutterNode.id - << " OH_ArkUI_AccessibilityElementInfoSetLongClickable -> true"; - } - - // 获取当前节点的组件类型 - std::string componentTypeName = GetNodeComponentType(flutterNode); - FML_DLOG(INFO) << "FlutterNodeToElementInfoById componentTypeName = " - << componentTypeName; - // flutter节点对应elementinfo所属的组件类型(如:root, button,text等) - int32_t (*OH_ArkUI_AccessibilityElementInfoSetComponentType)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetComponentType"); - if (OH_ArkUI_AccessibilityElementInfoSetComponentType == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetComponentType is null, %{public}s", dlerror()); - } - if (elementId == 0) { - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetComponentType(elementInfoFromList, "root") - ); - } else { - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetComponentType(elementInfoFromList, - componentTypeName.c_str()) - ); - } - FML_DLOG(INFO) << "FlutterNodeToElementInfoById SetComponentType: " - << componentTypeName; - - /** - * 无障碍重要性,用于控制某个组件是否可被无障碍辅助服务所识别。支持的值为(默认值:“auto”): - * “auto”:根据组件不同会转换为“yes”或者“no” - * “yes”:当前组件可被无障碍辅助服务所识别 - * “no”:当前组件不可被无障碍辅助服务所识别 - * “no-hide-descendants”:当前组件及其所有子组件不可被无障碍辅助服务所识别 - */ - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel)(ArkUI_AccessibilityElementInfo*, const char*) = - OhosAccessibilityDDL::DLLoadSetElemStringFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel is null, %{public}s", dlerror()); - } + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetCheckable -> true"; + } + // 判断当前节点(check box/radio button)是否checked/unchecked + if (IsNodeChecked(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetChecked = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_CHECKED); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetChecked); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel(elementInfoFromList, "yes"); + OH_ArkUI_AccessibilityElementInfoSetChecked(elementInfoFromList, true) ); - // 无障碍组,设置为true时表示该组件及其所有子组件为一整个可以选中的组件,无障碍服务将不再关注其子组件内容。默认值:false - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup is null, %{public}s", dlerror()); - } + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetChecked -> true"; + } + // 判断当前节点组件是否可显示 + if (IsNodeVisible(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetVisible = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_VISIBLE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetVisible); ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup(elementInfoFromList, false); + OH_ArkUI_AccessibilityElementInfoSetVisible(elementInfoFromList, true) ); - } + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetVisible -> true"; + } + // 判断当前节点组件是否选中 + if (IsNodeSelected(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetSelected = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_SELECTED); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetSelected); + OH_ArkUI_AccessibilityElementInfoSetSelected(elementInfoFromList, true); + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetSelected -> true"; + } + // 判断当前节点组件是否可滑动 + if (IsNodeScrollable(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetScrollable = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_SCROLLABLE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetScrollable); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetScrollable(elementInfoFromList, true) + ); + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetScrollable -> true"; + } + // 判断当前节点组件是否可编辑(文本输入框) + if (IsTextField(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetEditable = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_EDITABLE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetEditable); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetEditable(elementInfoFromList, true) + ); + FML_DLOG(INFO) << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetEditable -> true"; + } + // 判断当前节点组件是否支持长按 + if (IsNodeHasLongPress(flutterNode)) { + auto OH_ArkUI_AccessibilityElementInfoSetLongClickable = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_LONG_PRESS); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetLongClickable); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetLongClickable(elementInfoFromList, true) + ); + FML_DLOG(INFO) + << "flutterNode.id=" << flutterNode.id + << " OH_ArkUI_AccessibilityElementInfoSetLongClickable -> true"; + } + + // 获取当前节点的组件类型 + std::string componentTypeName = GetNodeComponentType(flutterNode); + FML_DLOG(INFO) << "FlutterSetElementInfoProperties componentTypeName = " + << componentTypeName; + // flutter节点对应elementinfo所属的组件类型(如:root, button,text等) + auto OH_ArkUI_AccessibilityElementInfoSetComponentType = + OhosAccessibilityDDL::DLLoadSetElemStringFunc(ArkUIAccessibilityConstant::ARKUI_SET_COMPONENT_TYPE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetComponentType); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetComponentType( + elementInfoFromList, elementId < 1 ? "root" : componentTypeName.c_str()) + ); + FML_DLOG(INFO) << "FlutterSetElementInfoProperties SetComponentType: " + << componentTypeName; + + /** + * 无障碍重要性,用于控制某个组件是否可被无障碍辅助服务所识别。支持的值为(默认值:“auto”): + * “auto”:根据组件不同会转换为“yes”或者“no” + * “yes”:当前组件可被无障碍辅助服务所识别 + * “no”:当前组件不可被无障碍辅助服务所识别 + * “no-hide-descendants”:当前组件及其所有子组件不可被无障碍辅助服务所识别 + */ + auto OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel = + OhosAccessibilityDDL::DLLoadSetElemStringFunc(ArkUIAccessibilityConstant::ARKUI_SET_A11Y_LEVEL); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel( + elementInfoFromList, componentTypeName != OTHER_WIDGET_NAME ? "yes" : "no"); + ); + // 无障碍组,设置为true时表示该组件及其所有子组件为一整个可以选中的组件,无障碍服务将不再关注其子组件内容。默认值:false + auto OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup = + OhosAccessibilityDDL::DLLoadSetElemBoolFunc(ArkUIAccessibilityConstant::ARKUI_SET_A11Y_GROUP); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup(elementInfoFromList, false); + ); } /** @@ -1435,7 +935,7 @@ void OhosAccessibilityBridge::FlutterSetElementInfoProperties( std::vector OhosAccessibilityBridge::GetLevelOrderTraversalTree(int32_t rootId) { std::vector levelOrderTraversalTree; - std::queue semanticsQue; + std::queue semanticsQue; auto root = GetFlutterSemanticsNode(rootId); semanticsQue.push(root); @@ -1444,6 +944,7 @@ std::vector OhosAccessibilityBridge::GetLevelOrderTraversalTree(int32_t uint32_t queSize = semanticsQue.size(); for (uint32_t i=0; i(currNode.id)); @@ -1451,6 +952,7 @@ std::vector OhosAccessibilityBridge::GetLevelOrderTraversalTree(int32_t currNode.childrenInTraversalOrder.end()); for (const auto& childId: currNode.childrenInTraversalOrder) { auto childNode = GetFlutterSemanticsNode(childId); + semanticsQue.push(childNode); } } @@ -1459,126 +961,431 @@ std::vector OhosAccessibilityBridge::GetLevelOrderTraversalTree(int32_t } /** - * 创建并配置完整arkui无障碍语义树 + * 创建并配置完整arkui无障碍语义树 + */ +void OhosAccessibilityBridge::BuildArkUISemanticsTree( + int64_t elementId, + ArkUI_AccessibilityElementInfo* elementInfoFromList, + ArkUI_AccessibilityElementInfoList* elementList) +{ + if (OHOS_API_VERSION < 13) { return; } + //配置root节点信息 + FlutterSetElementInfoProperties(elementInfoFromList, elementId); + //获取flutter无障碍语义树的节点总数 + auto levelOrderTreeVec = GetLevelOrderTraversalTree(0); + int64_t elementInfoCount = levelOrderTreeVec.size(); + //创建并配置节点id >= 1的全部节点 + for (int64_t i = 1; i < elementInfoCount; i++) { + int64_t levelOrderId = levelOrderTreeVec[i]; + auto newNode = GetFlutterSemanticsNode(levelOrderId); + if (g_flutterSemanticsTree.count(newNode.id)) { + LOGE("BuildArkUISemanticsTree: GetFlutterSemanticsNode id=%{public}ld null", levelOrderId); + } + //当节点为隐藏状态时,自动规避 + auto OH_ArkUI_AddAndGetAccessibilityElementInfo = + OhosAccessibilityDDL::DLLoadGetElemFunc(ArkUIAccessibilityConstant::ARKUI_GET_A11Y_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AddAndGetAccessibilityElementInfo); + auto* newElementInfo = OH_ArkUI_AddAndGetAccessibilityElementInfo(elementList); + //配置当前子节点信息 + FlutterSetElementInfoProperties(newElementInfo, levelOrderId); + } +} + +/** + * Called to obtain element information based on a specified node. + * NOTE:该arkui接口需要在系统无障碍服务开启时,才能触发调用 + */ +int32_t OhosAccessibilityBridge::FindAccessibilityNodeInfosById( + int64_t elementId, + ArkUI_AccessibilitySearchMode mode, + int32_t requestId, + ArkUI_AccessibilityElementInfoList* elementList) +{ + if (OHOS_API_VERSION < 13) { return ARKUI_FAILED_CODE; } + FML_DLOG(INFO) + << "#### FindAccessibilityNodeInfosById input-params ####: elementId = " + << elementId << " mode=" << mode; + CHECK_NULL_PTR_WITH_RET(elementList, FindAccessibilityNodeInfosById); + + AccessibiltiyChangesWithXComponentId(); + + if (g_flutterSemanticsTree.size() == 0) { + FML_DLOG(INFO) + << "FindAccessibilityNodeInfosById g_flutterSemanticsTree is null"; + return ARKUI_ACCESSIBILITY_NATIVE_RESULT_FAILED; + } + + // 获取当前对应id的flutter节点,若为空则返回错误编码 + auto flutterNode = GetFlutterSemanticsNode(static_cast(elementId)); + if (!g_flutterSemanticsTree.count(flutterNode.id)) { + LOGE("FindAccessibilityNodeInfosById: GetFlutterSemanticsNode id=%{public}ld is null", elementId); + } + + // 开启无障碍导航功能 + if(elementId == -1 || elementId == 0) { + accessibilityFeatures_->SetAccessibleNavigation(true, native_shell_holder_id_); + } + + // 从elementinfolist中获取elementinfo + auto OH_ArkUI_AddAndGetAccessibilityElementInfo = + OhosAccessibilityDDL::DLLoadGetElemFunc(ArkUIAccessibilityConstant::ARKUI_GET_A11Y_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AddAndGetAccessibilityElementInfo); + auto* elementInfoFromList = OH_ArkUI_AddAndGetAccessibilityElementInfo(elementList); + CHECK_NULL_PTR_WITH_RET(elementInfoFromList, OH_ArkUI_AddAndGetAccessibilityElementInfo); + + if (mode == ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_CURRENT) { + /** Search for current nodes. (mode = 0) */ + BuildArkUISemanticsTree(elementId, elementInfoFromList, elementList); + } else if (mode ==ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_PREDECESSORS) { + /** Search for parent nodes. (mode = 1) */ + if (IsNodeVisible(flutterNode)) { + FlutterSetElementInfoProperties(elementInfoFromList, elementId); + } + } else if (mode ==ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_SIBLINGS) { + /** Search for sibling nodes. (mode = 2) */ + if (IsNodeVisible(flutterNode)) { + FlutterSetElementInfoProperties(elementInfoFromList, elementId); + } + } else if (mode ==ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_CHILDREN) { + /** Search for child nodes at the next level. (mode = 4) */ + if (IsNodeVisible(flutterNode)) { + FlutterSetElementInfoProperties(elementInfoFromList, elementId); + } + } else if (mode ==ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_RECURSIVE_CHILDREN) { + /** Search for all child nodes. (mode = 8) */ + BuildArkUISemanticsTree(elementId, elementInfoFromList, elementList); + } else { + FlutterSetElementInfoProperties(elementInfoFromList, elementId); + } + FML_DLOG(INFO) << "--- FindAccessibilityNodeInfosById is end ---"; + + return ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL; +} + +/** + * 解析flutter语义动作,并通过NativAccessibilityChannel分发 + */ +void OhosAccessibilityBridge::DispatchSemanticsAction( + int32_t id, + flutter::SemanticsAction action, + fml::MallocMapping args) +{ + nativeAccessibilityChannel_->DispatchSemanticsAction(native_shell_holder_id_, + id, + action, + std::move(args)); +} + +/** + * flutter按钮节点双击跳转新页面时,发送页面更新事件 + */ +void OhosAccessibilityBridge::DoubleClickRouteToNewPage(SemanticsNodeExtent node) +{ + if (node.HasFlag(FLAGS_::kIsButton)) { + RequestFocusWhenPageUpdate(0); + } +} + +/** + * perform click action in accessibility status + */ +void OhosAccessibilityBridge::PerformClickAction( + int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode) +{ + /** Click event, sent after the UI component responds. 1 */ + auto clickEventType = ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_CLICKED; + Flutter_SendAccessibilityAsyncEvent(elementId, clickEventType); + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: click(" << action + << ")" << " event: click(" << clickEventType << ")"; + auto flutterTapAction = ArkuiActionsToFlutterActions(action); + DispatchSemanticsAction(static_cast(elementId), flutterTapAction, {}); + // double click at button-like node for pushing page update + DoubleClickRouteToNewPage(flutterNode); +} + +/** + * perform long-press action in accessibility status + */ +void OhosAccessibilityBridge::PerformLongClickAction( + int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode) +{ + /** Long click event, sent after the UI component responds. 2 */ + auto longClickEventType = ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_LONG_CLICKED; + Flutter_SendAccessibilityAsyncEvent(elementId, longClickEventType); + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: longclick(" + << action << ")" << " event: longclick(" + << longClickEventType << ")"; + auto flutterLongPressAction = ArkuiActionsToFlutterActions(action); + DispatchSemanticsAction(static_cast(elementId), flutterLongPressAction, {}); +} + +/** + * perform focus acquisition in accessibility status */ -void OhosAccessibilityBridge::BuildArkUISemanticsTree( +void OhosAccessibilityBridge::PerformGainFocusnAction( int64_t elementId, - ArkUI_AccessibilityElementInfo* elementInfoFromList, - ArkUI_AccessibilityElementInfoList* elementList) + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode) { - if (OH_GetSdkApiVersion() >= 13) { - //配置root节点信息 - FlutterNodeToElementInfoById(elementInfoFromList, elementId); - //获取flutter无障碍语义树的节点总数 - auto levelOrderTreeVec = GetLevelOrderTraversalTree(0); - int64_t elementInfoCount = levelOrderTreeVec.size(); - //创建并配置节点id >= 1的全部节点 - for (int64_t i = 1; i < elementInfoCount; i++) { - int64_t levelOrderId = levelOrderTreeVec[i]; - auto newNode = GetFlutterSemanticsNode(levelOrderId); - //当节点为隐藏状态时,自动规避 - if (IsNodeVisible(newNode)) { - ArkUI_AccessibilityElementInfo* (*OH_ArkUI_AddAndGetAccessibilityElementInfo)(ArkUI_AccessibilityElementInfoList*) = - OhosAccessibilityDDL::DLLoadGetElemFunc("OH_ArkUI_AddAndGetAccessibilityElementInfo"); - if (OH_ArkUI_AddAndGetAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_AddAndGetAccessibilityElementInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityElementInfo* newElementInfo = - OH_ArkUI_AddAndGetAccessibilityElementInfo(elementList); - //配置当前子节点信息 - FlutterNodeToElementInfoById(newElementInfo, levelOrderId); - } - } + // 感知获焦flutter节点 + accessibilityFocusedNode = flutterNode; + // 解析arkui的获焦 -> flutter对应节点的获焦 + auto flutterGainFocusAction = ArkuiActionsToFlutterActions(action); + DispatchSemanticsAction(static_cast(elementId), + flutterGainFocusAction, {}); + // Accessibility focus event, sent after the UI component responds. 32768 + auto focusEventType = ArkUI_AccessibilityEventType:: + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ACCESSIBILITY_FOCUSED; + Flutter_SendAccessibilityAsyncEvent(elementId, focusEventType); + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: focus(" << action + << ")" << " event: focus(" << focusEventType << ")"; + + if (flutterNode.HasAction(ACTIONS_::kIncrease) || + flutterNode.HasAction(ACTIONS_::kDecrease)) { + Flutter_SendAccessibilityAsyncEvent( + elementId, ArkUI_AccessibilityEventType:: + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SELECTED); } } /** - * Called to obtain element information based on a specified node. - * NOTE:该arkui接口需要在系统无障碍服务开启时,才能触发调用 + * perform focus clearance in accessibility status */ -int32_t OhosAccessibilityBridge::FindAccessibilityNodeInfosById( +void OhosAccessibilityBridge::PerformClearFocusAction( int64_t elementId, - ArkUI_AccessibilitySearchMode mode, - int32_t requestId, - ArkUI_AccessibilityElementInfoList* elementList) + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode) { - FML_DLOG(INFO) - << "#### FindAccessibilityNodeInfosById input-params ####: elementId = " - << elementId << " mode=" << mode << " requestId=" << requestId - << " elementList= " << elementList; + // 解析arkui的失焦 -> flutter对应节点的失焦 + auto flutterLoseFocusAction = ArkuiActionsToFlutterActions(action); + DispatchSemanticsAction(static_cast(elementId), flutterLoseFocusAction, {}); + /** Accessibility focus cleared event, sent after the UI component + * responds. 65536 */ + auto clearFocusEventType = ArkUI_AccessibilityEventType:: + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ACCESSIBILITY_FOCUS_CLEARED; + Flutter_SendAccessibilityAsyncEvent(elementId, clearFocusEventType); + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: clearfocus(" + << action << ")" << " event: clearfocus(" + << clearFocusEventType << ")"; +} - if (g_flutterSemanticsTree.size() == 0) { +/** + * perform scroll forward in accessibility status + */ +void OhosAccessibilityBridge::PerformScrollUpAction( + int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode) +{ + // flutter scroll forward with different situations + if (flutterNode.HasAction(ACTIONS_::kScrollUp)) { + auto flutterScrollUpAction = ArkuiActionsToFlutterActions(action); + DispatchSemanticsAction(static_cast(elementId), flutterScrollUpAction, {}); + } else if (flutterNode.HasAction(ACTIONS_::kScrollLeft)) { + DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kScrollLeft, {}); + } else if (flutterNode.HasAction(ACTIONS_::kIncrease)) { + flutterNode.value = flutterNode.increasedValue; + flutterNode.valueAttributes = flutterNode.increasedValueAttributes; + + Flutter_SendAccessibilityAsyncEvent( + elementId, ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SELECTED); + DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kIncrease, {}); + } + std::string currComponetType = GetNodeComponentType(flutterNode); + if (OHOSUtils::Contains(currComponetType, SCROLL_WIDGET_NAME)) { + /** Scrolled event, sent when a scrollable component experiences a scroll event. 4096 */ + ArkUI_AccessibilityEventType scrollEventType1 = + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SCROLLED; + Flutter_SendAccessibilityAsyncEvent(elementId, scrollEventType1); FML_DLOG(INFO) - << "FindAccessibilityNodeInfosById g_flutterSemanticsTree is null"; - return ARKUI_ACCESSIBILITY_NATIVE_RESULT_FAILED; + << "ExecuteAccessibilityAction -> action: scroll forward(" << action + << ")" << " event: scroll forward(" << scrollEventType1 << ")"; } - if (elementList == nullptr) { - FML_DLOG(INFO) << "FindAccessibilityNodeInfosById elementList is null"; - return ARKUI_ACCESSIBILITY_NATIVE_RESULT_FAILED; +} + +/** + * perform scroll backward in accessibility status + */ +void OhosAccessibilityBridge::PerformScrollDownAction( + int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode) +{ + // flutter scroll down with different situations + if (flutterNode.HasAction(ACTIONS_::kScrollDown)) { + auto flutterScrollDownAction = ArkuiActionsToFlutterActions(action); + DispatchSemanticsAction(static_cast(elementId), flutterScrollDownAction, {}); + } else if (flutterNode.HasAction(ACTIONS_::kScrollRight)) { + DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kScrollRight, {}); + } else if (flutterNode.HasAction(ACTIONS_::kDecrease)) { + flutterNode.value = flutterNode.decreasedValue; + flutterNode.valueAttributes = flutterNode.decreasedValueAttributes; + + Flutter_SendAccessibilityAsyncEvent( + elementId, ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SELECTED); + DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kDecrease, {}); + } + std::string currComponetType = GetNodeComponentType(flutterNode); + if (OHOSUtils::Contains(currComponetType, SCROLL_WIDGET_NAME)) { + /** Scrolled event, sent when a scrollable component experiences a + * scroll event. 4096 */ + ArkUI_AccessibilityEventType scrollEventType1 = + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SCROLLED; + Flutter_SendAccessibilityAsyncEvent(elementId, scrollEventType1); + FML_DLOG(INFO) + << "ExecuteAccessibilityAction -> action: scroll forward(" << action + << ")" << " event: scroll forward(" << scrollEventType1 << ")"; } - // 开启无障碍导航功能 - if(elementId == -1 || elementId == 0) { - accessibilityFeatures_->SetAccessibleNavigation(true, native_shell_holder_id_); +} +/** + * perform invalid action in accessibility status + */ +void OhosAccessibilityBridge::PerformClipboardAction( + int64_t elementId, + ArkUI_Accessibility_ActionType action) +{ + if (action == ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_COPY) { + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: copy(" << action << ")"; + DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kCopy, {}); + } else if (action == ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_PASTE) { + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: paste(" << action << ")"; + DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kPaste, {}); + } else { + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: cut(" << action << ")"; + DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kCut, {}); } +} +/** + * perform invalid action in accessibility status + */ +void OhosAccessibilityBridge::PerformInvalidAction( + int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode) +{ + /** Invalid event. 0 */ + ArkUI_AccessibilityEventType invalidEventType = + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_INVALID; + Flutter_SendAccessibilityAsyncEvent(elementId, invalidEventType); + FML_DLOG(ERROR) << "ExecuteAccessibilityAction -> action: invalid(" + << action << ")" << " event: innvalid(" + << invalidEventType << ")"; +} +/** + * 设置输入框文本 + */ +void OhosAccessibilityBridge::PerformSetText( + SemanticsNodeExtent flutterNode, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments) +{ + if (OHOS_API_VERSION < 13) { return; } + auto OH_ArkUI_FindAccessibilityActionArgumentByKey = + OhosAccessibilityDDL::DLLoadGetFindActionArgs(ArkUIAccessibilityConstant::ARKUI_FIND_ACTION_ARG_BY_KEY); + CHECK_DLL_NULL_PTR(OH_ArkUI_FindAccessibilityActionArgumentByKey); + + char* newText; + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_FindAccessibilityActionArgumentByKey(actionArguments, ARKUI_ACTION_ARG_SET_TEXT, &newText)); + CHECK_NULL_PTR(newText, PerformSetText); + + auto flutterSetTextAction = ArkuiActionsToFlutterActions(action); + DispatchSemanticsAction(flutterNode.id, + flutterSetTextAction, + fml::MallocMapping::Copy(newText, strlen(newText))); + flutterNode.value = newText; + flutterNode.valueAttributes = {}; + LOGI("ExecuteAccessibilityAction -> action: set text(%{public}d), newText=%{public}s", action, newText); +} - if (OH_GetSdkApiVersion() >= 13) { - // 从elementinfolist中获取elementinfo - ArkUI_AccessibilityElementInfo* (*OH_ArkUI_AddAndGetAccessibilityElementInfo)(ArkUI_AccessibilityElementInfoList*) = - OhosAccessibilityDDL::DLLoadGetElemFunc("OH_ArkUI_AddAndGetAccessibilityElementInfo"); - if (OH_ArkUI_AddAndGetAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_AddAndGetAccessibilityElementInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityElementInfo* elementInfoFromList = - OH_ArkUI_AddAndGetAccessibilityElementInfo(elementList); - if (elementInfoFromList == nullptr) { - FML_DLOG(INFO) << "FindAccessibilityNodeInfosById elementInfoFromList is null"; - return ARKUI_ACCESSIBILITY_NATIVE_RESULT_FAILED; - } +/** + * perform select text (from base to extent) in accessibility status + */ +void OhosAccessibilityBridge::PerformSelectText( + SemanticsNodeExtent flutterNode, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments) +{ + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: select text(" << action << ")"; + auto OH_ArkUI_FindAccessibilityActionArgumentByKey = + OhosAccessibilityDDL::DLLoadGetFindActionArgs(ArkUIAccessibilityConstant::ARKUI_FIND_ACTION_ARG_BY_KEY); + CHECK_DLL_NULL_PTR(OH_ArkUI_FindAccessibilityActionArgumentByKey); + + auto flutterSelectTextAction = ArkuiActionsToFlutterActions(action); + + char* textSelectBase; + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_FindAccessibilityActionArgumentByKey( + actionArguments, ARKUI_ACTION_ARG_SELECT_TEXT_START, &textSelectBase) + ); + CHECK_NULL_PTR(textSelectBase, PerformSelectText); + + char* textSelectExtent; + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_FindAccessibilityActionArgumentByKey( + actionArguments, ARKUI_ACTION_ARG_SELECT_TEXT_END, &textSelectExtent) + ); + CHECK_NULL_PTR(textSelectExtent, PerformSelectText); + + std::map selectionMap; + bool hasSelected = actionArguments != nullptr && + textSelectBase != nullptr && + textSelectExtent != nullptr; + if (hasSelected) { + int32_t base; + int32_t extent; + OHOSUtils::CharArrayToInt32(textSelectBase, base); + OHOSUtils::CharArrayToInt32(textSelectBase, extent); + selectionMap.insert({ARKUI_ACTION_ARG_SELECT_TEXT_START, base}); + selectionMap.insert({ARKUI_ACTION_ARG_SELECT_TEXT_END, extent}); + } else { + selectionMap.insert({ARKUI_ACTION_ARG_SELECT_TEXT_START, flutterNode.textSelectionBase}); + selectionMap.insert({ARKUI_ACTION_ARG_SELECT_TEXT_END, flutterNode.textSelectionExtent}); + } + // serialize map to byte vector + std::vector encodedData = OHOSUtils::SerializeStringIntMap(selectionMap); + DispatchSemanticsAction(flutterNode.id, + flutterSelectTextAction, + fml::MallocMapping::Copy(encodedData.data(), encodedData.size() * sizeof(uint8_t))); +} - // 过滤非当前屏幕显示的语义节点创建、配置,防止溢出屏幕坐标绘制bug以及优化性能开销 - auto flutterNode = GetFlutterSemanticsNode(static_cast(elementId)); +/** + * perform cursor position setting in accessibility status + */ +void OhosAccessibilityBridge::PerformSetCursorPosition( + SemanticsNodeExtent flutterNode, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments) +{ + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: set cursor position (" << action << ")"; + return; +} - if (mode == ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_CURRENT) { - /** Search for current nodes. (mode = 0) */ - BuildArkUISemanticsTree(elementId, elementInfoFromList, elementList); - } else if (mode ==ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_PREDECESSORS) { - /** Search for parent nodes. (mode = 1) */ - if (IsNodeVisible(flutterNode)) { - FlutterNodeToElementInfoById(elementInfoFromList, elementId); - } - } else if (mode ==ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_SIBLINGS) { - /** Search for sibling nodes. (mode = 2) */ - if (IsNodeVisible(flutterNode)) { - FlutterNodeToElementInfoById(elementInfoFromList, elementId); - } - } else if (mode ==ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_CHILDREN) { - /** Search for child nodes at the next level. (mode = 4) */ - if (IsNodeVisible(flutterNode)) { - FlutterNodeToElementInfoById(elementInfoFromList, elementId); - } - } else if (mode ==ArkUI_AccessibilitySearchMode::ARKUI_ACCESSIBILITY_NATIVE_SEARCH_MODE_PREFETCH_RECURSIVE_CHILDREN) { - /** Search for all child nodes. (mode = 8) */ - BuildArkUISemanticsTree(elementId, elementInfoFromList, elementList); - } else { - FlutterNodeToElementInfoById(elementInfoFromList, elementId); - } - } - FML_DLOG(INFO) << "--- FindAccessibilityNodeInfosById is end ---"; - return ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL; +/** + * perform custom action in accessibility status + */ +void OhosAccessibilityBridge::PerformCustomAction( + SemanticsNodeExtent flutterNode, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments) +{ + FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: custom action (" << action << ")"; + DispatchSemanticsAction(flutterNode.id, ACTIONS_::kCustomAction, {}); + return; } /** - * 解析flutter语义动作,并通过NativAccessibilityChannel分发 + * perform show on screen action in accessibility status */ -void OhosAccessibilityBridge::DispatchSemanticsAction( - int32_t id, - flutter::SemanticsAction action, - fml::MallocMapping args) +void OhosAccessibilityBridge::PerformShowOnScreenAction(SemanticsNodeExtent flutterNode) { - nativeAccessibilityChannel_->DispatchSemanticsAction(native_shell_holder_id_, - id, - action, - fml::MallocMapping()); + if (!IsNodeShowOnScreen(flutterNode)) { + DispatchSemanticsAction(flutterNode.id, ACTIONS_::kShowOnScreen, {}); + } } /** @@ -1591,217 +1398,95 @@ int32_t OhosAccessibilityBridge::ExecuteAccessibilityAction( int32_t requestId) { FML_DLOG(INFO) << "ExecuteAccessibilityAction input-params-> elementId=" - << elementId << " action=" << action - << " requestId=" << requestId - << " *actionArguments=" << actionArguments; + << elementId << " action=" << action; + CHECK_NULL_PTR_WITH_RET(actionArguments, ExecuteAccessibilityAction); - if (actionArguments == nullptr) { - FML_DLOG(ERROR) << "OhosAccessibilityBridge::ExecuteAccessibilityAction " - "actionArguments = null"; - return ARKUI_ACCESSIBILITY_NATIVE_RESULT_FAILED; - } + AccessibiltiyChangesWithXComponentId(); // 获取当前elementid对应的flutter语义节点 auto flutterNode = GetFlutterSemanticsNode(static_cast(elementId)); + if (!g_flutterSemanticsTree.count(flutterNode.id)) { + LOGE("ExecuteAccessibilityAction: GetFlutterSemanticsNode id=%{public}ld is null", elementId); + } + + /** + * 将被遮挡的flutter节点显示在屏幕上 + * @NOTE: arkui无障碍缺少showOnScreen动作 + */ + PerformShowOnScreenAction(flutterNode); // 根据当前elementid和无障碍动作类型,发送无障碍事件 switch (action) { /** Response to a click. 16 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK: { - /** Click event, sent after the UI component responds. 1 */ - auto clickEventType = ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_CLICKED; - Flutter_SendAccessibilityAsyncEvent(elementId, clickEventType); - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: click(" << action - << ")" << " event: click(" << clickEventType << ")"; - // 解析arkui的屏幕点击 -> flutter对应节点的屏幕点击 - auto flutterTapAction = ArkuiActionsToFlutterActions(action); - DispatchSemanticsAction(static_cast(elementId), flutterTapAction, - {}); + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK: + PerformClickAction(elementId, action, flutterNode); break; - } + /** Response to a long click. 32 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_LONG_CLICK: { - /** Long click event, sent after the UI component responds. 2 */ - auto longClickEventType = ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_LONG_CLICKED; - Flutter_SendAccessibilityAsyncEvent(elementId, longClickEventType); - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: longclick(" - << action << ")" << " event: longclick(" - << longClickEventType << ")"; - // 解析arkui的屏幕动作 -> flutter对应节点的屏幕动作 - auto flutterLongPressAction = ArkuiActionsToFlutterActions(action); - DispatchSemanticsAction(static_cast(elementId), - flutterLongPressAction, {}); + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_LONG_CLICK: + PerformLongClickAction(elementId, action, flutterNode); break; - } + /** Accessibility focus acquisition. 64 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS: { - // 解析arkui的获焦 -> flutter对应节点的获焦 - auto flutterGainFocusAction = ArkuiActionsToFlutterActions(action); - DispatchSemanticsAction(static_cast(elementId), - flutterGainFocusAction, {}); - // Accessibility focus event, sent after the UI component responds. 32768 - auto focusEventType = ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ACCESSIBILITY_FOCUSED; - Flutter_SendAccessibilityAsyncEvent(elementId, focusEventType); - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: focus(" << action - << ")" << " event: focus(" << focusEventType << ")"; - if (flutterNode.HasAction(ACTIONS_::kIncrease) || - flutterNode.HasAction(ACTIONS_::kDecrease)) { - Flutter_SendAccessibilityAsyncEvent( - elementId, ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SELECTED); - } + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS: + PerformGainFocusnAction(elementId, action, flutterNode); break; - } + /** Accessibility focus clearance. 128 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS: { - // 解析arkui的失焦 -> flutter对应节点的失焦 - auto flutterLoseFocusAction = ArkuiActionsToFlutterActions(action); - DispatchSemanticsAction(static_cast(elementId), - flutterLoseFocusAction, {}); - /** Accessibility focus cleared event, sent after the UI component - * responds. 65536 */ - auto clearFocusEventType = ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ACCESSIBILITY_FOCUS_CLEARED; - Flutter_SendAccessibilityAsyncEvent(elementId, clearFocusEventType); - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: clearfocus(" - << action << ")" << " event: clearfocus(" - << clearFocusEventType << ")"; + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS: + PerformClearFocusAction(elementId, action, flutterNode); break; - } + /** Forward scroll action. 256 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_FORWARD: { - // flutter scroll forward with different situations - if (flutterNode.HasAction(ACTIONS_::kScrollUp)) { - auto flutterScrollUpAction = ArkuiActionsToFlutterActions(action); - DispatchSemanticsAction(static_cast(elementId), - flutterScrollUpAction, {}); - } else if (flutterNode.HasAction(ACTIONS_::kScrollLeft)) { - DispatchSemanticsAction(static_cast(elementId), - ACTIONS_::kScrollLeft, {}); - } else if (flutterNode.HasAction(ACTIONS_::kIncrease)) { - flutterNode.value = flutterNode.increasedValue; - flutterNode.valueAttributes = flutterNode.increasedValueAttributes; - - Flutter_SendAccessibilityAsyncEvent( - elementId, ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SELECTED); - DispatchSemanticsAction(static_cast(elementId), - ACTIONS_::kIncrease, {}); - } else { - } - std::string currComponetType = GetNodeComponentType(flutterNode); - if (currComponetType == "ListView") { - /** Scrolled event, sent when a scrollable component experiences a - * scroll event. 4096 */ - ArkUI_AccessibilityEventType scrollEventType1 = - ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SCROLLED; - Flutter_SendAccessibilityAsyncEvent(elementId, scrollEventType1); - FML_DLOG(INFO) - << "ExecuteAccessibilityAction -> action: scroll forward(" << action - << ")" << " event: scroll forward(" << scrollEventType1 << ")"; - } + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_FORWARD: + PerformScrollUpAction(elementId, action, flutterNode); break; - } + /** Backward scroll action. 512 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_BACKWARD: { - // flutter scroll down with different situations - if (flutterNode.HasAction(ACTIONS_::kScrollDown)) { - auto flutterScrollDownAction = ArkuiActionsToFlutterActions(action); - DispatchSemanticsAction(static_cast(elementId), - flutterScrollDownAction, {}); - } else if (flutterNode.HasAction(ACTIONS_::kScrollRight)) { - DispatchSemanticsAction(static_cast(elementId), - ACTIONS_::kScrollRight, {}); - } else if (flutterNode.HasAction(ACTIONS_::kDecrease)) { - flutterNode.value = flutterNode.decreasedValue; - flutterNode.valueAttributes = flutterNode.decreasedValueAttributes; - - Flutter_SendAccessibilityAsyncEvent( - elementId, ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SELECTED); - DispatchSemanticsAction(static_cast(elementId), - ACTIONS_::kDecrease, {}); - } else { - } - std::string currComponetType = GetNodeComponentType(flutterNode); - if (currComponetType == "ListView") { - /** Scrolled event, sent when a scrollable component experiences a - * scroll event. 4096 */ - ArkUI_AccessibilityEventType scrollBackwardEventType = - ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_SCROLLED; - Flutter_SendAccessibilityAsyncEvent(elementId, scrollBackwardEventType); - FML_DLOG(INFO) - << "ExecuteAccessibilityAction -> action: scroll backward(" - << action << ")" << " event: scroll backward(" - << scrollBackwardEventType << ")"; - } + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_BACKWARD: + PerformScrollDownAction(elementId, action, flutterNode); break; - } + /** Copy action for text content. 1024 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_COPY: { - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: copy(" << action - << ")"; - DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kCopy, {}); + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_COPY: + PerformClipboardAction(elementId, action); break; - } + /** Paste action for text content. 2048 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_PASTE: { - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: paste(" << action - << ")"; - DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kPaste, {}); + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_PASTE: + PerformClipboardAction(elementId, action); break; - } + /** Cut action for text content. 4096 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CUT: { - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: cut(" << action << ")"; - DispatchSemanticsAction(static_cast(elementId), ACTIONS_::kCut, {}); + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CUT: + PerformClipboardAction(elementId, action); break; - } + /** Text selection action, requiring the setting of selectTextBegin, * TextEnd, and TextInForward parameters to select a text * segment in the text box. 8192 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SELECT_TEXT: { - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: select text(" - << action << ")"; - // 输入框文本选择操作 + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SELECT_TEXT: PerformSelectText(flutterNode, action, actionArguments); break; - } + /** Text content setting action. 16384 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_TEXT: { - FML_DLOG(INFO) << "ExecuteAccessibilityAction -> action: set text(" - << action << ")"; - // 输入框设置文本 + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_TEXT: PerformSetText(flutterNode, action, actionArguments); break; - } + /** Cursor position setting action. 1048576 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_CURSOR_POSITION: { - FML_DLOG(INFO) - << "ExecuteAccessibilityAction -> action: set cursor position(" - << action << ")"; + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_CURSOR_POSITION: + PerformSetCursorPosition(flutterNode, action, actionArguments); break; - } + /** Invalid action. 0 */ - case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_INVALID: { - /** Invalid event. 0 */ - ArkUI_AccessibilityEventType invalidEventType = - ArkUI_AccessibilityEventType:: - ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_INVALID; - Flutter_SendAccessibilityAsyncEvent(elementId, invalidEventType); - FML_DLOG(ERROR) << "ExecuteAccessibilityAction -> action: invalid(" - << action << ")" << " event: innvalid(" - << invalidEventType << ")"; + case ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_INVALID: + PerformInvalidAction(elementId, action, flutterNode); break; - } - default: { + + default: /** custom semantics action */ - } + PerformCustomAction(flutterNode, action, actionArguments); } FML_DLOG(INFO) << "--- ExecuteAccessibilityAction is end ---"; return ARKUI_ACCESSIBILITY_NATIVE_RESULT_SUCCESSFUL; @@ -1891,9 +1576,6 @@ flutter::SemanticsAction OhosAccessibilityBridge::ArkuiActionsToFlutterActions( ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS: return ACTIONS_::kDidLoseAccessibilityFocus; - // Text selection action, requiring the setting of selectTextBegin, - // TextEnd, and TextInForward parameters to select a text - // segment in the text box. */ case ArkUI_Accessibility_ActionType:: ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SELECT_TEXT: return ACTIONS_::kSetSelection; @@ -1903,218 +1585,199 @@ flutter::SemanticsAction OhosAccessibilityBridge::ArkuiActionsToFlutterActions( return ACTIONS_::kSetText; default: - // might not match to the valid action in arkui + // might not match to the valid action in arkui return ACTIONS_::kCustomAction; } } /** - * 自定义无障碍异步事件发送 + * flutter发送无障碍自定义主动播报事件 */ -void OhosAccessibilityBridge::Flutter_SendAccessibilityAsyncEvent( - int64_t elementId, +void OhosAccessibilityBridge::Flutter_SendAccessibilityAnnounceEvent( + std::unique_ptr& message, ArkUI_AccessibilityEventType eventType) { - if (provider_ == nullptr) { - FML_DLOG(ERROR) << "Flutter_SendAccessibilityAsyncEvent " - "AccessibilityProvider = nullptr"; - return; - } - if (OH_GetSdkApiVersion() >= 13) { - // 1.创建eventInfo对象 - ArkUI_AccessibilityEventInfo* (*OH_ArkUI_CreateAccessibilityEventInfo)(void) = - OhosAccessibilityDDL::DLLoadCreateEventInfoFunc("OH_ArkUI_CreateAccessibilityEventInfo"); - if (OH_ArkUI_CreateAccessibilityEventInfo == nullptr) { - LOGE("OH_ArkUI_CreateAccessibilityEventInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityEventInfo* eventInfo = OH_ArkUI_CreateAccessibilityEventInfo(); - if (eventInfo == nullptr) { - FML_DLOG(ERROR) << "Flutter_SendAccessibilityAsyncEvent " - "OH_ArkUI_CreateAccessibilityEventInfo eventInfo = null"; - return; - } - - // 2.创建的elementinfo并根据对应id的flutternode进行属性初始化 - ArkUI_AccessibilityElementInfo* (*OH_ArkUI_CreateAccessibilityElementInfo)(void) = - OhosAccessibilityDDL::DLLoadCreateElemInfoFunc("OH_ArkUI_CreateAccessibilityElementInfo"); - if (OH_ArkUI_CreateAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_CreateAccessibilityElementInfo is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityElementInfo* _elementInfo = OH_ArkUI_CreateAccessibilityElementInfo(); - FlutterNodeToElementInfoById(_elementInfo, elementId); - // 若为获焦事件,则设置当前elementinfo获焦 - int32_t (*OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused)(ArkUI_AccessibilityElementInfo*, bool) = - OhosAccessibilityDDL::DLLoadSetElemBoolFunc("OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused"); - if (OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused == nullptr) { - LOGE("OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused is null, %{public}s", dlerror()); - } - if (eventType == ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ACCESSIBILITY_FOCUSED) { - ARKUI_ACCESSIBILITY_CALL_CHECK( - OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused(_elementInfo, true) - ); - } - - // 3.设置发送事件,如配置获焦、失焦、点击、滑动事件 - int32_t (*OH_ArkUI_AccessibilityEventSetEventType)(ArkUI_AccessibilityEventInfo*, ArkUI_AccessibilityEventType) = - OhosAccessibilityDDL::DLLoadSetEventFunc("OH_ArkUI_AccessibilityEventSetEventType"); - if (OH_ArkUI_AccessibilityEventSetEventType == nullptr) { - LOGE("OH_ArkUI_AccessibilityEventSetEventType is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityEventSetEventType(eventInfo, eventType)); - - // 4.将eventinfo事件和当前elementinfo进行绑定 - int32_t (*OH_ArkUI_AccessibilityEventSetElementInfo)(ArkUI_AccessibilityEventInfo*, ArkUI_AccessibilityElementInfo*) = - OhosAccessibilityDDL::DLLoadSetEventElemFunc("OH_ArkUI_AccessibilityEventSetElementInfo"); - if (OH_ArkUI_AccessibilityEventSetElementInfo == nullptr) { - LOGE("OH_ArkUI_AccessibilityEventSetElementInfo is null, %{public}s", dlerror()); - } - ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityEventSetElementInfo(eventInfo, _elementInfo)); - - // 5.调用接口发送到ohos侧 - auto callback = [](int32_t errorCode) { - FML_DLOG(INFO) - << "Flutter_SendAccessibilityAsyncEvent callback-> errorCode =" - << errorCode; - }; - - // 6.发送event到OH侧 - void (*OH_ArkUI_SendAccessibilityAsyncEvent)(ArkUI_AccessibilityProvider*, ArkUI_AccessibilityEventInfo*, void (*callback)(int32_t)) = - OhosAccessibilityDDL::DLLoadSendAsyncEventFunc("OH_ArkUI_SendAccessibilityAsyncEvent"); - if (OH_ArkUI_SendAccessibilityAsyncEvent == nullptr) { - LOGE("OH_ArkUI_SendAccessibilityAsyncEvent is null, %{public}s", dlerror()); - } - OH_ArkUI_SendAccessibilityAsyncEvent(provider_, eventInfo, callback); - - // 7.销毁新创建的elementinfo, eventinfo - void (*OH_ArkUI_DestoryAccessibilityElementInfo)(ArkUI_AccessibilityElementInfo*) = - OhosAccessibilityDDL::DLLoadDestroyElemFunc("OH_ArkUI_DestoryAccessibilityElementInfo"); - if (OH_ArkUI_DestoryAccessibilityElementInfo == nullptr) { - LOGE("OH_ArkUI_DestoryAccessibilityElementInfo is null, %{public}s", dlerror()); - } - OH_ArkUI_DestoryAccessibilityElementInfo(_elementInfo); - _elementInfo = nullptr; - - void (*OH_ArkUI_DestoryAccessibilityEventInfo)(ArkUI_AccessibilityEventInfo*) = - OhosAccessibilityDDL::DLLoadDestroyEventFunc("OH_ArkUI_DestoryAccessibilityEventInfo"); - if (OH_ArkUI_DestoryAccessibilityEventInfo == nullptr) { - LOGE("OH_ArkUI_DestoryAccessibilityEventInfo is null, %{public}s", dlerror()); - } - OH_ArkUI_DestoryAccessibilityEventInfo(eventInfo); - eventInfo = nullptr; - } - - FML_DLOG(INFO) << "OhosAccessibilityBridge::Flutter_SendAccessibilityAsyncEvent is end"; - return; + if (OHOS_API_VERSION < 13) { return; } + AccessibiltiyChangesWithXComponentId(); + std::lock_guard lock(XComponentAdapter::GetInstance()->mutex_); + auto provider_ = XComponentAdapter::GetInstance()->GetAccessibilityProvider(xcomponentId_); + CHECK_NULL_PTR_RET_VOID(provider_, Flutter_SendAccessibilityAnnounceEvent); + + // 创建并设置屏幕朗读事件 + auto OH_ArkUI_CreateAccessibilityEventInfo = + OhosAccessibilityDDL::DLLoadCreateEventInfoFunc(ArkUIAccessibilityConstant::ARKUI_CREATE_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_CreateAccessibilityEventInfo); + auto* announceEventInfo = OH_ArkUI_CreateAccessibilityEventInfo(); + + auto OH_ArkUI_AccessibilityEventSetEventType = + OhosAccessibilityDDL::DLLoadSetEventFunc(ArkUIAccessibilityConstant::ARKUI_SET_EVENT_TYPE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityEventSetEventType); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityEventSetEventType( + announceEventInfo, + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ANNOUNCE_FOR_ACCESSIBILITY)); + + auto OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility = + OhosAccessibilityDDL::DLLoadSetEventStringFunc(ArkUIAccessibilityConstant::ARKUI_SET_ANNOUNCED_TEXT); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility( + announceEventInfo, message.get())); + FML_DLOG(INFO) << ("announce -> message: ") << (message.get()); + + auto callback = [](int32_t errorCode) { + FML_DLOG(WARNING) << "announce callback-> errorCode =" << errorCode; + }; + + auto OH_ArkUI_SendAccessibilityAsyncEvent = + OhosAccessibilityDDL::DLLoadSendAsyncEventFunc(ArkUIAccessibilityConstant::ARKUI_SEND_A11Y_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_SendAccessibilityAsyncEvent); + OH_ArkUI_SendAccessibilityAsyncEvent(provider_, announceEventInfo, callback); + + auto OH_ArkUI_DestoryAccessibilityEventInfo = + OhosAccessibilityDDL::DLLoadDestroyEventFunc(ArkUIAccessibilityConstant::ARKUI_DESTORY_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_DestoryAccessibilityEventInfo); + OH_ArkUI_DestoryAccessibilityEventInfo(announceEventInfo); + announceEventInfo = nullptr; } /** - * 判断当前语义节点是否获焦 + * 自定义无障碍异步事件发送 */ -bool OhosAccessibilityBridge::IsNodeFocusable( - const flutter::SemanticsNode& node) +void OhosAccessibilityBridge::Flutter_SendAccessibilityAsyncEvent( + int64_t elementId, + ArkUI_AccessibilityEventType eventType) { - if (node.HasFlag(FLAGS_::kScopesRoute)) { - return false; - } - if (node.HasFlag(FLAGS_::kIsFocusable)) { - return true; - } - // Always consider platform views focusable. - if (node.IsPlatformViewNode()) { - return true; - } - // Always consider actionable nodes focusable. - if (node.actions != 0) { - return true; - } - if ((node.flags & FOCUSABLE_FLAGS) != 0) { - return true; - } - if ((node.actions & ~FOCUSABLE_FLAGS) != 0) { - return true; - } - // Consider text nodes focusable. - return !node.label.empty() || !node.value.empty() || !node.hint.empty(); + if (OHOS_API_VERSION < 13) { return; } + AccessibiltiyChangesWithXComponentId(); + std::lock_guard lock(XComponentAdapter::GetInstance()->mutex_); + auto provider_ = XComponentAdapter::GetInstance()->GetAccessibilityProvider(xcomponentId_); + CHECK_NULL_PTR_RET_VOID(provider_, Flutter_SendAccessibilityAsyncEvent); + + // 创建eventInfo对象 + auto OH_ArkUI_CreateAccessibilityEventInfo = + OhosAccessibilityDDL::DLLoadCreateEventInfoFunc(ArkUIAccessibilityConstant::ARKUI_CREATE_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_CreateAccessibilityEventInfo); + auto* eventInfo = OH_ArkUI_CreateAccessibilityEventInfo(); + CHECK_NULL_PTR(eventInfo, Flutter_SendAccessibilityAsyncEvent); + + // 创建的elementinfo并根据对应id的flutternode进行属性初始化 + auto OH_ArkUI_CreateAccessibilityElementInfo = + OhosAccessibilityDDL::DLLoadCreateElemInfoFunc(ArkUIAccessibilityConstant::ARKUI_CREATE_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_CreateAccessibilityElementInfo); + ArkUI_AccessibilityElementInfo* _elementInfo = OH_ArkUI_CreateAccessibilityElementInfo(); + FlutterSetElementInfoProperties(_elementInfo, elementId); + + // 将eventinfo事件和当前elementinfo进行绑定 + auto OH_ArkUI_AccessibilityEventSetElementInfo = + OhosAccessibilityDDL::DLLoadSetEventElemFunc(ArkUIAccessibilityConstant::ARKUI_EVENT_SET_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityEventSetElementInfo); + ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityEventSetElementInfo(eventInfo, _elementInfo)); + + // 设置发送事件,如配置获焦、失焦、点击、滑动事件 + auto OH_ArkUI_AccessibilityEventSetEventType = + OhosAccessibilityDDL::DLLoadSetEventFunc(ArkUIAccessibilityConstant::ARKUI_SET_EVENT_TYPE); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityEventSetEventType); + ARKUI_ACCESSIBILITY_CALL_CHECK(OH_ArkUI_AccessibilityEventSetEventType(eventInfo, eventType)); + + // 调用接口发送到ohos侧 + auto callback = [](int32_t errorCode) { + FML_DLOG(INFO) + << "Flutter_SendAccessibilityAsyncEvent callback-> errorCode =" + << errorCode; + }; + + // 发送event到OH侧 + auto OH_ArkUI_SendAccessibilityAsyncEvent = + OhosAccessibilityDDL::DLLoadSendAsyncEventFunc(ArkUIAccessibilityConstant::ARKUI_SEND_A11Y_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_SendAccessibilityAsyncEvent); + OH_ArkUI_SendAccessibilityAsyncEvent(provider_, eventInfo, callback); + + // 销毁新创建的elementinfo, eventinfo + auto OH_ArkUI_DestoryAccessibilityElementInfo = + OhosAccessibilityDDL::DLLoadDestroyElemFunc(ArkUIAccessibilityConstant::ARKUI_DESTORY_NODE); + CHECK_DLL_NULL_PTR(OH_ArkUI_DestoryAccessibilityElementInfo); + OH_ArkUI_DestoryAccessibilityElementInfo(_elementInfo); + _elementInfo = nullptr; + + auto OH_ArkUI_DestoryAccessibilityEventInfo = + OhosAccessibilityDDL::DLLoadDestroyEventFunc(ArkUIAccessibilityConstant::ARKUI_DESTORY_EVENT); + CHECK_DLL_NULL_PTR(OH_ArkUI_DestoryAccessibilityEventInfo); + OH_ArkUI_DestoryAccessibilityEventInfo(eventInfo); + eventInfo = nullptr; + + FML_DLOG(INFO) << "OhosAccessibilityBridge::Flutter_SendAccessibilityAsyncEvent is end"; + return; } -void OhosAccessibilityBridge::PerformSetText( - flutter::SemanticsNode flutterNode, - ArkUI_Accessibility_ActionType action, - ArkUI_AccessibilityActionArguments* actionArguments) {} - -void OhosAccessibilityBridge::PerformSelectText( - flutter::SemanticsNode flutterNode, - ArkUI_Accessibility_ActionType action, - ArkUI_AccessibilityActionArguments* actionArguments) {} - /** * 获取当前flutter节点的组件类型,并映射为arkui组件 */ std::string OhosAccessibilityBridge::GetNodeComponentType( - const flutter::SemanticsNode& node) + const SemanticsNodeExtent& node) { if (node.HasFlag(FLAGS_::kIsButton)) { - return "Button"; + return BUTTON_WIDGET_NAME; } if (node.HasFlag(FLAGS_::kIsTextField)) { - return "TextField"; + return EDIT_TEXT_WIDGET_NAME; } if (node.HasFlag(FLAGS_::kIsMultiline)) { - return "TextArea"; + return EDIT_MULTILINE_TEXT_WIDGET_NAME; } if (node.HasFlag(FLAGS_::kIsLink)) { - return "Link"; + return LINK_WIDGET_NAME; } if (node.HasFlag(FLAGS_::kIsSlider) || node.HasAction(ACTIONS_::kIncrease) || node.HasAction(ACTIONS_::kDecrease)) { - return "Slider"; + return SLIDER_WIDGET_NAME; } if (node.HasFlag(FLAGS_::kIsHeader)) { - return "Header"; + return HEADER_WIDGET_NAME; } if (node.HasFlag(FLAGS_::kIsImage)) { - return "Image"; + return IMAGE_WIDGET_NAME; } if (node.HasFlag(FLAGS_::kHasCheckedState)) { if (node.HasFlag(FLAGS_::kIsInMutuallyExclusiveGroup)) { // arkui没有RadioButton,这里透传为RadioButton - return "RadioButton"; + return RADIO_BUTTON_WIDGET_NAME; } else { - return "Checkbox"; + return CHECK_BOX_WIDGET_NAME; } } if (node.HasFlag(FLAGS_::kHasToggledState)) { - return "Switch"; + return SWITCH_WIDGET_NAME; } if (node.HasAction(ACTIONS_::kIncrease) || node.HasAction(ACTIONS_::kDecrease)) { - return "SeekBar"; + return SEEKBAR_WIDGET_NAME; } if (node.HasFlag(FLAGS_::kHasImplicitScrolling)) { if (node.HasAction(ACTIONS_::kScrollLeft) || node.HasAction(ACTIONS_::kScrollRight)) { - return "HorizontalScrollView"; + return SCROLL_WIDGET_NAME; } else { - return "ScrollView"; + return SCROLL_WIDGET_NAME; } } if ((!node.label.empty() || !node.tooltip.empty() || !node.hint.empty())) { - return "Text"; + return TEXT_WIDGET_NAME; } - return "Widget"; + return OTHER_WIDGET_NAME; } /** * 判断当前节点是否为textfield文本框 */ -bool OhosAccessibilityBridge::IsTextField(flutter::SemanticsNode flutterNode) +bool OhosAccessibilityBridge::IsTextField(SemanticsNodeExtent flutterNode) { return flutterNode.HasFlag(FLAGS_::kIsTextField); } /** * 判断当前节点是否为滑动条slider类型 */ -bool OhosAccessibilityBridge::IsSlider(flutter::SemanticsNode flutterNode) +bool OhosAccessibilityBridge::IsSlider(SemanticsNodeExtent flutterNode) { return flutterNode.HasFlag(FLAGS_::kIsSlider); } @@ -2122,34 +1785,23 @@ bool OhosAccessibilityBridge::IsSlider(flutter::SemanticsNode flutterNode) * 判断当前flutter节点组件是否可点击 */ bool OhosAccessibilityBridge::IsNodeClickable( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return flutterNode.HasAction(ACTIONS_::kTap); - flutterNode.HasFlag(FLAGS_::kHasCheckedState) || - flutterNode.HasFlag(FLAGS_::kIsButton) || - flutterNode.HasFlag(FLAGS_::kIsTextField) || - flutterNode.HasFlag(FLAGS_::kIsImage) || - flutterNode.HasFlag(FLAGS_::kIsLiveRegion) || - flutterNode.HasFlag(FLAGS_::kIsMultiline) || - flutterNode.HasFlag(FLAGS_::kIsLink) || - flutterNode.HasFlag(FLAGS_::kIsSlider) || - flutterNode.HasFlag(FLAGS_::kIsKeyboardKey) || - flutterNode.HasFlag(FLAGS_::kHasToggledState) || - flutterNode.HasFlag(FLAGS_::kHasImplicitScrolling); } /** * 判断当前flutter节点组件是否可显示 */ bool OhosAccessibilityBridge::IsNodeVisible( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { - return flutterNode.HasFlag(FLAGS_::kIsHidden) ? false : true; + return !flutterNode.HasFlag(FLAGS_::kIsHidden); } /** * 判断当前flutter节点组件是否具备checkable属性 */ bool OhosAccessibilityBridge::IsNodeCheckable( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return flutterNode.HasFlag(FLAGS_::kHasCheckedState) || flutterNode.HasFlag(FLAGS_::kHasToggledState); @@ -2158,7 +1810,7 @@ bool OhosAccessibilityBridge::IsNodeCheckable( * 判断当前flutter节点组件是否checked/unchecked(checkbox、radio button) */ bool OhosAccessibilityBridge::IsNodeChecked( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return flutterNode.HasFlag(FLAGS_::kIsChecked) || flutterNode.HasFlag(FLAGS_::kIsToggled); @@ -2167,7 +1819,7 @@ bool OhosAccessibilityBridge::IsNodeChecked( * 判断当前flutter节点组件是否选中 */ bool OhosAccessibilityBridge::IsNodeSelected( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return flutterNode.HasFlag(FLAGS_::kIsSelected); } @@ -2175,7 +1827,7 @@ bool OhosAccessibilityBridge::IsNodeSelected( * 判断当前flutter节点组件是否为密码输入框 */ bool OhosAccessibilityBridge::IsNodePassword( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return flutterNode.HasFlag(FLAGS_::kIsTextField) && flutterNode.HasFlag(FLAGS_::kIsObscured); @@ -2184,7 +1836,7 @@ bool OhosAccessibilityBridge::IsNodePassword( * 判断当前flutter节点组件是否支持长按功能 */ bool OhosAccessibilityBridge::IsNodeHasLongPress( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return flutterNode.HasAction(ACTIONS_::kLongPress); } @@ -2192,24 +1844,81 @@ bool OhosAccessibilityBridge::IsNodeHasLongPress( * 判断当前flutter节点是否enabled */ bool OhosAccessibilityBridge::IsNodeEnabled( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return !flutterNode.HasFlag(FLAGS_::kHasEnabledState) || flutterNode.HasFlag(FLAGS_::kIsEnabled); } +/** + * 判断当前flutter节点是否在当前屏幕上显示 + */ +bool OhosAccessibilityBridge::IsNodeShowOnScreen(SemanticsNodeExtent flutterNode) +{ + return flutterNode.HasAction(ACTIONS_::kShowOnScreen); +} /** * 判断当前节点是否已经滑动 */ bool OhosAccessibilityBridge::HasScrolled( - const flutter::SemanticsNode& flutterNode) + const SemanticsNodeExtent& flutterNode) +{ + return flutterNode.scrollPosition != std::nan("") && + flutterNode.previousScrollPosition != std::nan("") && + flutterNode.previousScrollPosition != flutterNode.scrollPosition; +} +/** + * 判断当前节点是否改变标签文本 + */ +bool OhosAccessibilityBridge::HasChangedLabel(const SemanticsNodeExtent& flutterNode) +{ + if (flutterNode.label.empty() && flutterNode.previousLabel.empty()) { + return false; + } + return flutterNode.label.empty() || + flutterNode.previousLabel.empty() || + flutterNode.label != flutterNode.previousLabel; +} +/** + * 判断当前语义节点是否可获焦 + */ +bool OhosAccessibilityBridge::IsNodeFocusable( + const SemanticsNodeExtent& node) +{ + if (node.HasFlag(FLAGS_::kScopesRoute)) { + return false; + } + if (node.HasFlag(FLAGS_::kIsFocusable)) { + return true; + } + // Always consider platform views focusable. + if (node.IsPlatformViewNode()) { + return true; + } + // Always consider actionable nodes focusable. + if (node.actions != 0) { + return true; + } + if ((node.flags & FOCUSABLE_FLAGS) != 0) { + return true; + } + if ((node.actions & ~FOCUSABLE_FLAGS) != 0) { + return true; + } + // Consider text nodes focusable. + return !node.label.empty() || !node.value.empty() || !node.hint.empty(); +} +/** + * 判断当前flutter节点是否获焦 + */ +bool OhosAccessibilityBridge::IsNodeFocused(const SemanticsNodeExtent& flutterNode) { - return flutterNode.scrollPosition != std::nan(""); + return flutterNode.HasFlag(FLAGS_::kIsFocused); } /** * 判断是否可滑动 */ bool OhosAccessibilityBridge::IsNodeScrollable( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return flutterNode.HasAction(ACTIONS_::kScrollLeft) || flutterNode.HasAction(ACTIONS_::kScrollRight) || @@ -2220,14 +1929,14 @@ bool OhosAccessibilityBridge::IsNodeScrollable( * 判断当前节点组件是否是滑动组件,如: listview, gridview等 */ bool OhosAccessibilityBridge::IsScrollableWidget( - flutter::SemanticsNode flutterNode) + SemanticsNodeExtent flutterNode) { return flutterNode.HasFlag(FLAGS_::kHasImplicitScrolling); } void OhosAccessibilityBridge::AddRouteNodes( - std::vector edges, - flutter::SemanticsNode node) + std::vector edges, + SemanticsNodeExtent node) { if (node.HasFlag(FLAGS_::kScopesRoute)) { edges.emplace_back(node); @@ -2238,7 +1947,7 @@ void OhosAccessibilityBridge::AddRouteNodes( } } -std::string OhosAccessibilityBridge::GetRouteName(flutter::SemanticsNode node) +std::string OhosAccessibilityBridge::GetRouteName(SemanticsNodeExtent node) { if (node.HasFlag(FLAGS_::kNamesRoute) && !node.label.empty()) { return node.label; @@ -2253,7 +1962,7 @@ std::string OhosAccessibilityBridge::GetRouteName(flutter::SemanticsNode node) return ""; } -void OhosAccessibilityBridge::onWindowNameChange(flutter::SemanticsNode route) +void OhosAccessibilityBridge::OnWindowNameChange(SemanticsNodeExtent route) { std::string routeName = GetRouteName(route); if (routeName.empty()) { @@ -2261,11 +1970,12 @@ void OhosAccessibilityBridge::onWindowNameChange(flutter::SemanticsNode route) } Flutter_SendAccessibilityAsyncEvent( static_cast(route.id), - ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_CONTENT_UPDATE); + ArkUI_AccessibilityEventType:: + ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_PAGE_CONTENT_UPDATE); } -void OhosAccessibilityBridge::removeSemanticsNode( - flutter::SemanticsNode nodeToBeRemoved) +void OhosAccessibilityBridge::RemoveSemanticsNode( + SemanticsNodeExtent nodeToBeRemoved) { if (!g_flutterSemanticsTree.size()) { FML_DLOG(ERROR) << "OhosAccessibilityBridge::removeSemanticsNode -> " @@ -2280,7 +1990,7 @@ void OhosAccessibilityBridge::removeSemanticsNode( for (auto it = g_parentChildIdVec.begin(); it != g_parentChildIdVec.end(); it++) { if (it->first == nodeToBeRemovedParentId && it->second == nodeToBeRemoved.id) { - g_parentChildIdVec.erase(it); + g_parentChildIdVec.erase(it); } } } @@ -2294,18 +2004,35 @@ void OhosAccessibilityBridge::ClearFlutterSemanticsCaches() g_flutterSemanticsTree.clear(); g_parentChildIdVec.clear(); g_screenRectMap.clear(); - g_actions_mp.clear(); - g_flutterNavigationVec.clear(); + Flutter_SendAccessibilityAsyncEvent( + accessibilityFocusedNode.id, + ArkUI_AccessibilityEventType::ARKUI_ACCESSIBILITY_NATIVE_EVENT_TYPE_ACCESSIBILITY_FOCUS_CLEARED); + accessibilityFocusedNode = {}; } /** - * extent common struct SemanticsNode to - * derived struct SemanticsNodeExtent + * 更新扩展版flutter语义节点 */ -SemanticsNodeExtent OhosAccessibilityBridge::SetAndGetSemanticsNodeExtent( +SemanticsNodeExtent OhosAccessibilityBridge::UpdatetSemanticsNodeExtent( flutter::SemanticsNode node) { SemanticsNodeExtent nodeEx = SemanticsNodeExtent(); + // 获取更新前的flutter节点信息 + if (g_flutterSemanticsTree.size() > 0) { + auto prevNode = GetFlutterSemanticsNode(node.id); + nodeEx.hadPreviousConfig = true; + nodeEx.previousFlags = prevNode.flags; + nodeEx.previousActions = prevNode.actions; + nodeEx.previousTextSelectionBase = prevNode.textSelectionBase; + nodeEx.previousTextSelectionExtent = prevNode.textSelectionExtent; + nodeEx.previousScrollPosition = prevNode.scrollPosition; + nodeEx.previousScrollExtentMax = prevNode.scrollExtentMax; + nodeEx.previousScrollExtentMin = prevNode.scrollExtentMin; + nodeEx.previousValue = prevNode.value; + nodeEx.previousLabel = prevNode.label; + } + // 更新当前flutter节点信息 + nodeEx.isNull = false; nodeEx.id = std::move(node.id); nodeEx.flags = std::move(node.flags); nodeEx.actions = std::move(node.actions); @@ -2333,87 +2060,93 @@ SemanticsNodeExtent OhosAccessibilityBridge::SetAndGetSemanticsNodeExtent( nodeEx.decreasedValueAttributes = std::move(node.decreasedValueAttributes); nodeEx.tooltip = std::move(node.tooltip); nodeEx.textDirection = std::move(node.textDirection); - nodeEx.rect = std::move(node.rect); nodeEx.transform = std::move(node.transform); nodeEx.childrenInTraversalOrder = std::move(node.childrenInTraversalOrder); nodeEx.childrenInHitTestOrder = std::move(node.childrenInHitTestOrder); - nodeEx.customAccessibilityActions = - std::move(node.customAccessibilityActions); + nodeEx.customAccessibilityActions = std::move(node.customAccessibilityActions); return nodeEx; } void OhosAccessibilityBridge::GetSemanticsNodeDebugInfo( - flutter::SemanticsNode node) + SemanticsNodeExtent node) { FML_DLOG(INFO) << "-------------------SemanticsNode------------------"; SkMatrix _transform = node.transform.asM33(); FML_DLOG(INFO) << "node.id=" << node.id; FML_DLOG(INFO) << "node.label=" << node.label; + FML_DLOG(INFO) << "node.previousLabel=" << node.previousLabel; FML_DLOG(INFO) << "node.tooltip=" << node.tooltip; FML_DLOG(INFO) << "node.hint=" << node.hint; FML_DLOG(INFO) << "node.flags=" << node.flags; + FML_DLOG(INFO) << "node.previousFlags=" << node.previousFlags; FML_DLOG(INFO) << "node.actions=" << node.actions; + FML_DLOG(INFO) << "node.previousActions=" << node.previousActions; + FML_DLOG(INFO) << "node.value=" << node.value; + FML_DLOG(INFO) << "node.previousValue=" << node.previousValue; FML_DLOG(INFO) << "node.rect= {" << node.rect.fLeft << ", " << node.rect.fTop - << ", " << node.rect.fRight << ", " << node.rect.fBottom - << "}"; + << ", " << node.rect.fRight << ", " << node.rect.fBottom + << "}"; FML_DLOG(INFO) << "node.transform -> kMScaleX=" - << _transform.get(SkMatrix::kMScaleX); + << _transform.get(SkMatrix::kMScaleX); FML_DLOG(INFO) << "node.transform -> kMSkewX=" - << _transform.get(SkMatrix::kMSkewX); + << _transform.get(SkMatrix::kMSkewX); FML_DLOG(INFO) << "node.transform -> kMTransX=" - << _transform.get(SkMatrix::kMTransX); + << _transform.get(SkMatrix::kMTransX); FML_DLOG(INFO) << "node.transform -> kMSkewY=" - << _transform.get(SkMatrix::kMSkewY); + << _transform.get(SkMatrix::kMSkewY); FML_DLOG(INFO) << "node.transform -> kMScaleY=" - << _transform.get(SkMatrix::kMScaleY); + << _transform.get(SkMatrix::kMScaleY); FML_DLOG(INFO) << "node.transform -> kMTransY=" - << _transform.get(SkMatrix::kMTransY); + << _transform.get(SkMatrix::kMTransY); FML_DLOG(INFO) << "node.transform -> kMPersp0=" - << _transform.get(SkMatrix::kMPersp0); + << _transform.get(SkMatrix::kMPersp0); FML_DLOG(INFO) << "node.transform -> kMPersp1=" - << _transform.get(SkMatrix::kMPersp1); + << _transform.get(SkMatrix::kMPersp1); FML_DLOG(INFO) << "node.transform -> kMPersp2=" - << _transform.get(SkMatrix::kMPersp2); + << _transform.get(SkMatrix::kMPersp2); FML_DLOG(INFO) << "node.maxValueLength=" << node.maxValueLength; FML_DLOG(INFO) << "node.currentValueLength=" << node.currentValueLength; FML_DLOG(INFO) << "node.textSelectionBase=" << node.textSelectionBase; + FML_DLOG(INFO) << "node.previousTextSelectionBase=" << node.previousTextSelectionBase; FML_DLOG(INFO) << "node.textSelectionExtent=" << node.textSelectionExtent; - FML_DLOG(INFO) << "node.textSelectionBase=" << node.textSelectionBase; + FML_DLOG(INFO) << "node.previousTextSelectionExtent=" << node.previousTextSelectionExtent; FML_DLOG(INFO) << "node.platformViewId=" << node.platformViewId; FML_DLOG(INFO) << "node.scrollChildren=" << node.scrollChildren; FML_DLOG(INFO) << "node.scrollIndex=" << node.scrollIndex; FML_DLOG(INFO) << "node.scrollPosition=" << node.scrollPosition; + FML_DLOG(INFO) << "node.previousScrollPosition=" << node.previousScrollPosition; FML_DLOG(INFO) << "node.scrollIndex=" << node.scrollIndex; - FML_DLOG(INFO) << "node.scrollPosition=" << node.scrollPosition; FML_DLOG(INFO) << "node.scrollExtentMax=" << node.scrollExtentMax; + FML_DLOG(INFO) << "node.previousScrollExtentMax=" << node.previousScrollExtentMax; FML_DLOG(INFO) << "node.scrollExtentMin=" << node.scrollExtentMin; + FML_DLOG(INFO) << "node.previousScrollExtentMin=" << node.previousScrollExtentMin; FML_DLOG(INFO) << "node.elevation=" << node.elevation; FML_DLOG(INFO) << "node.thickness=" << node.thickness; FML_DLOG(INFO) << "node.textDirection=" << node.textDirection; FML_DLOG(INFO) << "node.childrenInTraversalOrder.size()=" - << node.childrenInTraversalOrder.size(); + << node.childrenInTraversalOrder.size(); for (uint32_t i = 0; i < node.childrenInTraversalOrder.size(); i++) { FML_DLOG(INFO) << "node.childrenInTraversalOrder[" << i - << "]=" << node.childrenInTraversalOrder[i]; + << "]=" << node.childrenInTraversalOrder[i]; } FML_DLOG(INFO) << "node.childrenInHitTestOrder.size()=" - << node.childrenInHitTestOrder.size(); + << node.childrenInHitTestOrder.size(); for (uint32_t i = 0; i < node.childrenInHitTestOrder.size(); i++) { FML_DLOG(INFO) << "node.childrenInHitTestOrder[" << i - << "]=" << node.childrenInHitTestOrder[i]; + << "]=" << node.childrenInHitTestOrder[i]; } FML_DLOG(INFO) << "node.customAccessibilityActions.size()=" - << node.customAccessibilityActions.size(); + << node.customAccessibilityActions.size(); for (uint32_t i = 0; i < node.customAccessibilityActions.size(); i++) { FML_DLOG(INFO) << "node.customAccessibilityActions[" << i - << "]=" << node.customAccessibilityActions[i]; + << "]=" << node.customAccessibilityActions[i]; } FML_DLOG(INFO) << "------------------SemanticsNode-----------------"; } void OhosAccessibilityBridge::GetSemanticsFlagsDebugInfo( - flutter::SemanticsNode node) + SemanticsNodeExtent node) { FML_DLOG(INFO) << "----------------SemanticsFlags-------------------------"; FML_DLOG(INFO) << "node.id=" << node.id; @@ -2467,4 +2200,23 @@ void OhosAccessibilityBridge::GetSemanticsFlagsDebugInfo( << customAccessibilityAction.hint; FML_DLOG(INFO) << "------------CustomAccessibilityAction--------------"; } + +void OhosAccessibilityBridge::GetSemanticsDebugInfo() +{ + // 打印flutter语义树的不同节点的属性信息 + for (const auto& item : g_flutterSemanticsTree) { + FML_DLOG(INFO) << "g_flutterSemanticsTree -> {" << item.first << ", " + << item.second.id << "}"; + } + for (const auto& item : g_parentChildIdVec) { + FML_DLOG(INFO) << "g_parentChildIdVec -> (" << item.first << ", " + << item.second << ")"; + } + //打印按层次遍历排序的flutter语义树节点id数组 + std::vector levelOrderTraversalTree = GetLevelOrderTraversalTree(0); + for (const auto& item: levelOrderTraversalTree) { + FML_DLOG(INFO) << "LevelOrderTraversalTree: { " << item << " }"; + } +} + } // namespace flutter diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h b/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h index 5f03fdc839f5ec12e06b19a5cadd4e57f21eeb61..d947b14f14b223ce5d16474c8372cf60ff4ee5bb 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h +++ b/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #ifndef OHOS_ACCESSIBILITY_BRIDGE_H #define OHOS_ACCESSIBILITY_BRIDGE_H @@ -19,6 +10,8 @@ #include #include #include +#include +#include #include #include "flutter/fml/mapping.h" #include "flutter/lib/ui/semantics/custom_accessibility_action.h" @@ -26,317 +19,319 @@ #include "native_accessibility_channel.h" #include "ohos_accessibility_features.h" #include "ohos_accessibility_ddl.h" +#include "flutter/shell/platform/ohos/utils/ohos_utils.h" +#include "flutter/shell/platform/ohos/utils/arkui_accessibility_constant.h" +#include "third_party/skia/include/core/SkMatrix.h" +#include "third_party/skia/include/core/SkScalar.h" +#include "third_party/skia/include/core/SkPoint.h" namespace flutter { typedef flutter::SemanticsFlags FLAGS_; typedef flutter::SemanticsAction ACTIONS_; struct AbsoluteRect { - float left; - float top; - float right; - float bottom; - - static constexpr AbsoluteRect MakeEmpty() { - return AbsoluteRect{0.0, 0.0, 0.0, 0.0}; - } -}; + float left; + float top; + float right; + float bottom; + static constexpr AbsoluteRect MakeEmpty() { + return AbsoluteRect{0.0, 0.0, 0.0, 0.0}; + } + static constexpr AbsoluteRect MakeRect( + float left, float top, float right, float bottom) { + return AbsoluteRect{left, top, right, bottom}; + } +}; struct SemanticsNodeExtent : flutter::SemanticsNode { - int32_t parentId = -1; - AbsoluteRect abRect = AbsoluteRect::MakeEmpty(); - int32_t previousFlags; - int32_t previousActions; - int32_t previousTextSelectionBase; - int32_t previousTextSelectionExtent; - float previousScrollPosition; - float previousScrollExtentMax; - float previousScrollExtentMin; - std::string previousValue; - std::string previousLabel; + bool isNull = false; + SkM44 globalTransform = SkM44{}; + AbsoluteRect absoluteRect = AbsoluteRect::MakeEmpty(); + int32_t parentId = -1; + bool hadPreviousConfig = false; + int32_t previousNodeId = -1; + int32_t previousFlags = 0; + int32_t previousActions = 0; + int32_t previousTextSelectionBase = -1; + int32_t previousTextSelectionExtent = -1; + double previousScrollPosition = std::nan(""); + double previousScrollExtentMax = std::nan(""); + double previousScrollExtentMin = std::nan(""); + std::string previousValue; + std::string previousLabel; + bool HasPrevAction(SemanticsAction action) const + { + return (previousActions & this->actions) != 0; + } + bool HasPrevFlag(SemanticsFlags flag) const + { + return (previousFlags & this->flags) != 0; + } }; /** - * flutter和ohos的无障碍服务桥接 + * 桥接flutter无障碍功能和ohos无障碍系统服务 */ class OhosAccessibilityBridge { - public: - static OhosAccessibilityBridge* GetInstance(); - static void DestroyInstance(); - OhosAccessibilityBridge(const OhosAccessibilityBridge&) = delete; - OhosAccessibilityBridge& operator=(const OhosAccessibilityBridge&) = delete; - - bool IS_FLUTTER_NAVIGATE = false; - int64_t native_shell_holder_id_; - ArkUI_AccessibilityProvider* provider_; - - void OnOhosAccessibilityStateChange( - int64_t shellHolderId, - bool ohosAccessibilityEnabled); - - void SetNativeShellHolderId(int64_t id); - - void updateSemantics(flutter::SemanticsNodeUpdates update, - flutter::CustomAccessibilityActionUpdates actions); - - void DispatchSemanticsAction(int32_t id, - flutter::SemanticsAction action, - fml::MallocMapping args); - - void Announce(std::unique_ptr& message); - - flutter::SemanticsNode GetFlutterSemanticsNode(int32_t id); - - int32_t FindAccessibilityNodeInfosById( - int64_t elementId, - ArkUI_AccessibilitySearchMode mode, - int32_t requestId, - ArkUI_AccessibilityElementInfoList* elementList); - int32_t FindAccessibilityNodeInfosByText( - int64_t elementId, - const char* text, - int32_t requestId, - ArkUI_AccessibilityElementInfoList* elementList); - int32_t FindFocusedAccessibilityNode( - int64_t elementId, - ArkUI_AccessibilityFocusType focusType, - int32_t requestId, - ArkUI_AccessibilityElementInfo* elementinfo); - int32_t FindNextFocusAccessibilityNode( - int64_t elementId, - ArkUI_AccessibilityFocusMoveDirection direction, - int32_t requestId, - ArkUI_AccessibilityElementInfo* elementList); - int32_t ExecuteAccessibilityAction( - int64_t elementId, - ArkUI_Accessibility_ActionType action, - ArkUI_AccessibilityActionArguments* actionArguments, - int32_t requestId); - int32_t ClearFocusedFocusAccessibilityNode(); - int32_t GetAccessibilityNodeCursorPosition(int64_t elementId, - int32_t requestId, - int32_t* index); - - void Flutter_SendAccessibilityAsyncEvent( - int64_t elementId, - ArkUI_AccessibilityEventType eventType); - void FlutterNodeToElementInfoById( - ArkUI_AccessibilityElementInfo* elementInfoFromList, - int64_t elementId); - int32_t GetParentId(int64_t elementId); - - void ConvertChildRelativeRectToScreenRect(flutter::SemanticsNode node); - std::pair, std::pair> - GetAbsoluteScreenRect(int32_t flutterNodeId); - void SetAbsoluteScreenRect(int32_t flutterNodeId, - float left, - float top, - float right, - float bottom); - - SemanticsNodeExtent SetAndGetSemanticsNodeExtent(flutter::SemanticsNode node); - - void FlutterScrollExecution( - flutter::SemanticsNode node, - ArkUI_AccessibilityElementInfo* elementInfoFromList); - - void ClearFlutterSemanticsCaches(); - - private: - OhosAccessibilityBridge(); - static OhosAccessibilityBridge* bridgeInstance; - std::shared_ptr nativeAccessibilityChannel_; - std::shared_ptr accessibilityFeatures_; - - // arkui的root节点的父节点id - static const int32_t ARKUI_ACCESSIBILITY_ROOT_PARENT_ID = -2100000; - static const int32_t RET_ERROR_STATE_CODE = -999; - static const int32_t ROOT_NODE_ID = 0; - constexpr static const double SCROLL_EXTENT_FOR_INFINITY = 100000.0; - constexpr static const double SCROLL_POSITION_CAP_FOR_INFINITY = 70000.0; - - flutter::SemanticsNode inputFocusedNode; - flutter::SemanticsNode lastInputFocusedNode; - flutter::SemanticsNode accessibilityFocusedNode; - - std::vector> g_parentChildIdVec; - std::map g_flutterSemanticsTree; - std::unordered_map< - int32_t, - std::pair, std::pair>> - g_screenRectMap; - std::unordered_map g_actions_mp; - std::vector g_flutterNavigationVec; - - const std::map - ArkUI_ACTION_TYPE_MAP_ = { - {"invalid", ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_INVALID}, - {"click", ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK}, - {"long press", ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_LONG_CLICK}, - {"focus acquisition", - ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS}, - {"focus clearance", - ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS}, - {"forward scroll", - ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_FORWARD}, - {"backward scroll", - ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_BACKWARD}, - {"copy text", ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_COPY}, - {"paste text", ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_PASTE}, - {"cut text", ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CUT}, - {"text selection", - ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SELECT_TEXT}, - {"set text", ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_TEXT}, - {"text cursor position setting", - ArkUI_Accessibility_ActionType:: - ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_CURSOR_POSITION}, - }; - - static const int32_t FOCUSABLE_FLAGS = - static_cast(FLAGS_::kHasCheckedState) | - static_cast(FLAGS_::kIsChecked) | - static_cast(FLAGS_::kIsSelected) | - static_cast(FLAGS_::kIsTextField) | - static_cast(FLAGS_::kIsFocused) | - static_cast(FLAGS_::kHasEnabledState) | - static_cast(FLAGS_::kIsEnabled) | - static_cast(FLAGS_::kIsInMutuallyExclusiveGroup) | - static_cast(FLAGS_::kHasToggledState) | - static_cast(FLAGS_::kIsToggled) | - static_cast(FLAGS_::kHasToggledState) | - static_cast(FLAGS_::kIsFocusable) | - static_cast(FLAGS_::kIsSlider); - - static const int32_t SCROLLABLE_ACTIONS = - static_cast(ACTIONS_::kScrollUp) | - static_cast(ACTIONS_::kScrollDown) | - static_cast(ACTIONS_::kScrollLeft) | - static_cast(ACTIONS_::kScrollRight); - - void FlutterSetElementInfoProperties( - ArkUI_AccessibilityElementInfo* elementInfoFromList, - int64_t elementId); - void FlutterSetElementInfoOperationActions( - ArkUI_AccessibilityElementInfo* elementInfoFromList, - std::string widget_type); - void FlutterTreeToArkuiTree( - ArkUI_AccessibilityElementInfoList* elementInfoList); - void BuildArkUISemanticsTree( - int64_t elementId, - ArkUI_AccessibilityElementInfo* elementInfoFromList, - ArkUI_AccessibilityElementInfoList* elementList); - - std::vector GetLevelOrderTraversalTree(int32_t rootId); - flutter::SemanticsNode GetFlutterRootSemanticsNode(); - std::string GetNodeComponentType(const flutter::SemanticsNode& node); - flutter::SemanticsAction ArkuiActionsToFlutterActions( - ArkUI_Accessibility_ActionType arkui_action); - - bool HasScrolled(const flutter::SemanticsNode& flutterNode); - - bool IsNodeFocusable(const flutter::SemanticsNode& flutterNode); - bool IsNodeCheckable(flutter::SemanticsNode flutterNode); - bool IsNodeChecked(flutter::SemanticsNode flutterNode); - bool IsNodeSelected(flutter::SemanticsNode flutterNode); - bool IsNodeClickable(flutter::SemanticsNode flutterNode); - bool IsNodeScrollable(flutter::SemanticsNode flutterNode); - bool IsNodePassword(flutter::SemanticsNode flutterNode); - bool IsNodeVisible(flutter::SemanticsNode flutterNode); - bool IsNodeEnabled(flutter::SemanticsNode flutterNode); - bool IsNodeHasLongPress(flutter::SemanticsNode flutterNode); - - bool IsTextField(flutter::SemanticsNode flutterNode); - bool IsSlider(flutter::SemanticsNode flutterNode); - bool IsScrollableWidget(flutter::SemanticsNode flutterNode); - void PerformSetText(flutter::SemanticsNode flutterNode, - ArkUI_Accessibility_ActionType action, - ArkUI_AccessibilityActionArguments* actionArguments); - void PerformSelectText(flutter::SemanticsNode flutterNode, - ArkUI_Accessibility_ActionType action, - ArkUI_AccessibilityActionArguments* actionArguments); - - void AddRouteNodes(std::vector edges, - flutter::SemanticsNode node); - std::string GetRouteName(flutter::SemanticsNode node); - void onWindowNameChange(flutter::SemanticsNode route); - void removeSemanticsNode(flutter::SemanticsNode nodeToBeRemoved); - - void GetSemanticsNodeDebugInfo(flutter::SemanticsNode node); - void GetSemanticsFlagsDebugInfo(flutter::SemanticsNode node); - void GetCustomActionDebugInfo( - flutter::CustomAccessibilityAction customAccessibilityAction); - - void FlutterPageUpdate(ArkUI_AccessibilityEventType eventType); - void RequestFocusWhenPageUpdate(); - - bool Contains(const std::string source, const std::string target); -}; - -enum class AccessibilityAction : int32_t { - kTap = 1 << 0, - kLongPress = 1 << 1, - kScrollLeft = 1 << 2, - kScrollRight = 1 << 3, - kScrollUp = 1 << 4, - kScrollDown = 1 << 5, - kIncrease = 1 << 6, - kDecrease = 1 << 7, - kShowOnScreen = 1 << 8, - kMoveCursorForwardByCharacter = 1 << 9, - kMoveCursorBackwardByCharacter = 1 << 10, - kSetSelection = 1 << 11, - kCopy = 1 << 12, - kCut = 1 << 13, - kPaste = 1 << 14, - kDidGainAccessibilityFocus = 1 << 15, - kDidLoseAccessibilityFocus = 1 << 16, - kCustomAction = 1 << 17, - kDismiss = 1 << 18, - kMoveCursorForwardByWord = 1 << 19, - kMoveCursorBackwardByWord = 1 << 20, - kSetText = 1 << 21, +public: + static OhosAccessibilityBridge* GetInstance(); + OhosAccessibilityBridge(const OhosAccessibilityBridge&) = delete; + OhosAccessibilityBridge& operator=(const OhosAccessibilityBridge&) = delete; + + std::string xcomponentId_; + bool isFlutterNavigated_; + int64_t native_shell_holder_id_; + + void OnOhosAccessibilityStateChange(bool ohosAccessibilityEnabled, int64_t shellholderId); + + void UpdateSemantics(flutter::SemanticsNodeUpdates update, + flutter::CustomAccessibilityActionUpdates actions); + + void DispatchSemanticsAction(int32_t id, + flutter::SemanticsAction action, + fml::MallocMapping args); + + void Announce(std::unique_ptr& message); + void OnTap(int32_t nodeId); + void OnLongPress(int32_t nodeId); + void OnTooltip(std::unique_ptr& message); + + SemanticsNodeExtent GetFlutterSemanticsNode(int32_t id); + int32_t GetParentId(int64_t elementId); + + int32_t FindAccessibilityNodeInfosById( + int64_t elementId, + ArkUI_AccessibilitySearchMode mode, + int32_t requestId, + ArkUI_AccessibilityElementInfoList* elementList); + int32_t FindAccessibilityNodeInfosByText( + int64_t elementId, + const char* text, + int32_t requestId, + ArkUI_AccessibilityElementInfoList* elementList); + int32_t FindFocusedAccessibilityNode( + int64_t elementId, + ArkUI_AccessibilityFocusType focusType, + int32_t requestId, + ArkUI_AccessibilityElementInfo* elementinfo); + int32_t FindNextFocusAccessibilityNode( + int64_t elementId, + ArkUI_AccessibilityFocusMoveDirection direction, + int32_t requestId, + ArkUI_AccessibilityElementInfo* elementList); + int32_t ExecuteAccessibilityAction( + int64_t elementId, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments, + int32_t requestId); + int32_t ClearFocusedFocusAccessibilityNode(); + int32_t GetAccessibilityNodeCursorPosition(int64_t elementId, + int32_t requestId, + int32_t* index); + + void Flutter_SendAccessibilityAsyncEvent( + int64_t elementId, + ArkUI_AccessibilityEventType eventType); + void Flutter_SendAccessibilityAnnounceEvent( + std::unique_ptr& message, + ArkUI_AccessibilityEventType eventType); + + void RelativeRectToScreenRect(SemanticsNodeExtent& node); + AbsoluteRect GetAbsoluteScreenRect(SemanticsNodeExtent& flutterNode); + void SetAbsoluteScreenRect(SemanticsNodeExtent& flutterNode, + float left, + float top, + float right, + float bottom); + + SemanticsNodeExtent UpdatetSemanticsNodeExtent(flutter::SemanticsNode node); + + void FlutterScrollExecution( + SemanticsNodeExtent node, + ArkUI_AccessibilityElementInfo* elementInfoFromList); + + void ClearFlutterSemanticsCaches(); + +private: + OhosAccessibilityBridge(); + bool isAccessibilityEnabled_; + static std::unique_ptr bridgeInstance_; + std::shared_ptr nativeAccessibilityChannel_; + std::shared_ptr accessibilityFeatures_; + + std::unordered_map> g_flutterSemanticsTreeXComponents; + std::unordered_map>> g_parentChildIdVecXComponents; + std::unordered_map> g_screenRectMapXComponents; + + std::unordered_map g_flutterSemanticsTree; + std::vector> g_parentChildIdVec; + std::unordered_map g_screenRectMap; + std::unordered_map g_globalTransformMap; + + SemanticsNodeExtent inputFocusedNode; + SemanticsNodeExtent lastInputFocusedNode; + SemanticsNodeExtent accessibilityFocusedNode; + + static const int32_t OHOS_API_VERSION; + static const int32_t ARKUI_ACCESSIBILITY_ROOT_PARENT_ID = -2100000; + static const int32_t RET_ERROR_STATE_CODE = -1; + static const int32_t ROOT_NODE_ID = 0; + constexpr static const double SCROLL_EXTENT_FOR_INFINITY = 100000.0; + constexpr static const double SCROLL_POSITION_CAP_FOR_INFINITY = 70000.0; + + const char* ARKUI_ACTION_ARG_SET_TEXT = "setText"; + const char* ARKUI_ACTION_ARG_SELECT_TEXT_START = "selectTextBegin"; + const char* ARKUI_ACTION_ARG_SELECT_TEXT_END = "selectTextEnd"; + + const std::string OTHER_WIDGET_NAME = "View"; + const std::string TEXT_WIDGET_NAME = "Text"; + const std::string EDIT_TEXT_WIDGET_NAME = "TextInput"; + const std::string EDIT_MULTILINE_TEXT_WIDGET_NAME = "TextArea"; + const std::string IMAGE_WIDGET_NAME = "Image"; + const std::string SCROLL_WIDGET_NAME = "Scroll"; + const std::string BUTTON_WIDGET_NAME = "Button"; + const std::string LINK_WIDGET_NAME = "Link"; + const std::string SLIDER_WIDGET_NAME = "Slider"; + const std::string HEADER_WIDGET_NAME = "Header"; + const std::string RADIO_BUTTON_WIDGET_NAME = "Radio"; + const std::string CHECK_BOX_WIDGET_NAME = "Checkbox"; + const std::string SWITCH_WIDGET_NAME = "Toggle"; + const std::string SEEKBAR_WIDGET_NAME = "SeekBar"; + + const std::map + ArkUI_ACTION_TYPE_MAP_ = { + {"invalid", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_INVALID}, + {"click", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLICK}, + {"long press", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_LONG_CLICK}, + {"focus acquisition", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_GAIN_ACCESSIBILITY_FOCUS}, + {"focus clearance", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CLEAR_ACCESSIBILITY_FOCUS}, + {"forward scroll", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_FORWARD}, + {"backward scroll", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SCROLL_BACKWARD}, + {"copy text", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_COPY}, + {"paste text", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_PASTE}, + {"cut text", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_CUT}, + {"text selection", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SELECT_TEXT}, + {"set text", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_TEXT}, + {"text cursor position setting", ArkUI_Accessibility_ActionType::ARKUI_ACCESSIBILITY_NATIVE_ACTION_TYPE_SET_CURSOR_POSITION}, + }; + + static const int32_t FOCUSABLE_FLAGS = + static_cast(FLAGS_::kHasCheckedState) | + static_cast(FLAGS_::kIsChecked) | + static_cast(FLAGS_::kIsSelected) | + static_cast(FLAGS_::kIsTextField) | + static_cast(FLAGS_::kIsFocused) | + static_cast(FLAGS_::kHasEnabledState) | + static_cast(FLAGS_::kIsEnabled) | + static_cast(FLAGS_::kIsInMutuallyExclusiveGroup) | + static_cast(FLAGS_::kHasToggledState) | + static_cast(FLAGS_::kIsToggled) | + static_cast(FLAGS_::kHasToggledState) | + static_cast(FLAGS_::kIsFocusable) | + static_cast(FLAGS_::kIsSlider); + + static const int32_t SCROLLABLE_ACTIONS = + static_cast(ACTIONS_::kScrollUp) | + static_cast(ACTIONS_::kScrollDown) | + static_cast(ACTIONS_::kScrollLeft) | + static_cast(ACTIONS_::kScrollRight); + + void FlutterSetElementInfoProperties( + ArkUI_AccessibilityElementInfo* elementInfoFromList, + int64_t elementId); + void FlutterSetElementInfoOperationActions( + ArkUI_AccessibilityElementInfo* elementInfoFromList, + std::string widget_type); + void BuildArkUISemanticsTree( + int64_t elementId, + ArkUI_AccessibilityElementInfo* elementInfoFromList, + ArkUI_AccessibilityElementInfoList* elementList); + + std::vector GetLevelOrderTraversalTree(int32_t rootId); + SemanticsNodeExtent GetFlutterRootSemanticsNode(); + std::string GetNodeComponentType(const SemanticsNodeExtent& node); + flutter::SemanticsAction ArkuiActionsToFlutterActions( + ArkUI_Accessibility_ActionType arkui_action); + + void BuildParentChildNodeIdRelation(const SemanticsNodeExtent& node); + void ComputeGlobalTransform(); + void ConvertRectToGlobal(SemanticsNodeExtent& node); + SkPoint ApplyTransform(SkPoint& point, const SkM44& transform); + + bool HasScrolled(const SemanticsNodeExtent& flutterNode); + bool HasChangedLabel(const SemanticsNodeExtent& flutterNode); + + bool IsNodeFocusable(const SemanticsNodeExtent& flutterNode); + bool IsNodeFocused(const SemanticsNodeExtent& flutterNode); + bool IsNodeCheckable(SemanticsNodeExtent flutterNode); + bool IsNodeChecked(SemanticsNodeExtent flutterNode); + bool IsNodeSelected(SemanticsNodeExtent flutterNode); + bool IsNodeClickable(SemanticsNodeExtent flutterNode); + bool IsNodeScrollable(SemanticsNodeExtent flutterNode); + bool IsNodePassword(SemanticsNodeExtent flutterNode); + bool IsNodeVisible(SemanticsNodeExtent flutterNode); + bool IsNodeEnabled(SemanticsNodeExtent flutterNode); + bool IsNodeHasLongPress(SemanticsNodeExtent flutterNode); + bool IsNodeShowOnScreen(SemanticsNodeExtent flutterNode); + + bool IsTextField(SemanticsNodeExtent flutterNode); + bool IsSlider(SemanticsNodeExtent flutterNode); + bool IsScrollableWidget(SemanticsNodeExtent flutterNode); + + void PerformClickAction(int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode); + void PerformLongClickAction(int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode); + void PerformGainFocusnAction(int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode); + void PerformClearFocusAction(int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode); + void PerformScrollUpAction(int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode); + void PerformScrollDownAction(int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode); + void PerformClipboardAction(int64_t elementId, + ArkUI_Accessibility_ActionType action); + void PerformInvalidAction(int64_t elementId, + ArkUI_Accessibility_ActionType action, + SemanticsNodeExtent flutterNode); + void PerformSetText(SemanticsNodeExtent flutterNode, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments); + void PerformSelectText(SemanticsNodeExtent flutterNode, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments); + void PerformSetCursorPosition(SemanticsNodeExtent flutterNode, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments); + void PerformCustomAction(SemanticsNodeExtent flutterNode, + ArkUI_Accessibility_ActionType action, + ArkUI_AccessibilityActionArguments* actionArguments); + void PerformShowOnScreenAction(SemanticsNodeExtent flutterNode); + + void AddRouteNodes(std::vector edges, + SemanticsNodeExtent node); + std::string GetRouteName(SemanticsNodeExtent node); + void OnWindowNameChange(SemanticsNodeExtent route); + void RemoveSemanticsNode(SemanticsNodeExtent nodeToBeRemoved); + + void GetSemanticsNodeDebugInfo(SemanticsNodeExtent node); + void GetSemanticsFlagsDebugInfo(SemanticsNodeExtent node); + void GetCustomActionDebugInfo( + flutter::CustomAccessibilityAction customAccessibilityAction); + + void RequestFocusWhenPageUpdate(int32_t requestFocusId); + bool Contains(const std::string source, const std::string target); + std::pair GetRealScaleFactor(); + void DoubleClickRouteToNewPage(SemanticsNodeExtent node); + void GetSemanticsDebugInfo(); + void AccessibiltiyChangesWithXComponentId(); }; - -enum class AccessibilityFlags : int32_t { - kHasCheckedState = 1 << 0, - kIsChecked = 1 << 1, - kIsSelected = 1 << 2, - kIsButton = 1 << 3, - kIsTextField = 1 << 4, - kIsFocused = 1 << 5, - kHasEnabledState = 1 << 6, - kIsEnabled = 1 << 7, - kIsInMutuallyExclusiveGroup = 1 << 8, - kIsHeader = 1 << 9, - kIsObscured = 1 << 10, - kScopesRoute = 1 << 11, - kNamesRoute = 1 << 12, - kIsHidden = 1 << 13, - kIsImage = 1 << 14, - kIsLiveRegion = 1 << 15, - kHasToggledState = 1 << 16, - kIsToggled = 1 << 17, - kHasImplicitScrolling = 1 << 18, - kIsMultiline = 1 << 19, - kIsReadOnly = 1 << 20, - kIsFocusable = 1 << 21, - kIsLink = 1 << 22, - kIsSlider = 1 << 23, - kIsKeyboardKey = 1 << 24, - kIsCheckStateMixed = 1 << 25, -}; - } // namespace flutter #endif // OHOS_ACCESSIBILITY_BRIDGE_H diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_ddl.cpp b/shell/platform/ohos/accessibility/ohos_accessibility_ddl.cpp index 39ea57e8a991583519592ae3fd4e3d206c2e3786..f7751526deaad4679c28903a2d29b72946105bca 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_ddl.cpp +++ b/shell/platform/ohos/accessibility/ohos_accessibility_ddl.cpp @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include "ohos_accessibility_ddl.h" @@ -284,4 +275,19 @@ GetNativeA11yProvider OhosAccessibilityDDL::DLLoadGetNativeA11yProvider(const ch } return symbol; } + +GetFindActionArgs OhosAccessibilityDDL::DLLoadGetFindActionArgs(const char* symbolName) +{ + LIBHANDLE handler = LOAD_LIB(ACCESSIBILITY_LIB_NAME); + if (handler == nullptr) { + return nullptr; + } + + auto symbol = reinterpret_cast(LOAD_SYM(handler, symbolName)); + if (symbol == nullptr) { + CLOSE_LIB(handler); + return nullptr; + } + return symbol; +} } \ No newline at end of file diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_ddl.h b/shell/platform/ohos/accessibility/ohos_accessibility_ddl.h index c5d6c3263147685c653237323624f99b5b7cfa81..d44989bfdbe4abcf7d2f2ed5367d66c63d90a0a7 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_ddl.h +++ b/shell/platform/ohos/accessibility/ohos_accessibility_ddl.h @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #ifndef OHOS_ACCESSIBILITY_DDL_H #define OHOS_ACCESSIBILITY_DDL_H @@ -42,6 +33,7 @@ using SetEventElemFunc = int32_t (*)(ArkUI_AccessibilityEventInfo*, ArkUI_Access using SetReqFocusFunc = int32_t (*)(ArkUI_AccessibilityEventInfo*, int32_t); using GetNativeA11yProvider = int32_t (*)(OH_NativeXComponent*, ArkUI_AccessibilityProvider**); +using GetFindActionArgs = int32_t (*)(ArkUI_AccessibilityActionArguments*, const char*, char**); class OhosAccessibilityDDL { public: @@ -72,11 +64,8 @@ public: static SetReqFocusFunc DLLoadSetReqFocusFunc(const char* symbolName); static GetNativeA11yProvider DLLoadGetNativeA11yProvider(const char* symbolName); - - + static GetFindActionArgs DLLoadGetFindActionArgs(const char* symbolName); }; - } // namespace flutter - #endif \ No newline at end of file diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp b/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp index 9f4c87850842da1609d0bf3d683d362b0b0c83be..4b715a7d02b5e0006455ac7021b81d3e597af42e 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp +++ b/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include "ohos_accessibility_features.h" #include "flutter/fml/logging.h" diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_features.h b/shell/platform/ohos/accessibility/ohos_accessibility_features.h index 1163180d65194e5bc38ac4aeb66112dafa7634ba..41625ad76969d15aa963d3aed9d3129873f4a25c 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_features.h +++ b/shell/platform/ohos/accessibility/ohos_accessibility_features.h @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #ifndef OHOS_ACCESSIBILITY_FEATURES_H #define OHOS_ACCESSIBILITY_FEATURES_H diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_manager.cpp b/shell/platform/ohos/accessibility/ohos_accessibility_manager.cpp index e9b1499f702b7dd1a5adcb535340ca0d9b280b2c..e6b811032418945d50b33d84b3e8d403a3704f3e 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_manager.cpp +++ b/shell/platform/ohos/accessibility/ohos_accessibility_manager.cpp @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #include "ohos_accessibility_manager.h" diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_manager.h b/shell/platform/ohos/accessibility/ohos_accessibility_manager.h index e3c873fe8c3113875d1ae2a6028c5507b899c36c..1ae56a60f9230498b9b6d47e754ab804aebe8958 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_manager.h +++ b/shell/platform/ohos/accessibility/ohos_accessibility_manager.h @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #ifndef OHOS_ACCESSIBILITY_MANAGER_H #define OHOS_ACCESSIBILITY_MANAGER_H diff --git a/shell/platform/ohos/compatibility/ohos_accessibility_interface.h b/shell/platform/ohos/compatibility/ohos_accessibility_interface.h index 5a4ca0769d3a91c1466bd57753302175836bc932..5248eda0afee8543d3be4c6c1e7de79803e75bba 100644 --- a/shell/platform/ohos/compatibility/ohos_accessibility_interface.h +++ b/shell/platform/ohos/compatibility/ohos_accessibility_interface.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ /** diff --git a/shell/platform/ohos/config/BUILD.gn b/shell/platform/ohos/config/BUILD.gn index d8a2dd87c9a984b7392d1658c1fb80b0df9b6c68..d2ee6dd563b4129a4c9d52b066fe8c04bebe6f34 100644 --- a/shell/platform/ohos/config/BUILD.gn +++ b/shell/platform/ohos/config/BUILD.gn @@ -1,15 +1,6 @@ -# Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +# Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE_KHZG file. #import("//build/config/linux/pkg_config.gni") import("//flutter/shell/platform/glfw/config.gni") diff --git a/shell/platform/ohos/context/ohos_context.cpp b/shell/platform/ohos/context/ohos_context.cpp index e436459390a0f9e7a2af97d33822c1026cd5f056..a3334afe3589c5bf4d5c33d65513ebae1845ad41 100644 --- a/shell/platform/ohos/context/ohos_context.cpp +++ b/shell/platform/ohos/context/ohos_context.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/context/ohos_context.h" diff --git a/shell/platform/ohos/context/ohos_context.h b/shell/platform/ohos/context/ohos_context.h index 84cdeb5820f055aab74deaaf36f7981878110468..3afcc6d61d591bdc4929574ce42f9d17232ed763 100644 --- a/shell/platform/ohos/context/ohos_context.h +++ b/shell/platform/ohos/context/ohos_context.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef OHOS_CONTEXT_H diff --git a/shell/platform/ohos/flutter_embedding/AppScope/app.json5 b/shell/platform/ohos/flutter_embedding/AppScope/app.json5 index 0b4a7d6f8a902ee0001e139801488216ddf4dc65..deb522e37eb74fe8716d4b416a709822dc076b98 100755 --- a/shell/platform/ohos/flutter_embedding/AppScope/app.json5 +++ b/shell/platform/ohos/flutter_embedding/AppScope/app.json5 @@ -1,17 +1,4 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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": { diff --git a/shell/platform/ohos/flutter_embedding/application/build-profile.json5 b/shell/platform/ohos/flutter_embedding/application/build-profile.json5 index 682d223d55956f1d579037598b4bf59a743f03a0..5163aaf6781b856043dfb4bd0f6c2679d3bfda78 100644 --- a/shell/platform/ohos/flutter_embedding/application/build-profile.json5 +++ b/shell/platform/ohos/flutter_embedding/application/build-profile.json5 @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ { "apiType": "stageMode", "buildOption": { diff --git a/shell/platform/ohos/flutter_embedding/application/hvigorfile.ts b/shell/platform/ohos/flutter_embedding/application/hvigorfile.ts index c71da0f0404c356f45efa2e7937985e219bf0460..f09851a6d95d0dcbd45b4fc0f7f3c3cb681e7f29 100644 --- a/shell/platform/ohos/flutter_embedding/application/hvigorfile.ts +++ b/shell/platform/ohos/flutter_embedding/application/hvigorfile.ts @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { hapTasks } from '@ohos/hvigor-ohos-plugin'; export default { diff --git a/shell/platform/ohos/flutter_embedding/application/oh-package.json5 b/shell/platform/ohos/flutter_embedding/application/oh-package.json5 index 9472ce464004acd9f5ecb8eced4e8ec9b0d6f099..54e012fbb8c7fefaa61f97e6c77b104685d81969 100644 --- a/shell/platform/ohos/flutter_embedding/application/oh-package.json5 +++ b/shell/platform/ohos/flutter_embedding/application/oh-package.json5 @@ -1,18 +1,3 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ { "name": "application", "version": "1.0.0", diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationability/ApplicationAbility.ets b/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationability/ApplicationAbility.ets index 11cc563d8fab01c4fe5bc0d083ec1c665986e25d..9b48b772ff298c2a591bd25282cf524d8e69bad3 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationability/ApplicationAbility.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationability/ApplicationAbility.ets @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationbackupability/ApplicationBackupAbility.ets b/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationbackupability/ApplicationBackupAbility.ets index 10ae96d62540755d875f7583986c0db254c34693..48e667bacb847517c2cc7dce81ec27e57858f494 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationbackupability/ApplicationBackupAbility.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationbackupability/ApplicationBackupAbility.ets @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ import { hilog } from '@kit.PerformanceAnalysisKit'; import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/ets/pages/Index.ets b/shell/platform/ohos/flutter_embedding/application/src/main/ets/pages/Index.ets index 81b53999e62d7f257e58d089da9d919c07340712..05d5092d9305d21049e199a0088be090282d5d8e 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/main/ets/pages/Index.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/main/ets/pages/Index.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + @Entry @Component struct Index { diff --git a/shell/platform/ohos/flutter_embedding/application/src/mock/mock-config.json5 b/shell/platform/ohos/flutter_embedding/application/src/mock/mock-config.json5 index 99db04adcdb49dc11ab59844a6b78fc81baace24..9d0b266f6732debf22fb362d44824f49a3346ac2 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/mock/mock-config.json5 +++ b/shell/platform/ohos/flutter_embedding/application/src/mock/mock-config.json5 @@ -1,17 +1,3 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ { } \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/FlutterInjector.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/FlutterInjector.test.ets index ab342916e2b8c1c8c3cd11b7b9e46402c7702c9e..5ad36af00fd206bb4c459cb7074a05952d30e6cb 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/FlutterInjector.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/FlutterInjector.test.ets @@ -1,17 +1,3 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import { describe, it, expect } from '@ohos/hypium' import { FlutterInjector } from "@ohos/flutter_ohos"; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/List.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/List.test.ets index 80151e3685194032e62e448b1c8e45c70ccc0e4b..3da316fe51bfcf707b3420d60e1bda3527afac4a 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/List.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/List.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import FlutterAbilityAndEntryDelegateTest from './embedding/ohos/FlutterAbilityAndEntryDelegateTest.test'; import FlutterAbilityTest from './embedding/ohos/FlutterAbilityTest.test'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineCacheTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineCacheTest.test.ets index 73e9ca9573361219b5d2c9e536f9b7abdf76576d..ca9678aa19bd96841418d03a8b97424afc362037 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineCacheTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineCacheTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import FlutterEngine from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine'; import FlutterEngineCache from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineCache'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineConnectionRegistryTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineConnectionRegistryTest.test.ets index 01925e7b0ebc20c1dc447303f8bb65d0e707eaf4..ad92e1e3c53b763557737e294dfef8ca7effe6cc 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineConnectionRegistryTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineConnectionRegistryTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, beforeAll, it, expect } from '@ohos/hypium'; import { FlutterPlugin, } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/FlutterPlugin'; import FlutterEngine from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupCacheTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupCacheTest.test.ets index 647b3e0e8292f03d21e58ad56144f3af5cfd83ce..500d8d5195040f6390104fee35d6b8219ef8e5c9 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupCacheTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupCacheTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, expect, it } from '@ohos/hypium'; import FlutterEngineGroupCache from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroupCache'; import { FlutterEngineGroup } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupTest.test.ets index f0190788bd496bdeefc622de38ef6ccbc1685746..378316ed98ac4198b3aefd2fcddf5854298c9fc1 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, expect, it } from '@ohos/hypium'; import FlutterEngineGroup, { Options } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroup'; import { FlutterEngine } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineTest.test.ets index fc91be86a45e6600bea65db4920ec7b0ed4a2193..06c5dffb66c7f2dc4fcf96c7939f6f01a433024f 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, beforeAll, it, expect } from '@ohos/hypium'; import DartExecutor, { DartEntrypoint } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/dart/DartExecutor'; import { Options } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroup'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterNapiTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterNapiTest.test.ets index 6ee93ce6ad0f9ac77f61cd50671c57f5b52e5bdd..b7a57a9a0cbcc1fb5848ec43b8cbf636ca2ecf6c 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterNapiTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterNapiTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import FlutterNapi from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi'; import ApplicationInfoLoader from '@ohos/flutter_ohos/src/main/ets/embedding/engine/loader/ApplicationInfoLoader'; import { FlutterRenderer } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/renderer/FlutterRenderer'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterOverlaySurfaceTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterOverlaySurfaceTest.test.ets index b98eaccdbeee59bb2c66bd0868981ee204bda1d1..c48e6f72a55f3979dd641e3416827826355ba2b9 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterOverlaySurfaceTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterOverlaySurfaceTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, beforeAll, expect, it } from '@ohos/hypium'; import { FlutterOverlaySurface } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterOverlaySurface'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterShellArgsTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterShellArgsTest.test.ets index b92df1429d92e30c588cb5ffbe5d55eeb0090512..d25149cefe4e757a4113307e131a96a1e2755f35 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterShellArgsTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterShellArgsTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, expect, it } from '@ohos/hypium'; import { abilityDelegatorRegistry } from '@kit.TestKit'; import { Want } from '@kit.AbilityKit'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartExecutorTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartExecutorTest.test.ets index 6577fa556cb0f9eeffe2c09f6450da5dbdb91d21..ee713e510291ef970027109bd5bbe5b7dd27c946 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartExecutorTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartExecutorTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, beforeAll, expect, it } from '@ohos/hypium'; import { common } from '@kit.AbilityKit'; import { Options } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroup'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartMessengerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartMessengerTest.test.ets index c48bad263fdf8725e88eaa658ec3acb6a53daf08..41d4bc0c458cb586c97c4c82444456b62dbecdf0 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartMessengerTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartMessengerTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { DartMessenger} from '@ohos/flutter_ohos/src/main/ets/embedding/engine/dart/DartMessenger' import { describe,it, expect } from '@ohos/hypium'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/ApplicationInfoTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/ApplicationInfoTest.test.ets index 00fe21a0e9ff9560f6e1ea5c669e18c83d20dff4..c5dcd6aaa54f4f364e1a8f670fd176a0dfc4db04 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/ApplicationInfoTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/ApplicationInfoTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import common from '@ohos.app.ability.common'; import ApplicationInfoLoader from '@ohos/flutter_ohos/src/main/ets/embedding/engine/loader/ApplicationInfoLoader' diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterApplicationInfoTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterApplicationInfoTest.test.ets index 7556ae740f126c2e0e213045eb25a60b2b33b58f..cf65b75912ddc4ffe664a7ca6aaa55bc1eec2702 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterApplicationInfoTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterApplicationInfoTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import FlutterApplicationInfo from '@ohos/flutter_ohos/src/main/ets/embedding/engine/loader/FlutterApplicationInfo' import { describe, it, expect } from '@ohos/hypium'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterLoaderTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterLoaderTest.test.ets index 52e231dcd95db99780fcc6631a90c7b57e7adcbf..177dfde1fb0173f6de53aa14aaabfa7c8bd50646 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterLoaderTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterLoaderTest.test.ets @@ -1,17 +1,3 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import common from '@ohos.app.ability.common'; import FlutterLoader from '@ohos/flutter_ohos/src/main/ets/embedding/engine/loader/FlutterLoader' diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorViewTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorViewTest.test.ets index 4924e8b78ad3cde41b4c74e0f07a4cb33fab9234..089753a796a0211fed0eda5cd29ea5ee255d4334 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorViewTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorViewTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { FlutterMutatorView } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorView' import { describe,it, expect } from '@ohos/hypium'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorsStackTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorsStackTest.test.ets index 4c633425ba780a04fae007d44cc50f759b5787dd..b902e76cf01716b8676b4fbb8b0e62c9982a1af2 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorsStackTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorsStackTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import common from '@ohos.app.ability.common'; import { diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/renderer/FlutterRendererTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/renderer/FlutterRendererTest.test.ets index 169f510280b480861703ce4c3054f6adaddaf834..800bac92ec94227a065f4338db58fa646d59a2c2 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/renderer/FlutterRendererTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/renderer/FlutterRendererTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe,it, expect } from '@ohos/hypium'; import { FlutterRenderer} from '@ohos/flutter_ohos/src/main/ets/embedding/engine/renderer/FlutterRenderer'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/LifecycleChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/LifecycleChannel.test.ets index 61590d082192e7d588d84d266ad9768c34248ebc..33cc9c137c583b45d1501861f682251e27e5c9e1 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/LifecycleChannel.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/LifecycleChannel.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, beforeEach, it, expect } from '@ohos/hypium' import LifecycleChannel from '@ohos/flutter_ohos/src/main/ets/embedding/engine/systemchannels/LifecycleChannel'; import Any from '@ohos/flutter_ohos/src/main/ets/plugin/common/Any'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/PlatformChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/PlatformChannel.test.ets index 1b6bb22329b4c9703ffc87264be2b2ae07c0b4cc..bce4baaabed81d409782cd85d818b154391a9ba5 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/PlatformChannel.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/PlatformChannel.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, expect, it, } from "@ohos/hypium"; import { AsyncCallback as _AsyncCallback } from '@ohos.base'; import PlatformChannel, { diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/RestorationChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/RestorationChannel.test.ets index 7a692e1ad8a4cb8039133306c77e8c75de062f13..dcd8266c87fb57516372e5cb031d7c287468b9ab 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/RestorationChannel.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/RestorationChannel.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { DartExecutor, diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/SettingsChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/SettingsChannel.test.ets index ae6ac3ed607cbaba74fe39bf5fd1582ce7777f13..8f0bdfb7742e644137031985a0dc6784541958a9 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/SettingsChannel.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/SettingsChannel.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, expect, it } from "@ohos/hypium"; import { resourceManager } from "@kit.LocalizationKit"; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/TextInputChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/TextInputChannel.test.ets index 5266cefa3ce4b7bff9e407f60965f64d7d152ea8..a150fb058a494c7f6789fbf53380606327ba5605 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/TextInputChannel.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/TextInputChannel.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, expect, it } from "@ohos/hypium"; import { resourceManager } from "@kit.LocalizationKit"; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityAndEntryDelegateTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityAndEntryDelegateTest.test.ets index 3c7d611d7804e28e8dc217abb1687506f3709afe..ae6aca8d7de6694e7511172263224b391cf15e51 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityAndEntryDelegateTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityAndEntryDelegateTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { abilityDelegatorRegistry } from '@kit.TestKit'; import AbilityConstant from '@ohos.app.ability.AbilityConstant'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityTest.test.ets index 7954b9f73bd6029d45d078d538a5b4d5b64844fa..045620c6a222fbcab279bba0374df810a95daade 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { abilityDelegatorRegistry } from '@kit.TestKit'; import { Want } from '@kit.AbilityKit'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterEntryTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterEntryTest.test.ets index 5d9ba80399bee3221d96352e3a837e7dbace6bcd..0f22656162657e3c9006c3abcd7fca7abe3d74be 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterEntryTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterEntryTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { FlutterEngine, FlutterPlugin, FlutterEntry } from "@ohos/flutter_ohos"; import { FlutterPluginBinding } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/FlutterPlugin'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterManagerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterManagerTest.test.ets index 3740524e877cbe889f73c3ee07783605ca8bbaf9..4f8832a8f0b01e189c48fecef97c554c150892eb 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterManagerTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterManagerTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect, beforeAll } from '@ohos/hypium'; import { FlutterManager } from "@ohos/flutter_ohos"; import { window } from '@kit.ArkUI'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/SettingTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/SettingTest.test.ets index d9a0489034f3d8134bfa5f65309f0b3532385f0d..18e573a363f47b1fb905f3ae1a25e9def932f639 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/SettingTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/SettingTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { Settings } from "@ohos/flutter_ohos"; import { MediaQuery } from '@kit.ArkUI'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventProcessorTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventProcessorTest.test.ets index dc72a1450d2c27e4f03ed6d48e08d6eb0c04af15..327e24e604d1970b7d58dd1731ae0b22b24d2e87 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventProcessorTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventProcessorTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import TouchEventProcessor from '@ohos/flutter_ohos/src/main/ets/embedding/ohos/TouchEventProcessor'; import { CustomTouchEvent } from '@ohos/flutter_ohos/src/main/ets/plugin/platform/CustomTouchEvent'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventTrackerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventTrackerTest.test.ets index fc93b33e7bf0e95e7b8efab23c6a36d504c92a02..8d98055472bbc3a41c944f2714ed65b2586864f8 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventTrackerTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventTrackerTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { TouchEventId, TouchEventTracker } from '@ohos/flutter_ohos/src/main/ets/embedding/ohos/TouchEventTracker'; import { TouchEvent } from '@ohos.multimodalInput.touchEvent'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapperTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapperTest.test.ets index 92a803725bdb47d4cd8f18837ca9897e8bfab434..c4c538f654303ac9badeb5ae3bfe2a45f864b984 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapperTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapperTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import WindowInfoRepositoryCallbackAdapterWrapper from '@ohos/flutter_ohos/src/main/ets/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapper'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryCodecTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryCodecTest.test.ets index cd1f7813dd991c0d0c271cfb08abd7f4208124e5..021ee3e35c90a3a04036a134b9ce4947431eaa6f 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryCodecTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryCodecTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { BinaryCodec } from "@ohos/flutter_ohos"; import { buffer } from '@kit.ArkTS'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryMessengerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryMessengerTest.test.ets index b746c7968235d512006395e13bc835e68f500904..27a37e651354ee1daa818817df28be8895a11605 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryMessengerTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryMessengerTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, expect, it } from '@ohos/hypium'; import { BinaryMessageHandler, diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/FlutterException.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/FlutterException.test.ets index fbdeee4dbff3e606214ea352bc00a90e348587f2..eff4cd253fc15b244a115f2913542f894eb9bf09 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/FlutterException.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/FlutterException.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import FlutterException from '@ohos/flutter_ohos/src/main/ets/plugin/common/FlutterException'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMessageCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMessageCodec.test.ets index 72e75a218edd09f4eb51904755eabd34cc45568a..788e928d4c6cd8627e6e1e754f39a1c32dd390a4 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMessageCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMessageCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import JSONMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/JSONMessageCodec'; import StringUtils from '@ohos/flutter_ohos/src/main/ets/util/StringUtils'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMethodCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMethodCodec.test.ets index 9e4a471e515ac93b7b676c01cec9693a4601fa4a..5bd0e9bbafedbf4a7ca73bd29ef4b39581186b87 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMethodCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMethodCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { Any, JSONMethodCodec, MethodCall } from "@ohos/flutter_ohos"; import { describe, expect, it, MockKit, when } from "@ohos/hypium"; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/MethodCall.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/MethodCall.test.ets index 0d69393e7d0baa9f828eb648b41e74bf726f1c37..4f551ab3c9823da4aa3de87178583b0ac28dad2b 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/MethodCall.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/MethodCall.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { MethodCall } from "@ohos/flutter_ohos"; import { describe, expect, it } from "@ohos/hypium"; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableBinaryCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableBinaryCodec.test.ets index f8174e51fb2dcf352b0fa49da12a453a7bf5729f..a2d04318d3a2f7ae1d36b0352c82fc798e038f3a 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableBinaryCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableBinaryCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import { SendableBinaryCodec } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMessageCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMessageCodec.test.ets index 4ee7d40da6f3aae759a6e5ca65facc5c00978b81..90723d3b1873b246cc374541b12361976bf09dbe 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMessageCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMessageCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import SendableJSONMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableJSONMessageCodec'; import StringUtils from '@ohos/flutter_ohos/src/main/ets/util/StringUtils' diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMethodCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMethodCodec.test.ets index 225ab226f07e4cd02cd9fbe942f2cb24f4960c48..b5f6b85f3bc1d1e20d1075bd8f35e704409130a6 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMethodCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMethodCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import SendableJSONMethodCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableJSONMethodCodec'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMessageCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMessageCodec.test.ets index b86d5cfe1cb0f46cea0563213c5d640c485d8f0d..3bafa98c6934c47181c84f8d2f68fa6537eb44a3 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMessageCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMessageCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import Any from '@ohos/flutter_ohos/src/main/ets/plugin/common/Any'; import SendableStandardMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableStandardMessageCodec'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMethodCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMethodCodec.test.ets index 7257b488ba54ea90442f429e6e53c0411f9686fa..8fbb945c7604a7521b728255263524bf8b177dd6 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMethodCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMethodCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import SendableStandardMethodCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableStandardMethodCodec'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStringCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStringCodec.test.ets index 7a5d4a3b8b0fbeab9018b13e4d91b0b02b7e663a..34fb4b6f7d1e48d239489ae11ad4fd7f4ed360db 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStringCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStringCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import StringCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableStringCodec' import StringUtils from '@ohos/flutter_ohos/src/main/ets/util/StringUtils' diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMessageCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMessageCodec.test.ets index 21ce334f7975ae9195e540c7f9e7af5b1d22d073..7b26b79e2e4467b0be6f85e88728a080451f8ad9 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMessageCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMessageCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import Any from '@ohos/flutter_ohos/src/main/ets/plugin/common/Any'; import StandardMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StandardMessageCodec'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMethodCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMethodCodec.test.ets index 034ddafc1f3f800251b42ba84e4fcd11d6b447da..3d9672a1e410abce29f67f52901d0b647fda9adf 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMethodCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMethodCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import StandardMethodCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StandardMethodCodec'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StringCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StringCodec.test.ets index 74780cd0851e1b109553120ece81627956e79f70..5d79dee6d164f9072fde34f8627c9ee975bacd01 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StringCodec.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StringCodec.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import StringCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StringCodec' import StringUtils from '@ohos/flutter_ohos/src/main/ets/util/StringUtils' diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/ListenableEditingState.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/ListenableEditingState.test.ets index 1c6f9e070af6e0a4c66e92dc288f8fc089b366f8..fa1d6a164172b22ecafba7ed7ecb68f06dde5aaf 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/ListenableEditingState.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/ListenableEditingState.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { EditingStateWatcher, ListenableEditingState } from '@ohos/flutter_ohos/src/main/ets/plugin/editing/ListenableEditingState'; @@ -31,13 +18,6 @@ export default function ListenableEditingStateTest() { expect(editingState.getSelectionStart()).assertEqual(5); expect(editingState.getSelectionEnd()).assertEqual(5); }) - - it('should handle delete event correctly (right)', 0, () => { - editingState.handleDeleteEvent(true, 1); - expect(editingState.getStringCache()).assertEqual('hello'); - expect(editingState.getSelectionStart()).assertEqual(5); - expect(editingState.getSelectionEnd()).assertEqual(5); - }) it('should handle newline event correctly', 0, () => { editingState.handleNewlineEvent(); expect(editingState.getStringCache()).assertEqual('hello\n'); diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextEditingDelta.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextEditingDelta.test.ets index 418797d0ea4efb4fe12770948cdb5ccd118e9651..4d8000ba17861521f5f70b2b90f03810481daed8 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextEditingDelta.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextEditingDelta.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { TextEditingDelta } from '@ohos/flutter_ohos/src/main/ets/plugin/editing/TextEditingDelta'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextInputPlugin.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextInputPlugin.test.ets index eb05ddadc5a08f19b518bd91805226cf86b9fe9f..dace31fa753618b05dd19bdf303dc825f19d202b 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextInputPlugin.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextInputPlugin.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, beforeEach, it, expect } from '@ohos/hypium' import TextInputChannel from '@ohos/flutter_ohos/src/main/ets/embedding/engine/systemchannels/TextInputChannel'; import TextInputPlugin from '@ohos/flutter_ohos/src/main/ets/plugin/editing/TextInputPlugin'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/localization/LocalizationPlugin.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/localization/LocalizationPlugin.test.ets index 36d725f79f8c1deeaebaaf23c29239aa4dce3d46..655a7ca44c0e41851fe2074c8ae939c383abb435 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/localization/LocalizationPlugin.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/localization/LocalizationPlugin.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, beforeEach, it, expect } from '@ohos/hypium'; import LocalizationPlugin from '@ohos/flutter_ohos/src/main/ets/plugin/localization/LocalizationPlugin'; import common from '@ohos.app.ability.common'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/AccessibilityEventsDelegate.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/AccessibilityEventsDelegate.test.ets index 847ec183b739227893a48feebf2b316331bf4700..4ffa7c756e0720ffe3614b60b339834b7d665d73 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/AccessibilityEventsDelegate.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/AccessibilityEventsDelegate.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { AccessibilityBridge, AccessibilityEventsDelegate } from "@ohos/flutter_ohos"; import { describe, expect, it } from "@ohos/hypium"; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformOverlayView.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformOverlayView.test.ets index 4ddd8fe65fb3ba510ada07e9ec41f42fa1d9c448..7d84424302de5a68c99bafc57b61d3b8e17d1203 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformOverlayView.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformOverlayView.test.ets @@ -1,17 +1,3 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import { describe, it, expect } from '@ohos/hypium' import { AccessibilityEventsDelegate, PlatformOverlayView } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformView.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformView.test.ets index 4369f8d25fcc52fcb47d0977c21e6c5428a7bf23..6fd3d55135861796904c69ce76b62c895a3f3af7 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformView.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformView.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import { PlatformView } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewRegistryImplTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewRegistryImplTest.test.ets index deaca608fc0efdf7c1ac59a14d5ed7f58385ed00..203ba76be8a0ad303d462217141e91bec8280933 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewRegistryImplTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewRegistryImplTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { PlatformViewRegistryImpl, PlatformViewFactory } from "@ohos/flutter_ohos"; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewWrapperTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewWrapperTest.test.ets index 2926252aeba5bf4fdc8d2958138dd324b7de7099..b4b1c554c52542866aec2e99fdfd6f2d84a1f6e7 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewWrapperTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewWrapperTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { PlatformViewWrapper, OhosTouchProcessor } from "@ohos/flutter_ohos"; import { DVModel, DVModelParameters } from '@ohos/flutter_ohos/src/main/ets/view/DynamicView/dynamicView'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewsControllerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewsControllerTest.test.ets index 7bbe3eef5defb416d832201ca8003e3a6c88f89b..cf1c0644fcaeac3d252707517f7317e95d14431a 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewsControllerTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewsControllerTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { PlatformViewsController, diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RawPointerCoordTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RawPointerCoordTest.test.ets index c26c4ee7f27c30af6e9c9a3fc1212ae41ae0a974..3819990185df968bd08c3ecf5da9d8f68cbbf2fd 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RawPointerCoordTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RawPointerCoordTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { RawPointerCoords } from '@ohos/flutter_ohos/src/main/ets/plugin/platform/RawPointerCoord'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RootDvModelManagerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RootDvModelManagerTest.test.ets index 3bc489d587d5d382a42ce209527180e2df6169e8..403c4a42e8ab11684c9908b8cc8399018e7615a9 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RootDvModelManagerTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RootDvModelManagerTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium'; import { PlatformViewWrapper } from '@ohos/flutter_ohos'; import { RootDvModeManager } from '@ohos/flutter_ohos/src/main/ets/plugin/platform/RootDvModelManager'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ByteBufferTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ByteBufferTest.test.ets index 536a5aed7110aff664c0a4ed7393874606b97f1d..fc85ef13d4ea6d3a5a5b771b69abce90b3677717 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ByteBufferTest.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ByteBufferTest.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect, afterAll } from '@ohos/hypium'; import { ByteBuffer } from "@ohos/flutter_ohos"; import { buffer } from '@kit.ArkTS'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/Log.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/Log.test.ets index 5ef0a0618adf56b8a7fe4921de38269c540a02de..e1e505f7d7f7cfc982923aec0ac792d67558fac7 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/Log.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/Log.test.ets @@ -1,17 +1,3 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import { describe, it, expect } from '@ohos/hypium' import { Log } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/MessageChannelUtils.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/MessageChannelUtils.test.ets index 60c39c1c12599a1cbfdae18b3a61512fb653b8df..713a6a2f48c2ba7047e3e6e655ac0f95d8f19ce2 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/MessageChannelUtils.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/MessageChannelUtils.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import { MessageChannelUtils } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/PathUtils.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/PathUtils.test.ets index 8f4283281840e0cc21ce3f9cb3999a9844111a3e..7248a4824999f5e8d8210a8dd06c71a26fbe7569 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/PathUtils.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/PathUtils.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import { PathUtils } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/StringUtils.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/StringUtils.test.ets index 693d0b188e914694bcd70ec1f73fe1ecdc3efe11..27cfb2252389340a19ad14c9ce694aeb06cd694b 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/StringUtils.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/StringUtils.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import { StringUtils } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ToolUtils.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ToolUtils.test.ets index 158170ba95c6516332eca4d3779b4a894d2f1ac5..6a7e34d88fa80a2328a318b12628f8d2f1063496 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ToolUtils.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ToolUtils.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import { ToolUtils } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/TraceSection.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/TraceSection.test.ets index b09b01f10931882f64cfb5b4413633b689e3a848..7ddbf39e2c6324e619135c869eed2d1360ed5f71 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/TraceSection.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/TraceSection.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, it, expect } from '@ohos/hypium' import { TraceSection } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/DynamicView/dynamicViewJson.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/DynamicView/dynamicViewJson.test.ets index 610a7f88c6202e029a0a0cdd772ce83e4ef3a0f7..65d362a1806c6547357f29904c3675b86b374f72 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/DynamicView/dynamicViewJson.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/DynamicView/dynamicViewJson.test.ets @@ -1,17 +1,3 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import { describe, it, expect } from '@ohos/hypium' import { createDVModelFromJson } from '@ohos/flutter_ohos/src/main/ets/view/DynamicView/dynamicViewJson'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/FlutterRunArguments.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/FlutterRunArguments.test.ets index a9d1a0787213b1e610aa61be37059c28328fdf0d..0264b23c8a545331844a187f6775e98a64e2d543 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/FlutterRunArguments.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/FlutterRunArguments.test.ets @@ -1,17 +1,3 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import { describe, it, expect } from '@ohos/hypium' import { FlutterRunArguments } from '@ohos/flutter_ohos'; diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/module.json5 b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/module.json5 index b4bf32fd9ef07bd62331aa8e09cae3029062b33a..e6ef64433f54208c3832e388e297c2005fe35da5 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/module.json5 +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/module.json5 @@ -1,18 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ { "module": { "name": "application_test", diff --git a/shell/platform/ohos/flutter_embedding/application/src/test/List.test.ets b/shell/platform/ohos/flutter_embedding/application/src/test/List.test.ets index 312f48fb747c89745bf9671ef83f93eabf0f12bc..af9973d97810340619e02e90ce1bfb8c20c8ef36 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/test/List.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/test/List.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import localUnitTest from './LocalUnit.test'; export default function testsuite() { diff --git a/shell/platform/ohos/flutter_embedding/application/src/test/LocalUnit.test.ets b/shell/platform/ohos/flutter_embedding/application/src/test/LocalUnit.test.ets index 8ca1b6da13fdc210635bd5e33d64370f1948557e..5fcdc0f8152fb24f5182b4a939601264fa3009f1 100644 --- a/shell/platform/ohos/flutter_embedding/application/src/test/LocalUnit.test.ets +++ b/shell/platform/ohos/flutter_embedding/application/src/test/LocalUnit.test.ets @@ -1,17 +1,4 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; export default function localUnitTest() { diff --git a/shell/platform/ohos/flutter_embedding/build-profile.json5 b/shell/platform/ohos/flutter_embedding/build-profile.json5 index c4150bb5a34dad87dcf290216414a834138b28aa..692325fe24fc045b5c922ce02215ffa00d7029c9 100755 --- a/shell/platform/ohos/flutter_embedding/build-profile.json5 +++ b/shell/platform/ohos/flutter_embedding/build-profile.json5 @@ -1,17 +1,4 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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": { diff --git a/shell/platform/ohos/flutter_embedding/flutter/build-profile.json5 b/shell/platform/ohos/flutter_embedding/flutter/build-profile.json5 index b93937f294390a491253ad2a1f987a53b1d942d4..e395590b6f9c6f09e319948941e25a0f52a09d27 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/build-profile.json5 +++ b/shell/platform/ohos/flutter_embedding/flutter/build-profile.json5 @@ -1,17 +1,4 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. -*/ + { "apiType": "stageMode", diff --git a/shell/platform/ohos/flutter_embedding/flutter/hvigorfile.ts b/shell/platform/ohos/flutter_embedding/flutter/hvigorfile.ts index eb1f1d089d8fbdcd5ea7af33ecb70f3c8b5bdfce..f2c2731f054e49694c53a491df05111b189c642f 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/hvigorfile.ts +++ b/shell/platform/ohos/flutter_embedding/flutter/hvigorfile.ts @@ -1,17 +1,3 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. -*/ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/index.ets b/shell/platform/ohos/flutter_embedding/flutter/index.ets index 8e44d572561bacb5f4f11cf0da363584980be719..cc343613fe7116974da8e5c7211c359189c816f7 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/index.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/index.ets @@ -1,17 +1,4 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { default as FlutterInjector } from './src/main/ets/FlutterInjector'; export { default as FlutterPluginRegistry } from './src/main/ets/app/FlutterPluginRegistry'; @@ -60,6 +47,7 @@ export { default as FlutterAbilityLaunchConfigs } from './src/main/ets/embedding export { default as FlutterEngineConfigurator } from './src/main/ets/embedding/ohos/FlutterEngineConfigurator'; export { default as FlutterEngineProvider } from './src/main/ets/embedding/ohos/FlutterEngineProvider'; export { default as FlutterEntry } from './src/main/ets/embedding/ohos/FlutterEntry'; +export { default as FlutterWindow } from './src/main/ets/embedding/ohos/FlutterWindow'; export { default as FlutterManager, DragDropCallback as DragDropCallback } from './src/main/ets/embedding/ohos/FlutterManager'; export * from './src/main/ets/embedding/ohos/FlutterPage'; export { default as KeyboardManager } from './src/main/ets/embedding/ohos/KeyboardManager'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/oh-package.json5 b/shell/platform/ohos/flutter_embedding/flutter/oh-package.json5 index 39bbaa64c01def1568782d0af4659f2391b78fad..e7d8b53cc17c57ea016ef9703d7f7e04589e1ec2 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/oh-package.json5 +++ b/shell/platform/ohos/flutter_embedding/flutter/oh-package.json5 @@ -1,17 +1,4 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. -*/ + { "license": "Apache-2.0", diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets index 629988a8937eed70c95f0b912e66693a7f247087..99aa2d54f7ac2c33aa6685fe452d46060937387a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/index.d.ets @@ -1,17 +1,3 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 common from '@ohos.app.ability.common'; import resourceManager from '@ohos.resourceManager'; @@ -133,6 +119,8 @@ export const nativeRegisterPixelMap: (nativeShellHolderId: number, textureId: nu export const nativeSetTextureBackGroundPixelMap: (nativeShellHolderId: number, textureId: number, pixelMap: PixelMap) => void; +export const nativeSetTextureBackGroundColor: (nativeShellHolderId: number, textureId: number, color: number) => void; + export const nativeRegisterTexture: (nativeShellHolderId: number, textureId: number) => number; export const nativeEncodeUtf8: (str: string) => Uint8Array; @@ -148,7 +136,13 @@ export const nativeSetAccessibilityFeatures: (accessibilityFeatureFlags: number, export const nativeAccessibilityStateChange: (nativeShellHolderId: number, state: Boolean) => void; -export const nativeAnnounce: (message: string) => void; +export const nativeAccessibilityAnnounce: (message: string) => void; + +export const nativeAccessibilityOnTap: (nodeId: number) => void; + +export const nativeAccessibilityOnLongPress: (nodeId: number) => void; + +export const nativeAccessibilityOnTooltip: (message: string) => void; export const nativeSetSemanticsEnabled: (nativeShellHolderId: number, enabled: boolean) => void; @@ -169,4 +163,8 @@ export const nativeUnicodeIsEmojiModifierBase: (code: number) => number; export const nativeUnicodeIsVariationSelector: (code: number) => number; -export const nativeUnicodeIsRegionalIndicatorSymbol: (code: number) => number; \ No newline at end of file +export const nativeUnicodeIsRegionalIndicatorSymbol: (code: number) => number; + +export const nativeGetXComponentId: (id: string) => number; + +export const nativeSetDVsyncSwitch: (nativeShellHolderId: number, isEnable: boolean) => void; \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/oh-package.json5 b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/oh-package.json5 index 5d1822ef86535e3d92242c5cb99af8dd46b2204f..68c9ab9fc9f00736d3201c7f372c6dde4ae67445 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/oh-package.json5 +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/cpp/types/libflutter/oh-package.json5 @@ -1,17 +1,4 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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": "libflutter.so", diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/FlutterInjector.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/FlutterInjector.ets index f7ac83e3a0e83b9bcec0b942d6a958b209fc061b..2e683937fa6f05730dd2d2d2e686681cfba9ab8f 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/FlutterInjector.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/FlutterInjector.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import FlutterNapi from './embedding/engine/FlutterNapi'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/app/FlutterPluginRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/app/FlutterPluginRegistry.ets index 758b5f6e1ce5fd7c97312ab4cc0cfe76954fc422..a121b7ee5d682597c95398c1c78a518d4fa06319 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/app/FlutterPluginRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/app/FlutterPluginRegistry.ets @@ -1,16 +1,8 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* 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 { FlutterView } from '../view/FlutterView'; import common from '@ohos.app.ability.common'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/FlutterComponent.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/FlutterComponent.ets index 07497e672b21c51727c1a45166504e19603e4063..d957ccf7a10f56618a2b771b41e8217eb85b2b46 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/FlutterComponent.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/FlutterComponent.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ /** diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets index cd3cd81923431aedd613734d5a7953624ec63f81..7939371e4149337c2ef1ab7d3d391b55a5158d20 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngine.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterEngine.java originally written by +* Copyright (C) Copyright 2013 The Flutter Authors. * -* 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 LifecycleChannel from './systemchannels/LifecycleChannel'; @@ -39,6 +34,7 @@ import LocalizationPlugin from '../../plugin/localization/LocalizationPlugin' import SettingsChannel from './systemchannels/SettingsChannel'; import PlatformViewsController from '../../plugin/platform/PlatformViewsController'; import { FlutterRenderer } from './renderer/FlutterRenderer'; +import NativeVsyncChannel from './systemchannels/NativeVsyncChannel'; const TAG = "FlutterEngine"; @@ -70,6 +66,7 @@ export default class FlutterEngine implements EngineLifecycleListener{ private localizationPlugin: LocalizationPlugin | null = null; private settingsChannel: SettingsChannel | null = null; private platformViewsController: PlatformViewsController; + private nativeVsyncChannel: NativeVsyncChannel | null = null; /** * 需要初始化的工作: @@ -125,6 +122,7 @@ export default class FlutterEngine implements EngineLifecycleListener{ this.accessibilityChannel = new AccessibilityChannel(this.dartExecutor, this.flutterNapi); this.flutterNapi.addEngineLifecycleListener(this); this.localizationPlugin = new LocalizationPlugin(context, this.localeChannel); + this.nativeVsyncChannel = new NativeVsyncChannel(this.dartExecutor, this.flutterNapi); // It should typically be a fresh, unattached NAPI. But on a spawned engine, the NAPI instance // is already attached to a native shell. In that case, the Java FlutterEngine is created around diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineCache.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineCache.ets index 7808dfd8afa1f7ad23e003028409cc18758dd616..acedb9122ac5865ffcd3742515c4f95efa4112e6 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineCache.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineCache.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterEngineCache.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 FlutterEngine from "./FlutterEngine" diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry.ets index bdcddb159e110ea3daace7a4983306835b333a46..6ea3fab9ddaf08014fd74782acb721a1c5138a3e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterEngineConnectionRegistry.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 PluginRegistry from './plugins/PluginRegistry'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets index bd4c494cc1543c76877f4518ac179c97da6bd0f9..45796626d77d49075f77c32e5f1567ef01eaab7a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroup.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterEngineGroup.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 FlutterEngine, { EngineLifecycleListener } from "./FlutterEngine" diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroupCache.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroupCache.ets index 645507a6d8a5fd2749a7ef3caf9a97ad1ec154eb..9e61f26bddf49296b97779185e37afb53f8574e0 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroupCache.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterEngineGroupCache.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import FlutterEngineGroup from './FlutterEngineGroup'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets index e36a5666822d8dfde8b31ffe32e10d7ac7b3729a..75ec3f3f3c59089553a1f107dba6427802541ef0 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import flutter from 'libflutter.so'; @@ -226,24 +217,12 @@ export default class FlutterNapi { , displayFeaturesType: Array, displayFeaturesState: Array): void { if (this.isAttached()) { flutter.nativeSetViewportMetrics(this.nativeShellHolderId!, devicePixelRatio, - physicalWidth, - physicalHeight, - physicalPaddingTop, - physicalPaddingRight, - physicalPaddingBottom, - physicalPaddingLeft, - physicalViewInsetTop, - physicalViewInsetRight, - physicalViewInsetBottom, - physicalViewInsetLeft, - systemGestureInsetTop, - systemGestureInsetRight, - systemGestureInsetBottom, - systemGestureInsetLeft, - physicalTouchSlop, - displayFeaturesBounds, - displayFeaturesType, - displayFeaturesState); + physicalWidth, physicalHeight, physicalPaddingTop, physicalPaddingRight, + physicalPaddingBottom, physicalPaddingLeft, physicalViewInsetTop, + physicalViewInsetRight, physicalViewInsetBottom, physicalViewInsetLeft, + systemGestureInsetTop, systemGestureInsetRight, systemGestureInsetBottom, + systemGestureInsetLeft, physicalTouchSlop, displayFeaturesBounds, + displayFeaturesType, displayFeaturesState); } } @@ -497,6 +476,11 @@ export default class FlutterNapi { flutter.nativeSetTextureBackGroundPixelMap(this.nativeShellHolderId!, textureId, pixelMap); } + setTextureBackGroundColor(textureId: number, color: number): void { + Log.d(TAG, "called setTextureBackGroundColor "); + flutter.nativeSetTextureBackGroundColor(this.nativeShellHolderId!, textureId, color); + } + registerTexture(textureId: number): number { Log.d(TAG, "called registerTexture "); if (!this.isAttached()) { @@ -570,6 +554,9 @@ export default class FlutterNapi { return Boolean(flutter.nativeUnicodeIsRegionalIndicatorSymbol(code)); } + SetDVsyncSwitch(isEnable: boolean): void { + flutter.nativeSetDVsyncSwitch(this.nativeShellHolderId!, isEnable); + } } export interface AccessibilityDelegate { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterOverlaySurface.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterOverlaySurface.ets index 2d63d83de313f52eba3f8fa6d2ed584f7bee44bd..00473afb69bd75bf93852bf219d6c302594ea5b6 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterOverlaySurface.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterOverlaySurface.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterOverlaySurface.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 class FlutterOverlaySurface { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterShellArgs.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterShellArgs.ets index 604c4900106515617821e8c43d3900ab1cd7d66b..d01c6709e55ea700422c36b8c35148ed00b2ae59 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterShellArgs.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterShellArgs.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterShellArgs.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Want from '@ohos.app.ability.Want'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/DartExecutor.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/DartExecutor.ets index 2c41446b2a710cbd3cf11aa7431b0ef8f5fdfac1..fdc79bfdec288be1fd77e9d88c47672fdc6d409e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/DartExecutor.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/DartExecutor.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on DartExecutor.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 resourceManager from '@ohos.resourceManager'; import FlutterInjector from '../../../FlutterInjector'; @@ -179,12 +174,13 @@ export default class DartExecutor implements BinaryMessenger { /** * Returns the number of pending channel callback replies. * - *

When sending messages to the Flutter application using {@link BinaryMessenger#send(String, + *

When sending messages to the Flutter application + * using {@link BinaryMessenger#send(String, * ByteBuffer, io.flutter.plugin.common.BinaryMessenger.BinaryReply)}, developers can optionally * specify a reply callback if they expect a reply from the Flutter application. * - *

This method tracks all the pending callbacks that are waiting for response, and is supposed - * to be called from the main thread (as other methods). Calling from a different thread could + *

This method tracks all the pending callbacks that are waiting for response, + * and is supposed to be called from the main thread (as other methods). Calling from a different thread could * possibly capture an indeterministic internal state, so don't do it. * *

Currently, it's mainly useful for a testing framework like Espresso to determine whether all @@ -333,8 +329,8 @@ export class DefaultBinaryMessenger implements BinaryMessenger { /** * Sets the given {@link io.flutter.plugin.common.BinaryMessenger.BinaryMessageHandler} as the - * singular handler for all incoming messages received from the Dart side of this Dart execution - * context. + * singular handler for all incoming messages received from the Dart side of + * this Dart execution context. * * @param channel the name of the channel. * @param handler a {@link BinaryMessageHandler} to be invoked on incoming messages, or null. diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/DartMessenger.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/DartMessenger.ets index a1773db5c745c9111fcc3fda82ccde07e0d50bd2..978bb22aa746813239b795a134cd7290325cbd4e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/DartMessenger.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/DartMessenger.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on DartMessenger.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { ErrorEvent, Queue, taskpool, worker, MessageEvents, JSON } from '@kit.ArkTS'; @@ -149,12 +144,12 @@ export class DartMessenger implements BinaryMessenger, PlatformMessageHandler { * Returns the number of pending channel callback replies. * *

When sending messages to the Flutter application using {@link BinaryMessenger#send(String, - * ByteBuffer, io.flutter.plugin.common.BinaryMessenger.BinaryReply)}, developers can optionally - * specify a reply callback if they expect a reply from the Flutter application. + * ByteBuffer, io.flutter.plugin.common.BinaryMessenger.BinaryReply)},developers can + * optionally specify a reply callback if they expect a reply from the Flutter application. * *

This method tracks all the pending callbacks that are waiting for response, and is supposed - * to be called from the main thread (as other methods). Calling from a different thread could - * possibly capture an indeterministic internal state, so don't do it. + * to be called from the main thread (as other methods). Calling from a different thread + * could possibly capture an indeterministic internal state, so don't do it. */ getPendingChannelResponseCount(): number { return this.pendingReplies.size; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/PlatformMessageHandler.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/PlatformMessageHandler.ets index b6e3411862cb936f4e9af2c6e0ab6a49be3c9dce..221be11bf72c5502741aa2878155a2bbd01dc2e3 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/PlatformMessageHandler.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/dart/PlatformMessageHandler.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformMessageHandler.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 interface PlatformMessageHandler { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/ApplicationInfoLoader.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/ApplicationInfoLoader.ets index 3c5bca80d380c5387ac2c872b35f860e3e8eacad..af38619d3b64bba9f0cbdec2977beb0d178bb916 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/ApplicationInfoLoader.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/ApplicationInfoLoader.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import FlutterApplicationInfo from './FlutterApplicationInfo'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterApplicationInfo.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterApplicationInfo.ets index e170586a89c865338c314cb4badc16772eb1b5c0..3fdc397e3ffd2fb9d0c4166be867b0df8f150cf9 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterApplicationInfo.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterApplicationInfo.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterApplicationInfo.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 BuildProfile from "../../../../../../BuildProfile"; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets index aaeb579a61b3b2415babfe5eeae14c7dd218616f..c5b764f63be268fbd877843509613f416cdc7b03 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/loader/FlutterLoader.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterLoader.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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. */ /** @@ -81,12 +76,12 @@ export default class FlutterLoader { /** * Starts initialization of the native system. * - *

This loads the Flutter engine's native library to enable subsequent JNI calls. This also - * starts locating and unpacking Dart resources packaged in the app's APK. + *

This loads the Flutter engine's native library to enable subsequent NAPI calls. This also + * starts locating and unpacking Dart resources packaged in the app's HAP. * *

Calling this method multiple times has no effect. * - * @param applicationContext The Android application context. + * @param applicationContext The Ohos application context. * @param settings Configuration settings. */ async startInitialization(context: common.Context) { @@ -240,6 +235,9 @@ export default class FlutterLoader { } getLookupKeyForAsset(asset: string, packageName?: string): string { + if (typeof packageName === 'string' && packageName.trim().length > 0) { + return this.fullAssetPathFrom('packages' + FILE_SEPARATOR + packageName + FILE_SEPARATOR + asset); + } return this.fullAssetPathFrom(asset); } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorView.ets index f439b570473a9abf5d278d2446b7965e11c3bc1d..4823741898abd6d5903cac22c37b70144719a139 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorView.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterMutatorView.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 ArrayList from '@ohos.util.ArrayList'; import matrix4 from '@ohos.matrix4'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorsStack.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorsStack.ets index 2f53c6c041bfd92ea74c3896d00a04f6b5590e2e..a71c0b9da6dc19fb2989d47a2ad54edafd8c4f7b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorsStack.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorsStack.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterMutatorsStack.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 matrix4 from '@ohos.matrix4' diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/FlutterPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/FlutterPlugin.ets index 92e08f8dd9c22e441ecfe852895522a7417f859b..28a0df9438d313dc067e46b2a638f9c1d39641fc 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/FlutterPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/FlutterPlugin.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterPlugin.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 common from '@ohos.app.ability.common'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/PluginRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/PluginRegistry.ets index 1a322ec2ba1bbcfcbce180b00ec4df6356733180..d8beda52973843876ed79d34a08ce83bfa19081a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/PluginRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/PluginRegistry.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PluginRegistry.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { FlutterPlugin } from './FlutterPlugin'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityAware.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityAware.ets index b3d9b9df83522545bef2893d26b02dc297c8b908..d6129d420b342c4570d44151598400602cd17c15 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityAware.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityAware.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ /** diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityControlSurface.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityControlSurface.ets index 947ccef4ba35c189f2c74f81c0f53eaf025cba36..1ecf2966b41bdb14fca91836dc6e3ddbf0247e7a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityControlSurface.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityControlSurface.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ import AbilityConstant from '@ohos.app.ability.AbilityConstant'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityPluginBinding.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityPluginBinding.ets index 349010b14ee70aff187ff938c146f14d6c7a080e..d7269d2e028e9738e0c69edef959c24933b6b17a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityPluginBinding.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/plugins/ability/AbilityPluginBinding.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ import UIAbility from '@ohos.app.ability.UIAbility' diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets index 9d00c43494d9784aadd88ee16b3f41ae561054f8..c1ffc886e32b13555e6d6a2d4c40c2ffbb1f9d75 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterRenderer.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import image from '@ohos.multimedia.image'; @@ -66,6 +57,10 @@ export class FlutterRenderer implements TextureRegistry { this.flutterNapi.setTextureBackGroundPixelMap(textureId, pixelMap); } + setTextureBackGroundColor(textureId: number, color: number): void { + this.flutterNapi.setTextureBackGroundColor(textureId, color); + } + setTextureBufferSize(textureId: number, width: number, height: number): void { this.flutterNapi.setTextureBufferSize(textureId, width, height); } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterUiDisplayListener.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterUiDisplayListener.ets index 2a0af4009cafd2cf5229f082a41ed2d445c69caa..334625667d51c5b93cd9bafd60b18a53b317d18a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterUiDisplayListener.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/FlutterUiDisplayListener.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterUiDisplayListener.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 interface FlutterUiDisplayListener { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets index b1da18061bc2398f9ce0acd5f9f2c42e248b9204..910745dce820e8997528ccc1869b635eebae643b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/renderer/SurfaceTextureWrapper.ets @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import image from '@ohos.multimedia.image'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/AccessibilityChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/AccessibilityChannel.ets index bbc5a658ea5c9af1e99f69a45e737b861fabcfd8..c743b3438c2c8f371c0e950df4ce0d76248718ae 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/AccessibilityChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/AccessibilityChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on AccessibilityChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Log from '../../../util/Log'; @@ -122,24 +117,32 @@ export interface AccessibilityMessageHandler extends AccessibilityDelegate { announce(message: string): void; onTap(nodeId: number): void; onLongPress(nodeId: number): void; - onTooltip(nodeId: string): void; + onTooltip(message: string): void; } export class DefaultHandler implements AccessibilityMessageHandler { - private static TAG = "AccessibilityMessageHandler"; + private static TAG = "AccessibilityMessageHandler"; + announce(message: string): void { Log.i(DefaultHandler.TAG, "handler announce."); - flutter.nativeAnnounce(message); + flutter.nativeAccessibilityAnnounce(message); } + onTap(nodeId: number): void { Log.i(DefaultHandler.TAG, "handler onTap."); + flutter.nativeAccessibilityOnTap(nodeId); } + onLongPress(nodeId: number): void { Log.i(DefaultHandler.TAG, "handler onLongPress."); + flutter.nativeAccessibilityOnLongPress(nodeId); } - onTooltip(nodeId: string): void { + + onTooltip(message: string): void { Log.i(DefaultHandler.TAG, "handler onTooltip."); + flutter.nativeAccessibilityOnTooltip(message); } + updateSemantics(buffer: ByteBuffer, strings: string[], stringAttributeArgs: ByteBuffer[]): void { Log.i(DefaultHandler.TAG, "handler updateSemantics"); } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/KeyEventChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/KeyEventChannel.ets index 4c863bc8bd38df145d113ebc57b01f41bcc40d7d..3b3c0e27111a2f89e7f748e24faa881660a47a99 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/KeyEventChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/KeyEventChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on KeyEventChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 BasicMessageChannel from '../../../plugin/common/BasicMessageChannel'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/LifecycleChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/LifecycleChannel.ets index ce5acbdbbae50078e7c339c767a34a178413bf2d..43de222074409ebbca20f2fb072e4000fe227323 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/LifecycleChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/LifecycleChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on LifecycleChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Log from '../../../util/Log'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/LocalizationChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/LocalizationChannel.ets index f8d8d27c935626c1e6962720fbc825a884e88a0d..f2ac95b25296e820c90d2fe7ed32e5236af8efd7 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/LocalizationChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/LocalizationChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on LocalizationChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 DartExecutor from '../dart/DartExecutor'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/MouseCursorChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/MouseCursorChannel.ets index 3e8b3d4167c3aeb9c08e657e8c504e7c51f5214d..2b431bf694f51051a5f71549f10b3a61eb3e517d 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/MouseCursorChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/MouseCursorChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on MouseCursorChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 HashMap from '@ohos.util.HashMap'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NativeVsyncChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NativeVsyncChannel.ets new file mode 100644 index 0000000000000000000000000000000000000000..2876b6fbb8501e7e0f88e6a6f011b7703f2090f1 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NativeVsyncChannel.ets @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 Hunan OpenValley Digital Industry Development 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 Log from '../../../util/Log'; +import DartExecutor from '../dart/DartExecutor'; +import BasicMessageChannel, { MessageHandler, Reply} from '../../../plugin/common/BasicMessageChannel'; +import HashMap from '@ohos.util.HashMap'; +import StandardMessageCodec from '../../../plugin/common/StandardMessageCodec'; +import StringUtils from '../../../util/StringUtils'; +import Any from '../../../plugin/common/Any'; +import FlutterNapi from '../FlutterNapi'; + +/** +* nativeVsync功能channel +*/ +export default class NativeVsyncChannel implements MessageHandler { + private static TAG = "NativeVsyncChannel"; + private static CHANNEL_NAME = "flutter/nativevsync"; + private channel: BasicMessageChannel; + private flutterNapi: FlutterNapi; + + onMessage(message: object, reply: Reply): void { + let data: HashMap = message as HashMap; + let isEnable: boolean = data.get("isEnable"); + this.flutterNapi.SetDVsyncSwitch(isEnable); + + Log.d(NativeVsyncChannel.TAG, `Received message: isEnable:$isEnable`); + reply.reply(StringUtils.stringToArrayBuffer("")); + } + + constructor(dartExecutor: DartExecutor, flutterNapi: FlutterNapi) { + Log.i(NativeVsyncChannel.TAG, "Channel entered"); + this.channel = new BasicMessageChannel( + dartExecutor, NativeVsyncChannel.CHANNEL_NAME, StandardMessageCodec.INSTANCE); + this.channel.setMessageHandler(this); + this.flutterNapi = flutterNapi; + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NavigationChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NavigationChannel.ets index f7ebcb6926eb490ed2ee21cb8927e5ed2a202632..5a28ca1d0126352f2eaeb8d87de45e02c5e59de8 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NavigationChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/NavigationChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on NavigationChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 JSONMethodCodec from '../../../plugin/common/JSONMethodCodec'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets index caf39c49165ef42fcd90c20e7c823f1a7eda01e9..bc67d38b9da4849a79e577adbc8ee8785337082b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformChannel.ets @@ -1,18 +1,14 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 hiTraceMeter from '@ohos.hiTraceMeter'; import JSONMethodCodec from '../../../plugin/common/JSONMethodCodec'; import MethodCall from '../../../plugin/common/MethodCall'; import MethodChannel, { MethodCallHandler, MethodResult } from '../../../plugin/common/MethodChannel'; @@ -175,6 +171,17 @@ export default class PlatformChannel { throw new Error("No such DeviceOrientation: " + encodedName); } + getScrollActivityFromValue(activity: string): ScrollActivity { + let activityTypes: string[] = [ + ScrollActivity.START, + ScrollActivity.END + ]; + if (activityTypes.includes(activity as ScrollActivity)) { + return activity as ScrollActivity; + } + throw new Error("No such ScrollActivity: " + activity); + } + } export enum HapticFeedbackType { @@ -282,6 +289,11 @@ export enum DeviceOrientation { LANDSCAPE_RIGHT = "DeviceOrientation.landscapeRight", } +export enum ScrollActivity { + START = "start", + END = "end", +} + class PlatformMethodCallback implements MethodCallHandler { private static TAG = "PlatformMethodCallback" platform: PlatformChannel; @@ -390,6 +402,9 @@ class PlatformMethodCallback implements MethodCallHandler { Log.e(PlatformMethodCallback.TAG, "systemPasteboard.hasData err: " + JSON.stringify(err)); }) break; + case "Scroll.Activity": + this.recordScrollActivity(args as string); + break; default: result.notImplemented(); break; @@ -476,4 +491,16 @@ class PlatformMethodCallback implements MethodCallHandler { systemNavigationBarContrastEnforced ); } + + private recordScrollActivity(scrollActivity: string) { + let activityType = this.platform.getScrollActivityFromValue(scrollActivity); + switch(activityType) { + case ScrollActivity.START: + hiTraceMeter.startTrace('flutter::APP_LIST_FING', 0); + break; + case ScrollActivity.END: + hiTraceMeter.finishTrace('flutter::APP_LIST_FING', 0); + break; + } + } } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformViewsChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformViewsChannel.ets index 0b602e31d8b92990082db1fd326c09496af0caa2..b35c113b0b8f2fbe649bcc379ba522a4e0d6d2b4 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformViewsChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/PlatformViewsChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformViewsChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Any from '../../../plugin/common/Any'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/RestorationChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/RestorationChannel.ets index c23d09ecb359444b07586fcbad448f941072634c..cc8068d5a19cd2056682321cde7d6d0fee8ef0dd 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/RestorationChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/RestorationChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on RestorationChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Any from '../../../plugin/common/Any'; @@ -25,15 +20,15 @@ import DartExecutor from '../dart/DartExecutor'; * System channel to exchange restoration data between framework and engine. * *

The engine can obtain the current restoration data from the framework via this channel to - * store it on disk and - when the app is relaunched - provide the stored data back to the framework - * to recreate the original state of the app. + * store it on disk and - when the app is relaunched - provide the stored data back to + * the framework to recreate the original state of the app. * *

The channel can be configured to delay responding to the framework's request for restoration * data via {@code waitForRestorationData} until the engine-side has provided the data. This is * useful when the engine is pre-warmed at a point in the application's life cycle where the * restoration data is not available yet. For example, if the engine is pre-warmed as part of the - * Application before an Activity is created, this flag should be set to true because Android will - * only provide the restoration data to the Activity during the onCreate callback. + * Application before an Activity is created, this flag should be set to true because Ohos + * will only provide the restoration data to the Activity during the onCreate callback. * *

The current restoration data provided by the framework can be read via {@code * getRestorationData()}. @@ -44,17 +39,17 @@ export default class RestorationChannel { private static CHANNEL_NAME = "flutter/restoration"; /** - * Whether the channel delays responding to the framework's initial request for restoration data - * until {@code setRestorationData} has been called. + * Whether the channel delays responding to the framework's initial request for restoration + * data until {@code setRestorationData} has been called. * - *

If the engine never calls {@code setRestorationData} this flag must be set to false. If set - * to true, the engine must call {@code setRestorationData} either with the actual restoration + *

If the engine never calls {@code setRestorationData} this flag must be set to false. + * If set to true, the engine must call {@code setRestorationData} either with the actual restoration * data as argument or null if it turns out that there is no restoration data. * *

If the response to the framework's request for restoration data is not delayed until the * data has been set via {@code setRestorationData}, the framework may intermittently initialize - * itself to default values until the restoration data has been made available. Setting this flag - * to true avoids that extra work. + * itself to default values until the restoration data has been made available. Setting + * this flag to true avoids that extra work. */ public waitForRestorationData: boolean = false; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/SettingsChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/SettingsChannel.ets index 6756b9032c035a13b4797168c32ec5cf42e9db3e..5b7310114a8d6b98e01ecdaa00f735384a621f1c 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/SettingsChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/SettingsChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on SettingsChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 BasicMessageChannel from '../../../plugin/common/BasicMessageChannel'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/SystemChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/SystemChannel.ets index b478ee36461aa2f6bb9833b1f49c595e368f4bf3..c89ed34b24f3453ec6298975b7ed98fb67c7f321 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/SystemChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/SystemChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on SystemChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 BasicMessageChannel from '../../../plugin/common/BasicMessageChannel'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TestChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TestChannel.ets index d54c448e027d069baaacbe66bf877c50823cb6d5..2ebf314455f69691474d4e0e5b6f4ef3c374b18a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TestChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TestChannel.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import BasicMessageChannel, { MessageHandler, Reply } from '../../../plugin/common/BasicMessageChannel'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets index f99b0cd27f3fba243e663d187c698e04b4b44b52..81880ae6eca3a66f88b26b234a8cbe6a6b6f02de 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on TextInputChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 JSONMethodCodec from '../../../plugin/common/JSONMethodCodec'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/workers/PlatformChannelWorker.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/workers/PlatformChannelWorker.ets index bc32d2655da245fd7affcef9392cd937c9d19375..8bb25b511dab8b67c11a050093a17f9b28bfc8dd 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/workers/PlatformChannelWorker.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/workers/PlatformChannelWorker.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import { ErrorEvent, MessageEvents, ThreadWorkerGlobalScope, worker } from '@kit.ArkTS'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/ExclusiveAppComponent.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/ExclusiveAppComponent.ets index f7ecfc7d5ef46c57923679789eb82f86eb83ef77..d0885ee95bd77124345a4da62a1cb602803d1953 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/ExclusiveAppComponent.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/ExclusiveAppComponent.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on ExclusiveAppComponent.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 default interface ExclusiveAppComponent { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets index d13fd9859a57ae1231ceec489a091d3f84ec6a63..42f066f4c08609ae912b2b8903b55cb1321b1800 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbility.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import UIAbility from '@ohos.app.ability.UIAbility'; @@ -29,14 +20,13 @@ import I18n from '@ohos.i18n' import { PlatformBrightness } from '../engine/systemchannels/SettingsChannel'; import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; import { Configuration } from '@ohos.app.ability.Configuration'; - +import { deviceInfo } from '@kit.BasicServicesKit'; import ExclusiveAppComponent from './ExclusiveAppComponent'; import errorManager from '@ohos.app.ability.errorManager'; import appRecovery from '@ohos.app.ability.appRecovery'; import FlutterManager from './FlutterManager'; import { FlutterView } from '../../view/FlutterView'; import ApplicationInfoLoader from '../engine/loader/ApplicationInfoLoader'; -import { accessibility } from '@kit.AccessibilityKit'; import { AccessibilityManager } from '../../view/AccessibilityBridge'; const TAG = "FlutterAbility"; @@ -62,6 +52,14 @@ export class FlutterAbility extends UIAbility implements Host { return "pages/Index" } + /** + * 可重写该方法,自定义FlutterAbility是否全屏; + * 默认值,根据设备类型,判断是否需要全屏 + */ + isDefaultFullScreen(): boolean { + return deviceInfo.deviceType != '2in1'; + } + /** * onCreate * 1、create and attach delegate @@ -107,13 +105,6 @@ export class FlutterAbility extends UIAbility implements Host { if (flutterApplicationInfo.isDebugMode) { this.delegate?.initWindow(); } - - //冷启动对os是否开启无障碍服务进行查询 - let accessibilityState: boolean = accessibility.isOpenAccessibilitySync(); - if(accessibilityState) { - this.delegate?.getFlutterNapi()?.accessibilityStateChange(accessibilityState); - } - Log.i(TAG, `accessibility isOpen state -> ${JSON.stringify(accessibilityState)}`); } onDestroy() { @@ -184,7 +175,9 @@ export class FlutterAbility extends UIAbility implements Host { Log.i(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); - FlutterManager.getInstance().setUseFullScreen(true, this.context); + if (this.isDefaultFullScreen()) { + FlutterManager.getInstance().setUseFullScreen(true, this.context); + } } catch (exception) { Log.e(TAG, 'Failed to enable the listener for window stage event changes. Cause:' + JSON.stringify(exception)); } @@ -319,7 +312,7 @@ export class FlutterAbility extends UIAbility implements Host { if (this.launchWant.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] != undefined) { return this.launchWant.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] as boolean; } - if (this.getCachedEngineId() != null) { + if (this.getCachedEngineId() != null && this.getCachedEngineId().length > 0) { // Prevent overwriting the existing state in a cached engine with restoration state. return false; } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets index df567109745d0c2624d6c72283b277c67e13547c..f0209620537dc8b96d30ca69425874d8ae1161d7 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import common from '@ohos.app.ability.common'; @@ -35,12 +26,10 @@ import FlutterNapi from '../engine/FlutterNapi'; import { FlutterView } from '../../view/FlutterView'; import FlutterManager from './FlutterManager'; import Any from '../../plugin/common/Any'; -import inputMethod from '@ohos.inputMethod'; const TAG = "FlutterAbilityDelegate"; const PLUGINS_RESTORATION_BUNDLE_KEY = "plugins"; const FRAMEWORK_RESTORATION_BUNDLE_KEY = "framework"; -const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS'; /** * 主要职责: @@ -56,7 +45,6 @@ class FlutterAbilityAndEntryDelegate implements ExclusiveAppComponent private engineGroup?: FlutterEngineGroup; private isHost:boolean = false; private flutterView?: FlutterView; - private inputMethodController: inputMethod.InputMethodController = inputMethod.getController(); constructor(host?: Host) { this.host = host; @@ -94,14 +82,6 @@ class FlutterAbilityAndEntryDelegate implements ExclusiveAppComponent this.flutterView.attachToFlutterEngine(this.flutterEngine!!); } this.host?.configureFlutterEngine(this.flutterEngine!!); - this.context.eventHub.on(EVENT_BACK_PRESS, () => { - if (this.flutterView?.getKeyboardHeight() == 0) { - this.flutterEngine?.getNavigationChannel()?.popRoute(); - this.flutterEngine?.getPlatformViewsController()?.setBackNodeControllers(); - } else { - this.inputMethodController.detach(); - } - }); } /** @@ -309,7 +289,6 @@ class FlutterAbilityAndEntryDelegate implements ExclusiveAppComponent } this.isAttached = false; - this.context?.eventHub.off(EVENT_BACK_PRESS); } onLowMemory(): void { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityLaunchConfigs.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityLaunchConfigs.ets index 996f455b9d045411425025f5c68089aee3f8938c..694a6df7c45bbeaeaf4f3e5e90d7ed085b6f8660 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityLaunchConfigs.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityLaunchConfigs.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ /** The mode of the background of a Flutter {@code Activity}, either opaque or transparent. */ diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineConfigurator.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineConfigurator.ets index 75408f2baa60902d1afe7ccf05a0ea8c557b38cd..28cd4fe376b6b9982835455f444f131c89d93d5b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineConfigurator.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineConfigurator.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterEngineConfigurator.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 FlutterEngine from '../engine/FlutterEngine'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineProvider.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineProvider.ets index a8eea36514d690e00aba5c987f61907cf4292515..a651efdd79c2a39d7fdf1423f1aca7d4ddd064ae 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineProvider.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEngineProvider.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterEngineProvider.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 FlutterEngine from '../engine/FlutterEngine'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets index 38f0192ea066838fc8578c64bd7212ccd363e3ad..c9cbdc8d077cee222fee25d10aa350b746a427ab 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterEntry.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import FlutterEngine from '../engine/FlutterEngine'; @@ -152,15 +143,27 @@ export default class FlutterEntry implements Host { } shouldAttachEngineToAbility(): boolean { - return this.parameters![FlutterEntry.ARG_SHOULD_ATTACH_ENGINE_TO_ABILITY] as boolean + let param = this.parameters![FlutterEntry.ARG_SHOULD_ATTACH_ENGINE_TO_ABILITY]; + if (!param) { + return true; + } + return param as boolean } getCachedEngineId(): string { - return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] as string + let param = this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID]; + if (!param) { + return ""; + } + return param as string } getCachedEngineGroupId(): string | null { - return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_GROUP_ID] as string + let param = this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_GROUP_ID]; + if (!param) { + return null; + } + return param as string } shouldDestroyEngineWithHost(): boolean { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets index b3e2f0598ce95f13ec55d14b9ba3a46e346727a0..d56e88648460eeab2c61748ecc51afcf9d43ff22 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterManager.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets index f5f641c4ec630bab11a5906ae3928c4ba8b0821e..34a1148219e45656a3d31f42392e60d53e925447 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets @@ -1,24 +1,17 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import Log from '../../util/Log'; import { FlutterView } from '../../view/FlutterView'; import FlutterManager from './FlutterManager'; import { DVModel, DVModelChildren, DynamicView } from '../../view/DynamicView/dynamicView'; +import flutter from 'libflutter.so'; const TAG = "FlutterPage"; + export const OHOS_FLUTTER_PAGE_UPDATE = "ohos_flutter_page_update"; /** @@ -26,12 +19,23 @@ export const OHOS_FLUTTER_PAGE_UPDATE = "ohos_flutter_page_update"; */ @Component export struct FlutterPage { + @Prop safeAreaEdges: SafeAreaEdge[] | undefined = []; + @Prop safeAreaTypes: SafeAreaType[] | undefined = []; @Prop viewId: string = "" @Prop xComponentType: XComponentType = XComponentType.SURFACE + onFocusListener?: () => void | undefined; + onBlurListener?: () => void | undefined; + isFocusFlag: boolean = false; + defaultFocusOnTouch = false; + + @Builder + doNothingBuilder() { + } - @Builder doNothingBuilder() {} @BuilderParam splashScreenView: () => void = this.doNothingBuilder; - @Builder defaultPage() { + + @Builder + defaultPage() { Stack() { ForEach(this.rootDvModel!!, (child: ESObject) => { DynamicView({ @@ -53,9 +57,23 @@ export struct FlutterPage { XComponent({ id: this.viewId, type: this.xComponentType, libraryname: 'flutter' }) .id(this.viewId) .focusable(true) + .focusOnTouch(this.defaultFocusOnTouch) .onLoad((context) => { this.flutterView?.onSurfaceCreated() Log.d(TAG, "XComponent onLoad "); + // 当xcomponent窗口部分显示或完全隐藏时触发回调 + this.getUIContext()?.getAttachedFrameNodeById(this.viewId)?.commonEvent.setOnVisibleAreaApproximateChange( + { ratios: [0.0, 1.0], expectedUpdateInterval: 0 }, + (ratioInc: boolean, ratio: number) => { + if (ratioInc) { + Log.i(TAG, "setOnVisibleAreaApproximateChange -> xcomponentId: " + this.viewId + + " ratioInc: " + ratioInc + " ratio: " + ratio); + flutter.nativeGetXComponentId(this.viewId); + // 保证获取xcomponentid之后再使用无障碍 + this.flutterView?.onAccessibilityIsOpen(); + } + } + ) }) .onDestroy(() => { Log.d(TAG, "XComponent onDestroy "); @@ -63,6 +81,7 @@ export struct FlutterPage { }) .renderFit(RenderFit.TOP_LEFT) .backgroundColor(Color.Transparent) + .expandSafeArea(this.safeAreaTypes, this.safeAreaEdges) if (this.showSplashScreen) { this.splashScreenView(); @@ -109,8 +128,20 @@ export struct FlutterPage { }); Log.d(TAG, "onDrop"); }) + .onFocus(() => { + Log.d(TAG, "onFocus"); + this.onFocusListener?.(); + this.isFocusFlag = true; + }) + .onBlur(() => { + Log.d(TAG, "onBlur"); + this.onBlurListener?.(); + this.isFocusFlag = false; + }) } - @Builder mouseWheelPage() { + + @Builder + mouseWheelPage() { Stack() { ForEach(this.rootDvModel!!, (child: ESObject) => { DynamicView({ @@ -132,9 +163,23 @@ export struct FlutterPage { XComponent({ id: this.viewId, type: this.xComponentType, libraryname: 'flutter' }) .id(this.viewId) .focusable(true) + .focusOnTouch(this.defaultFocusOnTouch) .onLoad((context) => { this.flutterView?.onSurfaceCreated() Log.d(TAG, "XComponent onLoad "); + // 当xcomponent窗口部分显示或完全隐藏时触发回调 + this.getUIContext()?.getAttachedFrameNodeById(this.viewId)?.commonEvent.setOnVisibleAreaApproximateChange( + { ratios: [0.0, 1.0], expectedUpdateInterval: 0 }, + (ratioInc: boolean, ratio: number) => { + if (ratioInc) { + Log.i(TAG, "setOnVisibleAreaApproximateChange -> xcomponentId: " + this.viewId + + " ratioInc: " + ratioInc + " ratio: " + ratio); + flutter.nativeGetXComponentId(this.viewId); + // 保证获取xcomponentid之后再使用无障碍 + this.flutterView?.onAccessibilityIsOpen(); + } + } + ) }) .onDestroy(() => { Log.d(TAG, "XComponent onDestroy "); @@ -142,6 +187,7 @@ export struct FlutterPage { }) .renderFit(RenderFit.TOP_LEFT) .backgroundColor(Color.Transparent) + .expandSafeArea(this.safeAreaTypes, this.safeAreaEdges) if (this.showSplashScreen) { this.splashScreenView(); @@ -200,21 +246,31 @@ export struct FlutterPage { this.flutterView?.onMouseWheel("actionEnd", event); }) ) + .onFocus(() => { + Log.d(TAG, "onFocus"); + this.onFocusListener?.(); + this.isFocusFlag = true; + }) + .onBlur(() => { + Log.d(TAG, "onBlur"); + this.onBlurListener?.(); + this.isFocusFlag = false; + }) + } + + public isFocused(): boolean { + return this.isFocusFlag; } - @State showSplashScreen: boolean = true; + @State showSplashScreen: boolean = true; @State checkFullScreen: boolean = true; @State checkKeyboard: boolean = true; @State checkGesture: boolean = true; @State checkMouseWheel: boolean = true; - @StorageLink('nodeWidth') storageLinkWidth: number = 0; @StorageLink('nodeHeight') storageLinkHeight: number = 0; - @State rootDvModel: DVModelChildren | undefined = undefined - @State isNeedUpdate: boolean = false; - private flutterView?: FlutterView | null private lastArea?: Area; private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Up | PanDirection.Down }); diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterWindow.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterWindow.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5259ba7ebe73a69be44125908907e870c20defb --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterWindow.ets @@ -0,0 +1,306 @@ +/* +* Copyright (c) 2024 Hunan OpenValley Digital Industry Development 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 FlutterEngine from '../engine/FlutterEngine'; +import PlatformPlugin from '../../plugin/PlatformPlugin'; +import Want from '@ohos.app.ability.Want'; +import FlutterShellArgs from '../engine/FlutterShellArgs'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import ExclusiveAppComponent from './ExclusiveAppComponent'; +import { FlutterAbilityAndEntryDelegate, Host } from './FlutterAbilityAndEntryDelegate'; +import FlutterAbilityLaunchConfigs from './FlutterAbilityLaunchConfigs'; +import Log from '../../util/Log'; +import { FlutterView } from '../../view/FlutterView'; +import FlutterManager from './FlutterManager'; +import window from '@ohos.window'; +import FlutterEngineConfigurator from './FlutterEngineConfigurator'; +import { FlutterPlugin } from '../engine/plugins/FlutterPlugin'; + +const TAG = "FlutterWindow"; + +/** + * 支持嵌入其他应用组件的flutter页面 + */ +export default class FlutterWindow implements Host { + private static ARG_SHOULD_ATTACH_ENGINE_TO_ABILITY: string = "should_attach_engine_to_ability"; + protected uiAbility: UIAbility | null = null + protected delegate: FlutterAbilityAndEntryDelegate | null = null + protected flutterView: FlutterView | null = null + protected context: Context; + protected windowStage: window.WindowStage | null = null + private parameters: Record = {}; + protected engineConfigurator: FlutterEngineConfigurator | null = null + protected hasInit: boolean = false; + private isFocusedFlag: boolean = false; + + constructor(context: Context, params: Record = {}) { + this.context = context; + this.uiAbility = FlutterManager.getInstance().getUIAbility(context); + this.parameters = params; + this.windowStage = FlutterManager.getInstance().getWindowStage(this.uiAbility); + this.hasInit = false; + } + + async aboutToInit() { + Log.i(TAG, 'aboutToInit'); + if (this.hasInit == false) { + this.delegate = new FlutterAbilityAndEntryDelegate(this); + this.flutterView = this.delegate?.createView(this.context); + this.flutterView?.onWindowCreated(); + await this?.delegate?.onAttach(this.context); + Log.i(TAG, 'onAttach end'); + this?.delegate?.platformPlugin?.setUIAbilityContext(this.uiAbility!!.context); + this.delegate?.onCreate(); + this.delegate?.onWindowStageCreate() + this.windowStage?.on('windowStageEvent', this.windowStageEventCallback); + this.hasInit = true; + this.delegate?.initWindow(); + } + } + + /** + * 是否由windowStage生命周期处理window事件,如果传false,用户根据场景传递窗口事件到FlutterEngine + * @returns 默认由主窗口window生命周期发送事件到FlutterEntine + */ + protected isWindowStageEventCallbackHandle(): boolean { + return true; + } + + /** + * 部分FlutterWindow场景,并不依赖主window的前后台、焦点事件,依赖组件的事件,所以消息由组件转发 + * 如果使用该方法传递window事件,需重写isWindowStageEventCallbackHandle返回false + * @param event window窗口事件 + */ + public postWindowStageEvent(event: window.WindowStageEventType) { + this.handleWindowStageEvent(event); + } + + private handleWindowStageEvent(event: window.WindowStageEventType) { + switch (event) { + case window.WindowStageEventType.SHOWN: // 切到前台 + Log.i(TAG, 'windowStage foreground.'); + break; + case window.WindowStageEventType.ACTIVE: // 获焦状态 + Log.i(TAG, 'windowStage active.'); + this.delegate?.getFlutterEngine()?.getTextInputChannel()?.textInputMethodHandler?.handleChangeFocus(true); + this?.delegate?.onWindowFocusChanged(true); + this.isFocusedFlag = true; + break; + case window.WindowStageEventType.INACTIVE: // 失焦状态 + Log.i(TAG, 'windowStage inactive.'); + this?.delegate?.onWindowFocusChanged(false); + this.isFocusedFlag = false; + break; + case window.WindowStageEventType.HIDDEN: // 切到后台 + Log.i(TAG, 'windowStage background.'); + break; + } + } + + public isFocused(): boolean { + return this.isFocusedFlag; + } + + protected windowStageEventCallback = (data: window.WindowStageEventType) => { + let stageEventType: window.WindowStageEventType = data; + if (this.isWindowStageEventCallbackHandle()) { + this.handleWindowStageEvent(stageEventType); + } + } + + setFlutterEngineConfigurator(configurator: FlutterEngineConfigurator) { + this.engineConfigurator = configurator; + } + + getFlutterView(): FlutterView { + return this.flutterView!! + } + + getFlutterEngine(): FlutterEngine | null { + return this.delegate?.flutterEngine! + } + + aboutToDestroy() { + Log.d(TAG, "FlutterWindow aboutToDestroy==="); + try { + this.windowStage?.off('windowStageEvent', this.windowStageEventCallback); + } catch (err) { + + } + if (this.flutterView != null) { + this.flutterView.onDestroy(); + this.flutterView = null; + } + if (this.delegate != null) { + this.delegate?.onDetach(); + this.delegate?.release() + } + } + + onPageShow() { //生命周期 + Log.d(TAG, "FlutterWindow onPageShow==="); + this?.delegate?.onForeground(); + } + + onPageHide() { //生命周期 + Log.d(TAG, "FlutterWindow onPageHide==="); + this?.delegate?.onBackground(); + } + + onBackPress() { + Log.d(TAG, "FlutterWindow onBackPress==="); + this?.delegate?.flutterEngine?.getNavigationChannel()?.popRoute(); + this?.delegate?.flutterEngine?.getTextInputChannel()?.textInputMethodHandler?.hide(); + } + + shouldDispatchAppLifecycleState(): boolean { + return true; + } + + detachFromFlutterEngine() { + if (this?.delegate != null) { + this?.delegate?.onDetach(); + } + } + + getAbility(): UIAbility { + return this.uiAbility!! + } + + loadContent() { + + } + + shouldAttachEngineToAbility(): boolean { + let param = this.parameters![FlutterWindow.ARG_SHOULD_ATTACH_ENGINE_TO_ABILITY]; + if (!param) { + return true; + } + return param as boolean + } + + getCachedEngineId(): string { + let param = this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID]; + if (!param) { + return ""; + } + return param as string + } + + getCachedEngineGroupId(): string | null { + let param = this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_GROUP_ID]; + if (!param) { + return null; + } + return param as string + } + + shouldDestroyEngineWithHost(): boolean { + if ((this.getCachedEngineId() != null && this.getCachedEngineId().length > 0) || + this.delegate!!.isFlutterEngineFromHost()) { + // Only destroy a cached engine if explicitly requested by app developer. + return false; + } + return true; + } + + attachToEngineAutomatically(): boolean { + return true; + } + + getFlutterShellArgs(): FlutterShellArgs { + return new FlutterShellArgs(); + } + + getDartEntrypointArgs(): string[] { + if (this.parameters![FlutterAbilityLaunchConfigs.EXTRA_DART_ENTRYPOINT_ARGS]) { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_DART_ENTRYPOINT_ARGS] as Array; + } + return new Array() + } + + getDartEntrypointLibraryUri(): string { + return ""; + } + + getAppBundlePath(): string { + return ""; + } + + getDartEntrypointFunctionName(): string { + if (this.parameters![FlutterAbilityLaunchConfigs.EXTRA_DART_ENTRYPOINT]) { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_DART_ENTRYPOINT] as string; + } + return FlutterAbilityLaunchConfigs.DEFAULT_DART_ENTRYPOINT + } + + getInitialRoute(): string { + if (this.parameters![FlutterAbilityLaunchConfigs.EXTRA_INITIAL_ROUTE]) { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_INITIAL_ROUTE] as string + } + return ""; + } + + getWant(): Want { + return new Want(); + } + + shouldRestoreAndSaveState(): boolean { + if (this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] != undefined) { + return this.parameters![FlutterAbilityLaunchConfigs.EXTRA_CACHED_ENGINE_ID] as boolean; + } + if (this.getCachedEngineId() != null && this.getCachedEngineId().length > 0) { + // Prevent overwriting the existing state in a cached engine with restoration state. + return false; + } + return true; + } + + getExclusiveAppComponent(): ExclusiveAppComponent | null { + return this.delegate ? this.delegate : null + } + + provideFlutterEngine(context: Context): FlutterEngine | null { + return null; + } + + providePlatformPlugin(flutterEngine: FlutterEngine): PlatformPlugin | undefined { + return new PlatformPlugin(flutterEngine.getPlatformChannel()!, this.context, this); + } + + configureFlutterEngine(flutterEngine: FlutterEngine) { + if (this.engineConfigurator) { + this.engineConfigurator.configureFlutterEngine(flutterEngine) + } + } + + cleanUpFlutterEngine(flutterEngine: FlutterEngine) { + if (this.engineConfigurator) { + this.engineConfigurator.cleanUpFlutterEngine(flutterEngine) + } + } + + popSystemNavigator(): boolean { + return false; + } + + addPlugin(plugin: FlutterPlugin): void { + this.delegate?.addPlugin(plugin) + } + + removePlugin(plugin: FlutterPlugin): void { + this.delegate?.removePlugin(plugin) + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyEventHandler.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyEventHandler.ets index 58133fd461d8669580f47c2358ae33739957c70d..69ea10bd50079ed92de54cd3e8e6ce9427037a96 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyEventHandler.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyEventHandler.ets @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ import { HashMap } from "@kit.ArkTS"; @@ -21,11 +12,20 @@ import { KeyCode } from "@kit.InputKit"; const TAG = "KeyEventHandler"; +// 组合键 +const COMBINATION_KEYS = [ + KeyCode.KEYCODE_CTRL_LEFT, KeyCode.KEYCODE_CTRL_RIGHT, + KeyCode.KEYCODE_ALT_LEFT, KeyCode.KEYCODE_ALT_RIGHT +]; + export class KeyEventHandler { private textInputPlugin?: TextInputPlugin; private charMap : HashMap = new HashMap(); private shiftMap : HashMap = new HashMap(); private isShiftMode: boolean = false; + private isCombinationKey: boolean = false; + // 记录输入的keyCode,确保有down和up事件才输入字符 + private inputMap: HashMap = new HashMap(); constructor(textInputPlugin?: TextInputPlugin) { this.textInputPlugin = textInputPlugin; @@ -82,6 +82,16 @@ export class KeyEventHandler { this.charMap.set(KeyCode.KEYCODE_PERIOD, '.') this.charMap.set(KeyCode.KEYCODE_SLASH, '/') this.charMap.set(KeyCode.KEYCODE_SPACE, ' ') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_0, '0') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_1, '1') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_2, '2') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_3, '3') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_4, '4') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_5, '5') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_6, '6') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_7, '7') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_8, '8') + this.charMap.set(KeyCode.KEYCODE_NUMPAD_9, '9') } private initShiftMap() { @@ -147,18 +157,36 @@ export class KeyEventHandler { handleKeyEvent(event: KeyEvent) { Log.i(TAG, JSON.stringify({ "name": "handleKeyEvent", - "event": event + "event": event, })); - if (event.type == KeyType.Up) { - // 处理字符按键相关逻辑 - if (this.charMap.hasKey(event.keyCode)) { - this.textInputPlugin?.getEditingState().handleInsertTextEvent(this.getCharByEvent(event)) + let text = this.getCharByEvent(event); + if (event.type == KeyType.Down) { + if (!this.isCombinationKey) { + this.isCombinationKey = COMBINATION_KEYS.findIndex((it) => it == event.keyCode) >= 0; + if (this.isCombinationKey) { + this.inputMap.clear(); + } + } + if (!this.isCombinationKey) { + // Ctrl/Alt 键按下的状态,不输入字符(字母/数字/符号) + this.inputMap.set(event.keyCode, text); } - // 处理非字符按键 - if (event.keyCode == KeyCode.KEYCODE_DEL) { - this.textInputPlugin?.getEditingState().handleDeleteEvent(false, 0) + } else if (event.type == KeyType.Up) { + if (COMBINATION_KEYS.findIndex((it) => it == event.keyCode) >= 0) { + // Ctrl/Alt 键抬起,重置状态 + this.isCombinationKey = false; + return; + } else if (this.isCombinationKey) { + // Ctrl/Alt 键按下的状态,不输入字符(字母/数字/符号) + return; + } + // 处理字符按键相关逻辑 + if (this.inputMap.hasKey(event.keyCode) && this.charMap.hasKey(event.keyCode)) { + this.inputMap.remove(event.keyCode) + this.textInputPlugin?.getEditingState().handleInsertTextEvent(text) } } this.isShiftMode = event.keyCode == KeyCode.KEYCODE_SHIFT_LEFT + || event.keyCode == KeyCode.KEYCODE_SHIFT_RIGHT } } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyboardManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyboardManager.ets index 21b5c88934ba7443f6dc5ead7fd8974e40db2ac3..3f1b088bc93d0718981bcdf437d9addac8bee1f1 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyboardManager.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/KeyboardManager.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on KeyboardManager.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 TextInputPlugin from '../../plugin/editing/TextInputPlugin'; import FlutterEngine from '../engine/FlutterEngine'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/OhosTouchProcessor.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/OhosTouchProcessor.ets index 46d0294ffce8763e71386296138281c45810d510..fd4bc8d8923c4d89cefee8d3499af773815f3896 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/OhosTouchProcessor.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/OhosTouchProcessor.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import { TouchEvent } from '@ohos.multimodalInput.touchEvent'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/Settings.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/Settings.ets index 637e99815ea5142d25d5c33ed138a97ae41f558c..91046fd777b5203f90f1bc97213ca30e96ea0422 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/Settings.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/Settings.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import SettingsChannel, { PlatformBrightness } from '../engine/systemchannels/SettingsChannel' diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/TouchEventProcessor.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/TouchEventProcessor.ets index e6100e08335ae582e9a048471e017163ba749c3a..b19484ece23485fdaa43758fbca9bbc6c5ac28dd 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/TouchEventProcessor.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/TouchEventProcessor.ets @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + /** Handle the motion events received by the FlutterNapi. */ // import PlainArray from '@ohos.util.PlainArray'; // import { TouchEvent } from '@ohos.multimodalInput.touchEvent'; @@ -257,6 +258,10 @@ export default class TouchEventProcessor { //如果flutter端判断当前platformView是可点击的,则将事件分发出去 let touchEvent = TouchEventProcessor.getInstance().constureCustomTouchEvent(strings, top, left); let nodeController = params['nodeController'] as EmbeddingNodeController; + // 保证platformviewcontroller.ets的onTouch的down属性正常结束 + if (touchEvent.type === TouchType.Up) { + params['down'] === false; + } nodeController.postEvent(touchEvent) } else { //如果触摸事件为OH_NATIVEXCOMPONENT_DOWN=0,且只有一个手指,说明是下一次点击了,这时候需要清空上一次的数据 diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/TouchEventTracker.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/TouchEventTracker.ets index b51743116ed023a1eb9b84448a8a77c7defd4b2f..d5dd9ccdb5ab6e923597b51f2244e15b0538345c 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/TouchEventTracker.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/TouchEventTracker.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ /** Tracks the motion events received by the FlutterView. */ import PlainArray from '@ohos.util.PlainArray'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapper.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapper.ets index ae2c6cfd5202c3f2c912720217df452a727f35b6..fe30cf0c15adb4eb881d7557bf8f8258f7ca7a84 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapper.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapper.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import UIAbility from '@ohos.app.ability.UIAbility'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets index 500390aeb93de65c2cd3eabe284126c1a47918e7..4b211f43935f65e98b185c9f398fbe9ee2796cb4 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/PlatformPlugin.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformPlugin.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import { BusinessError } from '@kit.BasicServicesKit'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/Any.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/Any.ets index 47b276990d36ba41a03de1c954dbc52867a7c6e8..d20a95d820ef03c355d355cca85db8ed605550e8 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/Any.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/Any.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ declare type Any = ESObject; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BackgroundBasicMessageChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BackgroundBasicMessageChannel.ets index 786222f770063d062de065373020955b3c2ad8cb..e840bc3b001066053f8727d28d15fa9aa04aad62 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BackgroundBasicMessageChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BackgroundBasicMessageChannel.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import MessageChannelUtils from '../../util/MessageChannelUtils'; import Log from '../../util/Log'; @@ -24,15 +15,15 @@ import SendableMessageHandler from './SendableMessageHandler'; import StringUtils from '../../util/StringUtils'; /** - * A named channel for communicating with the Flutter application using basic, asynchronous message - * passing. + * A named channel for communicating with the Flutter application using basic, asynchronous + * message passing. * *

Messages are encoded into binary before being sent, and binary messages received are decoded - * into Java objects. The {@link MessageCodec} used must be compatible with the one used by the - * Flutter application. This can be achieved by creating a BasicMessageChannel - * counterpart of this channel on the Dart side. The static Java type of messages sent and received - * is {@code Object}, but only values supported by the specified {@link MessageCodec} can be used. + * counterpart of this channel on the Dart side. The static Java type of messages sent + * and received is {@code Object}, but only values supported by the specified {@link MessageCodec} can be used. * *

The logical identity of the channel is given by its name. Identically named channels will * interfere with each other's communication. @@ -66,13 +57,13 @@ export default class BackgroundBasicMessageChannel { } /** - * Registers a message handler on this channel for receiving messages sent from the Flutter - * application. + * Registers a message handler on this channel for receiving messages sent from the + * Flutter application. * *

Overrides any existing handler registration for (the name of) this channel. * - *

If no handler has been registered, any incoming message on this channel will be handled - * silently by sending a null reply. + *

If no handler has been registered, any incoming message on this channel will be + * handled silently by sending a null reply. * * @param handler a {@link MessageHandler}, or null to deregister. */ diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BackgroundMethodChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BackgroundMethodChannel.ets index 912d525917913c4e0b841584d0e6712b2f0d4de7..9ed93b9127abc82fb864bbef830efbb90a2daabe 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BackgroundMethodChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BackgroundMethodChannel.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import Log from '../../util/Log'; import MessageChannelUtils from '../../util/MessageChannelUtils'; @@ -26,14 +17,15 @@ import SendableMethodCodec from './SendableMethodCodec' import SendableBinaryMessageHandler from './SendableBinaryMessageHandler' /** - * A named channel for communicating with the Flutter application using asynchronous method calls. + * A named channel for communicating with the Flutter application using asynchronous method + * calls. * *

Incoming method calls are decoded from binary on receipt, and Java results are encoded into - * binary before being transmitted back to Flutter. The {@link MethodCodec} used must be compatible - * with the one used by the Flutter application. This can be achieved by creating a MethodChannel - * counterpart of this channel on the Dart side. The Java type of method call arguments and results - * is {@code Object}, but only values supported by the specified {@link MethodCodec} can be used. + * counterpart of this channel on the Dart side. The Java type of method call arguments and + * results is {@code Object}, but only values supported by the specified {@link MethodCodec} can be used. * *

The logical identity of the channel is given by its name. Identically named channels will * interfere with each other's communication. @@ -62,7 +54,8 @@ export default class BackgroundMethodChannel { /** * Invokes a method on this channel, optionally expecting a result. * - *

Any uncaught exception thrown by the result callback will be caught and logged. + *

Any uncaught exception thrown by the result callback will be caught and + * logged. * * @param method the name String of the method. * @param arguments the arguments for the invocation, possibly null. @@ -79,12 +72,12 @@ export default class BackgroundMethodChannel { * *

Overrides any existing handler registration for (the name of) this channel. * - *

If no handler has been registered, any incoming method call on this channel will be handled - * silently by sending a null reply. This results in a MissingPluginException - * on the Dart side, unless an OptionalMethodChannel - * is used. + *

If no handler has been registered, any incoming method call on this channel will + * be handled silently by sending a null reply. This results in a MissingPluginException on the Dart side, unless an OptionalMethodChannel is used. * * @param handler a {@link MethodCallHandler}, or null to deregister. */ diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BasicMessageChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BasicMessageChannel.ets index 01a4a194f644701f130c5718324567ff4e3b27a0..cf0b5a0a92b6931d01428f7f66cc985cd8eeb61b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BasicMessageChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BasicMessageChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on BasicMessageChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 MessageChannelUtils from '../../util/MessageChannelUtils'; import { BinaryMessageHandler } from './BinaryMessenger'; @@ -22,15 +17,15 @@ import { BinaryMessenger } from './BinaryMessenger'; import StringUtils from '../../util/StringUtils'; /** - * A named channel for communicating with the Flutter application using basic, asynchronous message - * passing. + * A named channel for communicating with the Flutter application using basic, asynchronous + * message passing. * - *

Messages are encoded into binary before being sent, and binary messages received are decoded - * into Java objects. The {@link MessageCodec} used must be compatible with the one used by the + *

Messages are encoded into binary before being sent, and binary messages received are + * decoded into Java objects. The {@link MessageCodec} used must be compatible with the one used by the * Flutter application. This can be achieved by creating a BasicMessageChannel - * counterpart of this channel on the Dart side. The static Java type of messages sent and received - * is {@code Object}, but only values supported by the specified {@link MessageCodec} can be used. + * counterpart of this channel on the Dart side. The static Java type of messages sent and + * received is {@code Object}, but only values supported by the specified {@link MessageCodec} can be used. * *

The logical identity of the channel is given by its name. Identically named channels will * interfere with each other's communication. @@ -61,13 +56,13 @@ export default class BasicMessageChannel { } /** - * Registers a message handler on this channel for receiving messages sent from the Flutter - * application. + * Registers a message handler on this channel for receiving messages sent from the + * Flutter application. * *

Overrides any existing handler registration for (the name of) this channel. * - *

If no handler has been registered, any incoming message on this channel will be handled - * silently by sending a null reply. + *

If no handler has been registered, any incoming message on this channel will be + * handled silently by sending a null reply. * * @param handler a {@link MessageHandler}, or null to deregister. */ @@ -104,12 +99,12 @@ export interface MessageHandler { * message to the given {@link Reply}. Failure to do so will result in lingering Flutter reply * handlers. The reply may be submitted asynchronously and invoked on any thread. * - *

Any uncaught exception thrown by this method, or the preceding message decoding, will be - * caught by the channel implementation and logged, and a null reply message will be sent back + *

Any uncaught exception thrown by this method, or the preceding message decoding, + * will be caught by the channel implementation and logged, and a null reply message will be sent back * to Flutter. * - *

Any uncaught exception thrown during encoding a reply message submitted to the {@link - * Reply} is treated similarly: the exception is logged, and a null reply is sent to Flutter. + *

Any uncaught exception thrown during encoding a reply message submitted to the + * {@link Reply} is treated similarly: the exception is logged, and a null reply is sent to Flutter. * * @param message the message, possibly null. * @param reply a {@link Reply} for sending a single message reply back to Flutter. diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryCodec.ets index 1c15c762108efc389aef0b9d2bf3ff8b07b01991..309a7bf0ff66b3341f77727029d02fe7c7bd31d7 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on BinaryCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 MessageCodec from './MessageCodec'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryMessenger.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryMessenger.ets index 19e9a35f6757844f1d9231f791bd7cf7b89bb615..b28933e547f0dac458d2d728f79531c0d262b692 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryMessenger.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/BinaryMessenger.ets @@ -1,25 +1,20 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on BinaryMessenger.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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. */ /** * An abstraction over the threading policy used to invoke message handlers. * *

These are generated by calling methods like {@link - * BinaryMessenger#makeBackgroundTaskQueue(TaskQueueOptions)} and can be passed into platform - * channels' constructors to control the threading policy for handling platform channels' - * messages. + * BinaryMessenger#makeBackgroundTaskQueue(TaskQueueOptions)} and can be passed into + * platform channels' constructors to control the threading policy for handling platform + * channels' messages. */ import SendableBinaryMessageHandler from './SendableBinaryMessageHandler' @@ -94,12 +89,12 @@ export interface BinaryMessageHandler { /** * Handles the specified message. * - *

Handler implementations must reply to all incoming messages, by submitting a single reply - * message to the given {@link BinaryReply}. Failure to do so will result in lingering Flutter + *

Handler implementations must reply to all incoming messages, by submitting a single + * reply message to the given {@link BinaryReply}. Failure to do so will result in lingering Flutter * reply handlers. The reply may be submitted asynchronously. * - *

Any uncaught exception thrown by this method will be caught by the messenger - * implementation and logged, and a null reply message will be sent back to Flutter. + *

Any uncaught exception thrown by this method will be caught by the + * messenger implementation and logged, and a null reply message will be sent back to Flutter. * * @param message the message {@link ByteBuffer} payload, possibly null. * @param reply A {@link BinaryReply} used for submitting a reply back to Flutter. @@ -108,18 +103,18 @@ export interface BinaryMessageHandler { } /** - * Facility for communicating with Flutter using asynchronous message passing with binary messages. - * The Flutter Dart code should use BinaryMessages to * participate. * *

{@code BinaryMessenger} is expected to be utilized from a single thread throughout the - * duration of its existence. If created on the main thread, then all invocations should take place - * on the main thread. If created on a background thread, then all invocations should take place on + * duration of its existence. If created on the main thread, then all invocations should take + * place on the main thread. If created on a background thread, then all invocations should take place on * that background thread. * - * @see BasicMessageChannel , which supports message passing with Strings and semi-structured - * messages. + * @see BasicMessageChannel , which supports message passing with Strings and + * semi-structured messages. * @see MethodChannel , which supports communication using asynchronous method invocation. * @see EventChannel , which supports communication using event streams. */ @@ -142,27 +137,28 @@ export interface BinaryMessenger { *

Any uncaught exception thrown by the reply callback will be caught and logged. * * @param channel the name {@link String} of the logical channel used for the message. - * @param message the message payload, a direct-allocated {@link ByteBuffer} with the message - * bytes between position zero and current position, or null. - * @param callback a {@link BinaryReply} callback invoked when the Flutter application responds to - * the message, possibly null. + * @param message the message payload, a direct-allocated {@link ByteBuffer} with the + * message bytes between position zero and current position, or null. + * @param callback a {@link BinaryReply} callback invoked when the Flutter application + * responds to the message, possibly null. */ send(channel: String, message: ArrayBuffer, callback?: BinaryReply | null): void; /** - * Registers a handler to be invoked when the Flutter application sends a message to its host - * platform. + * Registers a handler to be invoked when the Flutter application sends a message to its + * host platform. * - *

Registration overwrites any previous registration for the same channel name. Use a null - * handler to deregister. + *

Registration overwrites any previous registration for the same channel name. Use + * a null handler to deregister. * - *

If no handler has been registered for a particular channel, any incoming message on that - * channel will be handled silently by sending a null reply. + *

If no handler has been registered for a particular channel, any incoming message + * on that channel will be handled silently by sending a null reply. * * @param channel the name {@link String} of the channel. - * @param handler a {@link BinaryMessageHandler} to be invoked on incoming messages, or null. - * @param taskQueue a {@link BinaryMessenger.TaskQueue} that specifies what thread will execute - * the handler. Specifying null means execute on the platform thread. + * @param handler a {@link BinaryMessageHandler} to be invoked on incoming messages, + * or null. + * @param taskQueue a {@link BinaryMessenger.TaskQueue} that specifies what thread + * will execute the handler. Specifying null means execute on the platform thread. */ setMessageHandler(channel: String, handler: BinaryMessageHandler | SendableBinaryMessageHandler | null, taskQueue?: TaskQueue, ...args: Object[]): void; } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/EventChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/EventChannel.ets index 0affd6b72708e69ff22a6e8b774bbf19de237f7a..602259f5d67b824d08c02f8378d0d37b3e0dd2ff 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/EventChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/EventChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on EventChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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. */ diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/FlutterException.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/FlutterException.ets index 260d5ad1d10e2f9da9d18e9ebc4548266c08d433..f00c742e7cb5e280e5353115845db7edb6dfbc1b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/FlutterException.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/FlutterException.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterException.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Any from './Any'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/JSONMessageCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/JSONMessageCodec.ets index d30f817fb3c6ce49d1ccdd5cae6a774098e8ca2e..1d9c851d6aabb4b026352d6ad262be308e0fcaeb 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/JSONMessageCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/JSONMessageCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on JSONMessageCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 StringUtils from '../../util/StringUtils'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/JSONMethodCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/JSONMethodCodec.ets index 895aa995dd6ba5644177c9c69dbd8039d3082394..ab4eef4a13bc68db51e7a2868d8b7858b7f27dfb 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/JSONMethodCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/JSONMethodCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on JSONMethodCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Log from '../../util/Log'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MessageCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MessageCodec.ets index 4fdd52011b4ecbd0e6509864581000e5d8c0ad15..eaf60bcfdae8541cfa0868b272925f8f4b4904e8 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MessageCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MessageCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on MessageCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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. */ /** diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodCall.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodCall.ets index 1588f617fb9e52fe9ebd4e4e66833ec83ebdf3ee..25701de6de5c2030563f96806a191452f3bc5227 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodCall.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodCall.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on MethodCall.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 ToolUtils from '../../util/ToolUtils'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodChannel.ets index 07eeb637cd9132db4bec808be340db56fd874fea..4eae0c0dc0b412f784de903ed3e306e90b8ee493 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodChannel.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on MethodChannel.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Log from '../../util/Log'; @@ -25,15 +20,15 @@ import StandardMethodCodec from './StandardMethodCodec'; /** * A named channel for communicating with the Flutter application using asynchronous method calls. * - *

Incoming method calls are decoded from binary on receipt, and Java results are encoded into - * binary before being transmitted back to Flutter. The {@link MethodCodec} used must be compatible - * with the one used by the Flutter application. This can be achieved by creating a Incoming method calls are decoded from binary on receipt, and Java results are encoded + * into binary before being transmitted back to Flutter. The {@link MethodCodec} used must be + * compatible with the one used by the Flutter application. This can be achieved by creating a MethodChannel * counterpart of this channel on the Dart side. The Java type of method call arguments and results * is {@code Object}, but only values supported by the specified {@link MethodCodec} can be used. * - *

The logical identity of the channel is given by its name. Identically named channels will - * interfere with each other's communication. + *

The logical identity of the channel is given by its name. Identically named channels + * will interfere with each other's communication. */ export default class MethodChannel { @@ -51,11 +46,13 @@ export default class MethodChannel { /** * Invokes a method on this channel, optionally expecting a result. * - *

Any uncaught exception thrown by the result callback will be caught and logged. + *

Any uncaught exception thrown by the result callback will be caught and + * logged. * * @param method the name String of the method. * @param arguments the arguments for the invocation, possibly null. - * @param callback a {@link Result} callback for the invocation result, or null. + * @param callback a {@link Result} callback for the invocation result, + * or null. */ invokeMethod(method: string, args: Any, callback?: MethodResult): void { this.messenger.send(this.name, this.codec.encodeMethodCall(new MethodCall(method, args)), callback == null ? null : new IncomingResultHandler(callback, this.codec)); @@ -66,12 +63,12 @@ export default class MethodChannel { * *

Overrides any existing handler registration for (the name of) this channel. * - *

If no handler has been registered, any incoming method call on this channel will be handled - * silently by sending a null reply. This results in a MissingPluginException - * on the Dart side, unless an OptionalMethodChannel - * is used. + *

If no handler has been registered, any incoming method call on this channel will be + * handled silently by sending a null reply. This results in a MissingPluginException< + * /a> on the Dart side, unless an OptionalMethodChannel< + * /a> is used. * * @param handler a {@link MethodCallHandler}, or null to deregister. */ @@ -94,17 +91,17 @@ export interface MethodCallHandler { /** * Handles the specified method call received from Flutter. * - *

Handler implementations must submit a result for all incoming calls, by making a single - * call on the given {@link Result} callback. Failure to do so will result in lingering Flutter - * result handlers. The result may be submitted asynchronously and on any thread. Calls to + *

Handler implementations must submit a result for all incoming calls, by making a + * single call on the given {@link Result} callback. Failure to do so will result in lingering + * Flutter result handlers. The result may be submitted asynchronously and on any thread. Calls to * unknown or unimplemented methods should be handled using {@link Result#notImplemented()}. * - *

Any uncaught exception thrown by this method will be caught by the channel implementation - * and logged, and an error result will be sent back to Flutter. + *

Any uncaught exception thrown by this method will be caught by the channel + * implementation and logged, and an error result will be sent back to Flutter. * *

The handler is called on the platform thread (Android main thread) by default, or - * otherwise on the thread specified by the {@link BinaryMessenger.TaskQueue} provided to the - * associated {@link MethodChannel} when it was created. See also Threading in * the Flutter Engine. * @@ -137,9 +134,9 @@ export interface MethodResult { * * @param errorCode An error code String. * @param errorMessage A human-readable error message String, possibly null. - * @param errorDetails Error details, possibly null. The details must be an Object type - * supported by the codec. For instance, if you are using {@link StandardMessageCodec} - * (default), please see its documentation on what types are supported. + * @param errorDetails Error details, possibly null. The details must be an Object + * type supported by the codec. For instance, if you are using {@link + * StandardMessageCodec} (default), please see its documentation on what types are supported. */ error: (errorCode: string, errorMessage: string, errorDetails: Any) => void; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodCodec.ets index 445892d23809b823471da4edeecacb1e5050cf85..62f81fb8111e1fb4fe580836e00833ff864cd164 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/MethodCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on MethodCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Any from './Any'; @@ -18,9 +13,9 @@ import MethodCall from './MethodCall'; /** * A codec for method calls and enveloped results. * - *

Method calls are encoded as binary messages with enough structure that the codec can extract a - * method name String and an arguments Object. These data items are used to populate a {@link - * MethodCall}. + *

Method calls are encoded as binary messages with enough structure that the codec can + * extract amethod name String and an arguments Object. These data items are used to populate + * a {@link MethodCall}. * *

All operations throw {@link IllegalArgumentException}, if conversion fails. */ @@ -57,10 +52,10 @@ export default interface MethodCodec { * * @param errorCode An error code String. * @param errorMessage An error message String, possibly null. - * @param errorDetails Error details, possibly null. Consider supporting {@link Throwable} in your - * codec. This is the most common value passed to this field. - * @return a {@link ByteBuffer} containing the encoding between position 0 and the current - * position. + * @param errorDetails Error details, possibly null. Consider supporting {@link Throwable} + * in your codec. This is the most common value passed to this field. + * @return a {@link ByteBuffer} containing the encoding between position 0 and the + * current position. */ encodeErrorEnvelope(errorCode: string, errorMessage: string, errorDetails: Any): ArrayBuffer; @@ -69,11 +64,11 @@ export default interface MethodCodec { * * @param errorCode An error code String. * @param errorMessage An error message String, possibly null. - * @param errorDetails Error details, possibly null. Consider supporting {@link Throwable} in your - * codec. This is the most common value passed to this field. + * @param errorDetails Error details, possibly null. Consider supporting {@link Throwable} + * in your codec. This is the most common value passed to this field. * @param errorStacktrace Platform stacktrace for the error. possibly null. - * @return a {@link ByteBuffer} containing the encoding between position 0 and the current - * position. + * @return a {@link ByteBuffer} containing the encoding between position 0 and the + * current position. */ encodeErrorEnvelopeWithStacktrace(errorCode: string, errorMessage: string, errorDetails: Any, errorStacktrace: string): ArrayBuffer diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/PluginRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/PluginRegistry.ets index cb92c8eb1acc0406e2f14229e8d29d0ef19b3030..898dbc13227dca795d97d75da1fe245edc6c6a1b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/PluginRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/PluginRegistry.ets @@ -1,14 +1,5 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableBinaryCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableBinaryCodec.ets index 3874e37028199fd8a68cf04b4a0ad25820491b97..a99d9f045864cdc2fe688ff964564fd5da6e98a0 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableBinaryCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableBinaryCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on BinaryCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 SendableMessageCodec from './SendableMessageCodec'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableBinaryMessageHandler.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableBinaryMessageHandler.ets index d59ef697569d175e7c048b789a3dc02effb55503..5464f901737cfe43f970a65a58a60c6b2b114845 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableBinaryMessageHandler.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableBinaryMessageHandler.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import { lang } from '@kit.ArkTS'; import { BinaryReply } from './BinaryMessenger'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableJSONMessageCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableJSONMessageCodec.ets index 44abb977cf85359b885c5795ecd95706bc36d13e..1591231e5afb2caa821467400a31afcd3504a5d3 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableJSONMessageCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableJSONMessageCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on JSONMessageCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 StringUtils from '../../util/StringUtils'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableJSONMethodCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableJSONMethodCodec.ets index 55c96b523a490c673462bdaf07313199166b094d..11f38655f157f1b2066abd166979ff01304ed1f1 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableJSONMethodCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableJSONMethodCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on JSONMethodCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 ToolUtils from '../../util/ToolUtils'; import FlutterException from './FlutterException'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMessageCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMessageCodec.ets index d58ffa6e27e6322a03a002297fba7e7a5bfe6a5a..1820d6395d24f5f044d3620cfa7c77d15a21a948 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMessageCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMessageCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on MessageCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { lang } from '@kit.ArkTS'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMessageHandler.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMessageHandler.ets index 8322b882c90c29650e536d6eff9a2f7aaf382f26..97a401cd7a13b1f43c6f81bd5cf67027345d4a9d 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMessageHandler.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMessageHandler.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import { lang } from '@kit.ArkTS'; import { Reply} from './BasicMessageChannel'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMethodCallHandler.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMethodCallHandler.ets index ae80345181e09eb36d2ae8533a8f0f7d8e1cb0a7..c93d377a49592493e2e817632d6b01438365b994 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMethodCallHandler.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMethodCallHandler.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import { lang } from '@kit.ArkTS'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMethodCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMethodCodec.ets index 05bdcc403f9975e5fce7efc8cfc44120275dfb3d..c74e47c7ddfa0585a06c15551b2a6de1e1bfa001 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMethodCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableMethodCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on MethodCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { lang } from '@kit.ArkTS'; @@ -19,9 +14,9 @@ import MethodCall from './MethodCall'; /** * A codec for method calls and enveloped results. * - *

Method calls are encoded as binary messages with enough structure that the codec can extract a - * method name String and an arguments Object. These data items are used to populate a {@link - * MethodCall}. + *

Method calls are encoded as binary messages with enough structure that the codec can + * extract a method name String and an arguments Object. These data items are used to populate + * a {@link MethodCall}. * *

All operations throw {@link IllegalArgumentException}, if conversion fails. */ @@ -59,10 +54,10 @@ export default interface SendableMethodCodec extends ISendable { * * @param errorCode An error code String. * @param errorMessage An error message String, possibly null. - * @param errorDetails Error details, possibly null. Consider supporting {@link Throwable} in your - * codec. This is the most common value passed to this field. - * @return a {@link ByteBuffer} containing the encoding between position 0 and the current - * position. + * @param errorDetails Error details, possibly null. Consider supporting {@link Throwable} + * in your codec. This is the most common value passed to this field. + * @return a {@link ByteBuffer} containing the encoding between position 0 and the + * current position. */ encodeErrorEnvelope(errorCode: string, errorMessage: string, errorDetails: Any): ArrayBuffer; @@ -71,11 +66,11 @@ export default interface SendableMethodCodec extends ISendable { * * @param errorCode An error code String. * @param errorMessage An error message String, possibly null. - * @param errorDetails Error details, possibly null. Consider supporting {@link Throwable} in your - * codec. This is the most common value passed to this field. + * @param errorDetails Error details, possibly null. Consider supporting {@link Throwable} + * in your codec. This is the most common value passed to this field. * @param errorStacktrace Platform stacktrace for the error. possibly null. - * @return a {@link ByteBuffer} containing the encoding between position 0 and the current - * position. + * @return a {@link ByteBuffer} containing the encoding between position 0 and the + * current position. */ encodeErrorEnvelopeWithStacktrace(errorCode: string, errorMessage: string, errorDetails: Any, errorStacktrace: string): ArrayBuffer diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStandardMessageCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStandardMessageCodec.ets index af405327733303d134942a5fa849b3975f7094f5..18f2cdb08140aace6c445e1a5cf3866c13c28e28 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStandardMessageCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStandardMessageCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on StandardMessageCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Any from './Any'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStandardMethodCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStandardMethodCodec.ets index c2af05f39d3f9e32e67a52c1cae23b36381a2a38..b9d6b2d46ce58e484a810d633fb769bbe7c26722 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStandardMethodCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStandardMethodCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on StandardMethodCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { ByteBuffer } from '../../util/ByteBuffer'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStringCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStringCodec.ets index 23466ca64ae0cdeccf49a7475a8a2f96c7b1cf54..d26bea8f0091485b6ad3c83bf0be5b63c085092a 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStringCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/SendableStringCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on StringCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 SendableMessageCodec from './SendableMessageCodec'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMessageCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMessageCodec.ets index 25d7737baec7d236a2a99a949c6aab3c5c397105..797c5d2172deb8f8c2dc3e38ae37ed3ce03f65f1 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMessageCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMessageCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on StandardMessageCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { ByteBuffer } from '../../util/ByteBuffer'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMethodCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMethodCodec.ets index 279960f403444795148dd534546c5e145cfdfd07..7355f0bc1bab653531053bbc0369d9ebb61aeb80 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMethodCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StandardMethodCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on StandardMethodCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { ByteBuffer } from '../../util/ByteBuffer'; @@ -24,11 +19,11 @@ import StandardMessageCodec from './StandardMessageCodec'; * A {@link MethodCodec} using the Flutter standard binary encoding. * *

This codec is guaranteed to be compatible with the corresponding StandardMethodCodec - * on the Dart side. These parts of the Flutter SDK are evolved synchronously. + * href="https://api.flutter.dev/flutter/services/StandardMethodCodec-class.html">StandardMethodCodec + * on the Dart side. These parts of the Flutter SDK are evolved synchronously. * - *

Values supported as method arguments and result payloads are those supported by {@link - * StandardMessageCodec}. + *

Values supported as method arguments and result payloads are those supported by + * {@link StandardMessageCodec}. */ export default class StandardMethodCodec implements MethodCodec { private static TAG = "StandardMethodCodec"; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StringCodec.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StringCodec.ets index 3ce96e365ce74d7e82bbf2f742c1bdb3800afb27..8bab15f67e27164dcd3a1779d292469af924a249 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StringCodec.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/common/StringCodec.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on StringCodec.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 StringUtils from '../../util/StringUtils'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets index 351277019b2ba94b0b7cd759d33574c48b0b3198..690fdff3a427a874969e75bfc252697f57714405 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on ListenableEditingState.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { TextEditState } from '../../embedding/engine/systemchannels/TextInputChannel'; @@ -252,42 +247,6 @@ export class ListenableEditingState { } } - handleDeleteEvent(leftOrRight: boolean, length: number): void { - let start = this.mSelectionStartCache < this.mSelectionEndCache ? this.mSelectionStartCache : this.mSelectionEndCache; - let end = this.mSelectionStartCache > this.mSelectionEndCache ? this.mSelectionStartCache : this.mSelectionEndCache; - - if (leftOrRight == false) { - //delete left - if (start == 0 && end == 0) { - return; - } - let unicodeStart = start; - if (start == end) { - unicodeStart = FlutterTextUtils.getOffsetBefore(this.mStringCache, start); - } - this.replace(unicodeStart, end, "", 0, 0); - this.mSelectionStartCache = unicodeStart; - let tempStr: string = this.mStringCache.slice(0, unicodeStart) + this.mStringCache.slice(end); - this.mStringCache = tempStr; - this.mSelectionEndCache = this.mSelectionStartCache; - } else if (leftOrRight == true) { - //delete right - if (start == this.mStringCache.length) { - return; - } - let unicodeEnd = end; - if (start == end) { - unicodeEnd = FlutterTextUtils.getOffsetAfter(this.mStringCache, start); - } - this.replace(start, unicodeEnd, "", 0, 0); - this.mSelectionEndCache = start; - let tempStr: string = this.mStringCache.slice(0, start) + (unicodeEnd >= this.mStringCache.length ? "" : this.mStringCache.slice(unicodeEnd)); - this.mStringCache = tempStr; - this.mSelectionStartCache = this.mSelectionEndCache; - } - this.notifyListenersIfNeeded(true, true, false); - } - handleNewlineEvent(): void { // 获取光标所在位置; // 当光标移动前位置小于移动后的位置时,获取光标移动前位置;反之获取移动后位置 diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextEditingDelta.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextEditingDelta.ets index 495c4a51821d5b9279c56dc134138e5ccb17b41f..837cb6eb17729c741829c10419135be7185e5b2c 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextEditingDelta.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextEditingDelta.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on TextEditingDelta.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 Log from '../../util/Log'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets index 5f3a67c3628f4209dce770b382a28fc442b66431..4509d270ba24c4356310a177f5ab4b30bf24b81e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on TextInputPlugin.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 TextInputChannel, { @@ -258,22 +253,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { return; } - try { - this.inputMethodController.on('deleteLeft', this.deleteLeftCallback) - } catch (err) { - Log.e(TextInputMethodHandlerImpl.TAG, "Failed to subscribe deleteLeft:" + JSON.stringify(err)); - this.cancelListenKeyBoardEvent(); - return; - } - - try { - this.inputMethodController.on('deleteRight', this.deleteRightCallback) - } catch (err) { - Log.e(TextInputMethodHandlerImpl.TAG, "Failed to subscribe deleteRight:" + JSON.stringify(err)); - this.cancelListenKeyBoardEvent(); - return; - } - try { this.inputMethodController.on('sendFunctionKey', this.sendFunctionKeyCallback) } catch (err) { @@ -306,14 +285,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.mEditable.handleInsertTextEvent(text); } - private deleteLeftCallback = (length: number) => { - this.mEditable.handleDeleteEvent(false, length); - } - - private deleteRightCallback = (length: number) => { - this.mEditable.handleDeleteEvent(true, length); - } - private sendFunctionKeyCallback = (functionKey: inputMethod.FunctionKey) => { /// 临时规避缺少newline对应枚举类型问题 if (functionKey.enterKeyType == NEWLINE_KEY_TYPE) { @@ -324,9 +295,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { private sendKeyboardStatusCallback = (state: inputMethod.KeyboardStatus) => { this.keyboardStatus = state; - if (state == inputMethod.KeyboardStatus.HIDE) { - this.plugin.textInputChannel.onConnectionClosed(this.inputTarget.id); - } } private selectByRangeCallback = (range: inputMethod.Range) => { @@ -335,8 +303,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { cancelListenKeyBoardEvent(): void { this.inputMethodController?.off('insertText', this.insertTextCallback); - this.inputMethodController?.off('deleteLeft', this.deleteLeftCallback); - this.inputMethodController?.off('deleteRight', this.deleteRightCallback); this.inputMethodController?.off('sendFunctionKey', this.sendFunctionKeyCallback); this.inputMethodController?.off('sendKeyboardStatus', this.sendKeyboardStatusCallback); this.inputMethodController?.off('selectByRange', this.selectByRangeCallback); diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextUtils.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextUtils.ets index 61aa4b3dee7fe35658c24b51ebf1205708d7f923..aad2b230cb112167d2955ac088171e4f57d8ed6d 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextUtils.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextUtils.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterTextUtils.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 FlutterNapi from '../../embedding/engine/FlutterNapi'; import Log from '../../util/Log'; @@ -143,6 +138,7 @@ export class FlutterTextUtils { return offset - deleteCharCount; } + // Avoid repetition // Keycaps if (codePoint == COMBINING_ENCLOSING_KEYCAP) { codePoint = FlutterTextUtils.codePointBefore(text, lastOffset); @@ -159,9 +155,9 @@ export class FlutterTextUtils { } /** - * Following if statements for Emoji tag sequence and Variation selector are skipping these - * modifiers for going through the last statement that is for handling emojis. They return the - * offset if they don't find proper base characters + * Following if statements for Emoji tag sequence and Variation selector are skipping + * these modifiers for going through the last statement that is for handling emojis. They + * return the offset if they don't find proper base characters */ // Emoji Tag Sequence if (codePoint == CANCEL_TAG) { // tag_end diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/localization/LocalizationPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/localization/LocalizationPlugin.ets index 05421fc41e6c74003556ed92dffc9018314b7926..5f1d2104ff21fbcc03e31ccab9c2989fe8d4443f 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/localization/LocalizationPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/localization/LocalizationPlugin.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on LocalizationPlugin.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 LocalizationChannel, { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/mouse/MouseCursorPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/mouse/MouseCursorPlugin.ets index 90fc4b83874d49a66f1bb4f732a6df272ad87c80..35aa20fed0af1ab9f6085ca0737343c110422801 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/mouse/MouseCursorPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/mouse/MouseCursorPlugin.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on MouseCursorPlugin.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 MouseCursorChannel, { MouseCursorMethodHandler } from '../../embedding/engine/systemchannels/MouseCursorChannel'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/AccessibilityEventsDelegate.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/AccessibilityEventsDelegate.ets index aae15ba935e29f71d8f734b5505b8236b49af2d7..0b801ddfe2b506ad118d508d6e21dc9b81bd0f28 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/AccessibilityEventsDelegate.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/AccessibilityEventsDelegate.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on AccessibilityEventsDelegate.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 AccessibilityBridge from '../../view/AccessibilityBridge'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformOverlayView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformOverlayView.ets index 64e8c7f780dc9253f3fd79c05663805a13c8d839..42c88569d2476e7bdd42a577509f9b5acc71d0b4 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformOverlayView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformOverlayView.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import { AccessibilityEventsDelegate } from './AccessibilityEventsDelegate'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformView.ets index 1628ddd672c078a94b7624996e20878110eaaf58..031c3e6be31aed4a5d8f26dcc1b9699c903e94c4 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformView.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformView.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { DVModel, DynamicView } from '../../view/DynamicView/dynamicView' @@ -30,18 +25,18 @@ export default abstract class PlatformView { /** Returns the DynamicView to be embedded in the Flutter hierarchy. */ abstract getView(): WrappedBuilder<[Params]>; /** - * Called by the {@link io.flutter.embedding.engine.FlutterEngine} that owns this {@code - * PlatformView} when the DynamicView responsible for rendering a Flutter UI is + * Called by the {@link io.flutter.embedding.engine.FlutterEngine} that owns this + * {@code PlatformView} when the DynamicView responsible for rendering a Flutter UI is * associated with the {@link io.flutter.embedding.engine.FlutterEngine}. * - *

This means that our associated {@link io.flutter.embedding.engine.FlutterEngine} can now - * render a UI and interact with the user. + *

This means that our associated {@link io.flutter.embedding.engine.FlutterEngine} + * can now render a UI and interact with the user. * - *

Some platform views may have unusual dependencies on the {@link View} that renders Flutter - * UIs, such as unique keyboard interactions. That {@link View} is provided here for those - * purposes. Use of this {@link View} should be avoided if it is not absolutely necessary, because - * depending on this {@link View} will tend to make platform view code more brittle to future - * changes. + *

Some platform views may have unusual dependencies on the {@link View} that renders + * Flutter UIs, such as unique keyboard interactions. That {@link View} is provided here for those + * purposes. Use of this {@link View} should be avoided if it is not absolutely necessary, + * because depending on this {@link View} will tend to make platform view code more brittle + * to future changes. */ onFlutterViewAttached(dvModel: DVModel): void {} diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewFactory.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewFactory.ets index 81ce2ba940d0decbebe39f9db33be4c5f2ec499d..6b9a0ad68e80834467597a47f45d17cb47d379c4 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewFactory.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewFactory.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformViewFactory.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 MessageCodec from '../common/MessageCodec'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewRegistry.ets index 2c49f5eeaddb54cece120df8eea307c69ad76ebf..7372d8c9fc6af75f4db3b8f75c5a0173b87998ae 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewRegistry.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformViewRegistry.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 PlatformViewFactory from './PlatformViewFactory' diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewRegistryImpl.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewRegistryImpl.ets index 98cb247d890cbe65150feb84242c01128047e7f9..1af69ba4c1c67f7ed71effefda9f1b9ab882537b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewRegistryImpl.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewRegistryImpl.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformViewRegistryImpl.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 HashMap from '@ohos.util.HashMap'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewWrapper.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewWrapper.ets index 8dc1a1909eff3d884bf305738b550bb8fcaf0a4d..b3c3aafe0da2989c9414946525fa3247493b63e1 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewWrapper.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewWrapper.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import OhosTouchProcessor from '../../embedding/ohos/OhosTouchProcessor'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsAccessibilityDelegate.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsAccessibilityDelegate.ets index 62888046c561533a3ea096c77ce7f3f634503e4c..f45b3261b8c5b52c6d49c6cb385db4dd437fe2e9 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsAccessibilityDelegate.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsAccessibilityDelegate.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformViewsAccessibilityDelegate.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 AccessibilityBridge from '../../view/AccessibilityBridge'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets index 5c929c84186bf8f3e27de4978f6e83107b079e9e..2b075ef81dd348791172d9853f90d168516d5ebd 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on PlatformViewsController.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 { PlatformViewsAccessibilityDelegate } from './PlatformViewsAccessibilityDelegate'; @@ -65,6 +60,20 @@ class DVModelJson { this.build = build; } } +enum TouchEventType { + /// Action code for when a primary pointer touched the screen. + ACTION_DOWN = 0, + /// Action code for when a primary pointer stopped touching the screen. + ACTION_UP = 1, + /// Action code for when the event only includes information about pointer movement. + ACTION_MOVE = 2, + /// Action code for when a motion event has been canceled. + ACTION_CANCEL = 3, + /// Action code for when a secondary pointer touched the screen. + ACTION_POINTER_DOWN = 5, + /// Action code for when a secondary pointer touched the screen. + ACTION_POINTER_UP = 6, +} const TAG = "PlatformViewsController" @@ -142,17 +151,18 @@ export default class PlatformViewsController implements PlatformViewsAccessibili this.textureRegistry!.unregisterTexture(textureId); } + this.viewIdWithNodeController.get(viewId)?.removeBuilderNode() + this.viewIdWithNodeController.get(viewId)?.disposeFrameNode() + this.viewIdWithNodeController.delete(viewId); + let viewWrapper: PlatformViewWrapper | null = this.viewWrappers.get(viewId) || null; - if (viewWrapper != null) { - this.viewIdWithNodeController.get(viewId)?.removeBuilderNode() - this.viewIdWithNodeController.get(viewId)?.disposeFrameNode() - this.viewIdWithNodeController.delete(viewId); - if (this.flutterView) { - let index = this.flutterView.getDVModel().children.indexOf(viewWrapper.getDvModel()!); + if (viewWrapper != null && this.flutterView) { + let index = this.flutterView.getDVModel().children.indexOf(viewWrapper.getDvModel()!); + if (index > -1) { this.flutterView.getDVModel().children.splice(index, 1); } - this.viewWrappers.delete(viewId); } + this.viewWrappers.delete(viewId); try { platformView.dispose(); @@ -203,12 +213,12 @@ export default class PlatformViewsController implements PlatformViewsAccessibili let dvModel = viewWrapper.getDvModel() let params = dvModel.getLayoutParams() as Record; //接收到点击类型为down的时候 - if (touch.action == 0) { + if (touch.action === TouchEventType.ACTION_DOWN) { //将当前点击状态设置为true params['down'] = true //首次收到触控点击类型为 OH_NATIVEXCOMPONENT_DOWN ,则将存到列表中的事件分发出去 let touchEventArray: Array | undefined = params['touchEvent'] as Array - if (touchEventArray != undefined) { + if (touchEventArray !== undefined) { let nodeController = params['nodeController'] as EmbeddingNodeController; for (let it of touchEventArray) { nodeController.postEvent(it) @@ -216,9 +226,9 @@ export default class PlatformViewsController implements PlatformViewsAccessibili //首次执行完之后,将列表数据置空 params['touchEvent'] = undefined } - //当前接收的事件类型为up的时候 - } else if (touch.action == 1) { - //手指抬起之后,将当前点击状态设置为false。测试了一下,多个手指突然抬起,最后返回的状态也是1 + //当前接收的事件类型为up的时候 + } else if (touch.action === TouchEventType.ACTION_UP || touch.action === TouchEventType.ACTION_CANCEL) { + //手指抬起之后,将当前点击状态设置为false。测试了一下,多个手指突然抬起,最后返回的状态也是ACTION_UP //所以,这边就以状态抬起,代表当前用户不点击platformview了 params['down'] = false } @@ -371,9 +381,6 @@ export default class PlatformViewsController implements PlatformViewsAccessibili public attachToView(newFlutterView : FlutterView) { this.flutterView = newFlutterView; - for (let wrapper of this.viewWrappers.values()) { - this.flutterView?.getDVModel().children.push(wrapper.getDvModel()!); - } for (let mutator of this.platformViewParent.values()) { this.flutterView?.getDVModel().children.push(mutator.getDvModel()!); } @@ -383,9 +390,6 @@ export default class PlatformViewsController implements PlatformViewsAccessibili } public detachFromView(): void { - for (let index = 0; index < this.viewWrappers.size; index++) { - this.flutterView?.getDVModel().children.pop(); - } for (let index = 0; index < this.platformViewParent.size; index++) { this.flutterView?.getDVModel().children.pop(); } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets index a4d3da8a2393bd9f3da93d4e1578c2516046bf5a..908bb2959bb2cb3855b330a4b19d235101feb2f4 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/RootDvModelManager.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import { DVModel, diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ByteBuffer.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ByteBuffer.ets index e7cc1d3ac24f31d8f32bd64190819fee1ae57817..4dc4ec75e52a103f0ae98ba949aba48a42718135 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ByteBuffer.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ByteBuffer.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import util from '@ohos.util' diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/Log.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/Log.ets index 12a50ce3202a5f3cf2db0a0d2b3f7d140b98ced3..3df80380ad5a29c8f4cc10cd48e9ec73be2cf3fa 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/Log.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/Log.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import HiLog from '@ohos.hilog'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/MessageChannelUtils.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/MessageChannelUtils.ets index 1899f74069a24a3e250378b11ac1c9492f03b8f3..153e8e7eacb29e7a468df459b164778f4d7f5e8e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/MessageChannelUtils.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/MessageChannelUtils.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import BasicMessageChannel from '../plugin/common/BasicMessageChannel'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/PathUtils.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/PathUtils.ets index f47bcb68b0755dba14200d8a44db899528119191..78a61486e005c43dfcd20cafa0101c7c101e17c5 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/PathUtils.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/PathUtils.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import common from '@ohos.app.ability.common'; import fs from '@ohos.file.fs'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/StringUtils.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/StringUtils.ets index 8d2d4cb42124a785afe2bfed27726b2087d9e78e..c6a53de74086dbf86bc9d841711bb943ee312e79 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/StringUtils.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/StringUtils.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import flutter from 'libflutter.so' diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ToolUtils.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ToolUtils.ets index 1d13a5c93cb22c37739bcf4f39cac620920ee6ca..11da33a6128c65f61d1e8fde586ac6f53a6f898b 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ToolUtils.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/ToolUtils.ets @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ import Any from '../plugin/common/Any'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/TraceSection.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/TraceSection.ets index e74cbcce5f63e638a9cbac1e9cd59c693ca2b7a6..f9916525105dd6510b6d2762b3f0a97b7f7a8c64 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/TraceSection.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/util/TraceSection.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on TraceSection.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 hiTraceMeter from '@ohos.hiTraceMeter' diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/AccessibilityBridge.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/AccessibilityBridge.ets index c7122f48701bd5fa6365bcb72e97a38b460ef132..4e71002fe5a507e3c3a3f200f19064401ec7cdb0 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/AccessibilityBridge.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/AccessibilityBridge.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on AccessibilityBridge.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 AccessibilityChannel, {AccessibilityMessageHandler} from '../embedding/engine/systemchannels/AccessibilityChannel'; import { ByteBuffer } from '../util/ByteBuffer'; @@ -18,46 +13,8 @@ import Log from '../util/Log'; const TAG = "AccessibilityBridge"; -export default class AccessibilityBridge implements AccessibilityMessageHandler { - - private accessibilityChannel: AccessibilityChannel | null = null; - - constructor(){ - - } - - announce(message: string): void { - throw new Error('Method not implemented.'); - // android -> rootAccessibilityView.announceForAccessibility(message); - } - - onTap(nodeId: number): void { - throw new Error('Method not implemented.'); - // android -> sendAccessibilityEvent(nodeId, AccessibilityEvent.TYPE_VIEW_CLICKED); - } - - onLongPress(nodeId: number): void { - throw new Error('Method not implemented.'); - // android -> sendAccessibilityEvent(nodeId, AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); - } - - onTooltip(nodeId: string): void { - throw new Error('Method not implemented.'); - } - - updateSemantics(buffer: ByteBuffer, strings: string[], stringAttributeArgs: ByteBuffer[]): void { - Log.d(TAG, "AccessibilityBridge.ets updateSemantics is called"); - } - - updateCustomAccessibilityActions(buffer: ByteBuffer, strings: string[]): void { - Log.d(TAG, "AccessibilityBridge.ets updateCustomAccessibilityActions is called"); - - } - - accessibilityStateChange(state: Boolean): void{ - Log.d(TAG, "AccessibilityBridge.ets accessibilityStateChange is called"); - } - +export default class AccessibilityBridge { + constructor() {} } export class AccessibilityManager { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/DynamicView/dynamicView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/DynamicView/dynamicView.ets index 89b999d7f0fb013c61d75c64ec5d6ecb05c50287..721dfa23abd57fe0fd229799e475756f063f43d9 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/DynamicView/dynamicView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/DynamicView/dynamicView.ets @@ -1,16 +1,7 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ import matrix4 from '@ohos.matrix4'; import Any from '../../plugin/common/Any'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/DynamicView/dynamicViewJson.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/DynamicView/dynamicViewJson.ets index 28721b37056ed68bd92ad4d2c9b45a24e97a9569..34b669ee004002a0e766f381fab33e2cbc52a944 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/DynamicView/dynamicViewJson.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/DynamicView/dynamicViewJson.ets @@ -1,16 +1,7 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ import Any from '../../plugin/common/Any'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterCallbackInformation.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterCallbackInformation.ets index 7f9111e95f95d9784422a7695dd0db712690763e..ff6ee989661fb7157321c08b78a829ed8e346763 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterCallbackInformation.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterCallbackInformation.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterCallbackInformation.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 FlutterNapi from '../embedding/engine/FlutterNapi'; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterRunArguments.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterRunArguments.ets index c81e33f381f06662a8b881df3452d76038837361..c22408168531c046846961c9e981c4e59bcb9b57 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterRunArguments.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterRunArguments.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on FlutterRunArguments.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 default class FlutterRunArguments { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets index c8b2fd67425f49e057dd98f78fe0623c9a08ed6d..0a6b2bcc1b76ac1a376fa7807184649a2306eb31 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets @@ -1,17 +1,9 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. */ + import FlutterEngine from '../embedding/engine/FlutterEngine'; import Log from '../util/Log'; import { DVModel, DVModelChildren, DVModelEvents, DVModelParameters } from './DynamicView/dynamicView'; @@ -29,6 +21,7 @@ import { accessibility } from '@kit.AccessibilityKit'; import TextInputPlugin from '../plugin/editing/TextInputPlugin'; const TAG = "FlutterViewTag"; +const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS'; export class ViewportMetrics { devicePixelRatio: number = 1.0; @@ -47,6 +40,7 @@ export class ViewportMetrics { systemGestureInsetBottom: number = 0; systemGestureInsetLeft: number = 0; physicalTouchSlop: number = -1; + displayFeatures: ArrayList = new ArrayList(); clone(): ViewportMetrics { const copy = new ViewportMetrics(); @@ -66,6 +60,7 @@ export class ViewportMetrics { copy.systemGestureInsetBottom = this.systemGestureInsetBottom; copy.systemGestureInsetLeft = this.systemGestureInsetLeft; copy.physicalTouchSlop = this.physicalTouchSlop; + copy.displayFeatures = this.displayFeatures; return copy; } @@ -85,10 +80,67 @@ export class ViewportMetrics { this.systemGestureInsetRight === other.systemGestureInsetRight && this.systemGestureInsetBottom === other.systemGestureInsetBottom && this.systemGestureInsetLeft === other.systemGestureInsetLeft && - this.physicalTouchSlop === other.physicalTouchSlop; + this.physicalTouchSlop === other.physicalTouchSlop && + this.displayFeatures === other.displayFeatures; } } +export class DisplayFeature { + bounds: display.Rect[]; + type: DisplayFeatureType; + state: DisplayFeatureState; + + constructor(bounds: display.Rect[], type: DisplayFeatureType, state: DisplayFeatureState) { + this.bounds = bounds; + this.type = type; + this.state = state; + } + + getBounds(): display.Rect[] { + return this.bounds; + } + + getType(): DisplayFeatureType { + return this.type; + } + + getState(): DisplayFeatureState { + return this.state + } + + setBounds(bounds: display.Rect[]): void { + this.bounds = bounds; + } + + setType(type: DisplayFeatureType): void { + this.type = type; + } + + setState(state: DisplayFeatureState): void { + this.state = state; + } +} + +export enum DisplayFeatureType{ + UNKNOWN = 0, + FOLD = 1, + HINGE = 2, + CUTOUT = 3 +}; + +export enum DisplayFeatureState{ + UNKNOWN = 0, + POSTURE_FLAT = 1, + POSTURE_HALF_OPENED = 2, +}; + +export enum DisplayFoldStatus{ + FOLD_STATUS_UNKNOWN = 0, + FOLD_STATUS_EXPANDED = 1, + FOLD_STATUS_FOLDED = 2, + FOLD_STATUS_HALF_FOLDED = 3 +}; + export class PlatformViewParas { width: number = 0.0; height: number = 0.0; @@ -124,6 +176,7 @@ export class FlutterView { private mouseCursorPlugin?: MouseCursorPlugin; private textInputPlugin?: TextInputPlugin; private uiContext?: UIContext | undefined; + private context: Context; private settings?: Settings; private mFirstFrameListeners: ArrayList; private isFlutterUiDisplayed: boolean = false; @@ -137,13 +190,14 @@ export class FlutterView { private navigationAvoidArea: window.AvoidArea; private gestureAvoidArea: window.AvoidArea; private keyboardAvoidArea: window.AvoidArea; - private needSetViewport: boolean = false; - constructor(viewId: string, context: Context) { - this.id = viewId + this.id = viewId; + this.context = context; this.displayInfo = display.getDefaultDisplaySync(); this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels; + + this.buildDisplayFeatures(display.getFoldStatus()); this.mainWindow = FlutterManager.getInstance() .getWindowStage(FlutterManager.getInstance().getUIAbility(context)) .getMainWindowSync(); @@ -164,6 +218,12 @@ export class FlutterView { this.gestureAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); this.keyboardAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); + // 监听折叠状态的改变 + display?.on('foldStatusChange', (data: display.FoldStatus) => { + Log.d(TAG, `Fold status change to ${JSON.stringify(data)}`) + this.buildDisplayFeatures(data); + }) + // Subscribes to display changes. Example: event that the display size is changed. try { display.on("change", ()=>{ @@ -179,6 +239,50 @@ export class FlutterView { } } + private async buildDisplayFeatures(foldStatus: display.FoldStatus) { + let displayFeatures: ArrayList = new ArrayList(); + let bound: display.Rect[]; + let state: DisplayFeatureState = DisplayFeatureState.UNKNOWN; + let type: DisplayFeatureType = DisplayFeatureType.FOLD; + const displayInfos = display.getDefaultDisplaySync(); + if (display.isFoldable()) { + switch (foldStatus) { + case display.FoldStatus.FOLD_STATUS_EXPANDED: + type = DisplayFeatureType.FOLD; + state = DisplayFeatureState.POSTURE_FLAT; + break; + case display.FoldStatus.FOLD_STATUS_HALF_FOLDED: + type = DisplayFeatureType.FOLD; + state = DisplayFeatureState.POSTURE_HALF_OPENED; + break; + case display.FoldStatus.FOLD_STATUS_UNKNOWN: + type = DisplayFeatureType.UNKNOWN; + state = DisplayFeatureState.UNKNOWN; + break; + default: + state = DisplayFeatureState.UNKNOWN; + type = DisplayFeatureType.FOLD; + break; + } + const displays = await display.getAllDisplays(); + for (let i = 0; i < displays.length; i++) { + let cutoutInfo = await displays[i].getCutoutInfo(); + bound = cutoutInfo.boundingRects; + displayFeatures.add(new DisplayFeature(bound, type, state)); + } + Log.d(TAG, `FOLD device displayFeatures is : ${JSON.stringify(displayFeatures)}`) + } else { + type = DisplayFeatureType.CUTOUT; + state = DisplayFeatureState.UNKNOWN; + let infos = await displayInfos?.getCutoutInfo(); + bound = infos.boundingRects; + displayFeatures.add(new DisplayFeature(bound, type, state)); + Log.d(TAG, `UNFold device displayFeatures is : ${JSON.stringify(displayFeatures)}`) + } + this.viewportMetrics.displayFeatures = displayFeatures; + this.updateViewportMetrics(); + } + private windowSizeChangeCallback = (data: window.Size) => { Log.i(TAG, "windowSizeChangeCallback w:" + data.width + ", h:" + data.height); if (this.isAttachedToFlutterEngine()) { @@ -213,7 +317,7 @@ export class FlutterView { Log.i(TAG, "keyboardHeightChangeCallback " + data); this.keyboardAvoidArea.bottomRect.height = data; if (this.isAttachedToFlutterEngine()) { - this.onAreaChange(null); + this.onAreaChange(null); } }; @@ -270,6 +374,9 @@ export class FlutterView { Log.i(TAG, `unsubscribe accessibility state change, result: ${JSON.stringify(data)}`); }); this.mainWindow?.off('keyboardHeightChange', this.keyboardHeightChangeCallback); + display.off('foldStatusChange', (status: display.FoldStatus) => { + Log.d(TAG, `foldStatusChange listner destory`); + }) } catch (e) { Log.e(TAG, "mainWindow off error: " + JSON.stringify(e)); } @@ -320,6 +427,15 @@ export class FlutterView { } this.onAreaChange(newArea, true); + this.context.eventHub.on(EVENT_BACK_PRESS, () => { + if (this?.getKeyboardHeight() == 0) { + this.flutterEngine?.getNavigationChannel()?.popRoute(); + this.flutterEngine?.getPlatformViewsController()?.setBackNodeControllers(); + } else { + this.flutterEngine?.getTextInputChannel()?.textInputMethodHandler?.hide(); + } + }); + let windowId = this.mainWindow?.getWindowProperties()?.id ?? 0 this.mouseCursorPlugin = new MouseCursorPlugin(windowId, this.flutterEngine?.getMouseCursorChannel()!); this.textInputPlugin = new TextInputPlugin(this.flutterEngine?.getTextInputChannel()!); @@ -346,6 +462,7 @@ export class FlutterView { this.flutterEngine = null; this.keyboardManager = null; this.textInputPlugin?.destroy(); + this.context?.eventHub.off(EVENT_BACK_PRESS); } onWindowCreated() { @@ -378,42 +495,54 @@ export class FlutterView { } } - onAreaChange(newArea: Area | null, setFullScreen: boolean = false) { - const originalMetrics = this.viewportMetrics.clone(); + onAccessibilityIsOpen() { + let accessibilityState: boolean = accessibility.isOpenAccessibilitySync(); + if(accessibilityState) { + this.flutterEngine?.getFlutterNapi()?.accessibilityStateChange(accessibilityState) + } + Log.i(TAG, `accessibility isOpen state -> ${JSON.stringify(accessibilityState)}`); + } + onAreaChange(newArea: Area | null, setFullScreen: boolean = false) { if (newArea != null) { this.viewportMetrics.physicalWidth = vp2px(newArea.width as number); this.viewportMetrics.physicalHeight = vp2px(newArea.height as number); } // 根据是否全屏显示,设置标题栏高度(若全屏,则及时规避) - if (this.checkFullScreen && (setFullScreen || this.mainWindow?.getWindowProperties().isLayoutFullScreen)) { // 全屏显示 - this.viewportMetrics.physicalViewPaddingTop = this.systemAvoidArea?.topRect.height ?? 0; - this.viewportMetrics.physicalViewPaddingBottom = this.navigationAvoidArea?.bottomRect.height ?? 0; + let isUseFullScreen = FlutterManager.getInstance().getFullScreenListener().useFullScreen(); + let isLayoutFullScreen = this.mainWindow?.getWindowProperties().isLayoutFullScreen; + if (this.checkFullScreen && (setFullScreen || isLayoutFullScreen || isUseFullScreen)) { // 全屏显示 + this.viewportMetrics.physicalViewPaddingTop = + this.systemAvoidArea?.topRect.height ?? this.viewportMetrics.physicalViewPaddingTop; + this.viewportMetrics.physicalViewPaddingBottom = + this.navigationAvoidArea?.bottomRect.height ?? this.viewportMetrics.physicalViewPaddingBottom; } else { // 非全屏显示(保持规避效果) // 顶部状态栏和底部导航栏规避为0,无平滑过渡效果 this.viewportMetrics.physicalViewPaddingTop = 0; this.viewportMetrics.physicalViewPaddingBottom = 0; } - this.viewportMetrics.physicalViewPaddingLeft = this.systemAvoidArea?.leftRect.width ?? 0; - this.viewportMetrics.physicalViewPaddingRight = this.systemAvoidArea?.rightRect.width ?? 0; + this.viewportMetrics.physicalViewPaddingLeft = + this.systemAvoidArea?.leftRect.width ?? this.viewportMetrics.physicalViewPaddingLeft; + this.viewportMetrics.physicalViewPaddingRight = + this.systemAvoidArea?.rightRect.width ?? this.viewportMetrics.physicalViewPaddingRight; this.onKeyboardAreaChange() this.onGestureAreaChange() - if (!this.viewportMetrics.isEqual(originalMetrics) || this.needSetViewport) { - if (!this.updateViewportMetrics()) { - this.needSetViewport = true; - } - } + this.updateViewportMetrics() } private onKeyboardAreaChange() { if (this.checkKeyboard) { - this.viewportMetrics.physicalViewInsetTop = this.keyboardAvoidArea?.topRect.height ?? 0 - this.viewportMetrics.physicalViewInsetLeft = this.keyboardAvoidArea?.leftRect.width ?? 0 - this.viewportMetrics.physicalViewInsetBottom = this.keyboardAvoidArea?.bottomRect.height ?? 0 - this.viewportMetrics.physicalViewInsetRight = this.keyboardAvoidArea?.rightRect.width ?? 0 + this.viewportMetrics.physicalViewInsetTop = + this.keyboardAvoidArea?.topRect.height ?? this.viewportMetrics.physicalViewInsetTop + this.viewportMetrics.physicalViewInsetLeft = + this.keyboardAvoidArea?.leftRect.width ?? this.viewportMetrics.physicalViewInsetLeft + this.viewportMetrics.physicalViewInsetBottom = + this.keyboardAvoidArea?.bottomRect.height ?? this.viewportMetrics.physicalViewInsetBottom + this.viewportMetrics.physicalViewInsetRight = + this.keyboardAvoidArea?.rightRect.width ?? this.viewportMetrics.physicalViewInsetRight } else { this.viewportMetrics.physicalViewInsetTop = 0 this.viewportMetrics.physicalViewInsetLeft = 0 @@ -424,10 +553,14 @@ export class FlutterView { private onGestureAreaChange() { if (this.checkGesture) { - this.viewportMetrics.systemGestureInsetTop = this.gestureAvoidArea?.topRect.height ?? 0 - this.viewportMetrics.systemGestureInsetLeft = this.gestureAvoidArea?.leftRect.width ?? 0 - this.viewportMetrics.systemGestureInsetBottom = this.gestureAvoidArea?.bottomRect.height ?? 0 - this.viewportMetrics.systemGestureInsetRight = this.gestureAvoidArea?.rightRect.width ?? 0 + this.viewportMetrics.systemGestureInsetTop = + this.gestureAvoidArea?.topRect.height ?? this.viewportMetrics.systemGestureInsetTop + this.viewportMetrics.systemGestureInsetLeft = + this.gestureAvoidArea?.leftRect.width ?? this.viewportMetrics.systemGestureInsetLeft + this.viewportMetrics.systemGestureInsetBottom = + this.gestureAvoidArea?.bottomRect.height ?? this.viewportMetrics.systemGestureInsetBottom + this.viewportMetrics.systemGestureInsetRight = + this.gestureAvoidArea?.rightRect.width ?? this.viewportMetrics.systemGestureInsetRight } else { this.viewportMetrics.systemGestureInsetTop = 0 this.viewportMetrics.systemGestureInsetLeft = 0 @@ -441,31 +574,53 @@ export class FlutterView { } private updateViewportMetrics(): boolean { - if (this.isAttachedToFlutterEngine()) { - Log.i(TAG, 'updateViewportMetrics devicePixelRatio:' + this.viewportMetrics.devicePixelRatio); - - this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, - this.viewportMetrics.physicalWidth, - this.viewportMetrics.physicalHeight, - this.viewportMetrics.physicalViewPaddingTop, - this.viewportMetrics.physicalViewPaddingRight, - this.viewportMetrics.physicalViewPaddingBottom, - this.viewportMetrics.physicalViewPaddingLeft, - this.viewportMetrics.physicalViewInsetTop, - this.viewportMetrics.physicalViewInsetRight, - this.viewportMetrics.physicalViewInsetBottom, - this.viewportMetrics.physicalViewInsetLeft, - this.viewportMetrics.systemGestureInsetTop, - this.viewportMetrics.systemGestureInsetRight, - this.viewportMetrics.systemGestureInsetBottom, - this.viewportMetrics.systemGestureInsetLeft, - this.viewportMetrics.physicalTouchSlop, - new Array(0), - new Array(0), - new Array(0)) - return true; + if (!this.isAttachedToFlutterEngine()) { + return false; + } + Log.i(TAG, 'updateViewportMetrics devicePixelRatio:' + this.viewportMetrics.devicePixelRatio); + + const displayFeatures = this.viewportMetrics.displayFeatures; + let boundCount = 0; + for (let i = 0; i < displayFeatures.length; i++) { + boundCount = boundCount + displayFeatures[i].getBounds().length; + } + let displayFeatureBound: number[] = new Array(boundCount * 4); + let displayFeatureType: number[] = new Array(boundCount ? displayFeatures.length : boundCount); + let displayFeatureStatus: number[] = new Array(boundCount ? displayFeatures.length : boundCount); + for (let i = 0; i < displayFeatures.length; i++) { + let singleFeatureBound = displayFeatures[i].getBounds(); + if (singleFeatureBound.length === 0) { + continue; + } + for (let j = 0; j < singleFeatureBound.length; j++) { + displayFeatureBound[4 * i + 4 * j] = singleFeatureBound[j].left; + displayFeatureBound[4 * i + 4 * j + 1] = singleFeatureBound[j].top; + displayFeatureBound[4 * i + 4 * j + 2] = singleFeatureBound[j].width; + displayFeatureBound[4 * i + 4 * j + 3] = singleFeatureBound[j].height; + } + displayFeatureType[i] = displayFeatures[i].getType(); + displayFeatureStatus[i] = displayFeatures[i].getState(); } - return false; + this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, + this.viewportMetrics.physicalWidth, + this.viewportMetrics.physicalHeight, + this.viewportMetrics.physicalViewPaddingTop, + this.viewportMetrics.physicalViewPaddingRight, + this.viewportMetrics.physicalViewPaddingBottom, + this.viewportMetrics.physicalViewPaddingLeft, + this.viewportMetrics.physicalViewInsetTop, + this.viewportMetrics.physicalViewInsetRight, + this.viewportMetrics.physicalViewInsetBottom, + this.viewportMetrics.physicalViewInsetLeft, + this.viewportMetrics.systemGestureInsetTop, + this.viewportMetrics.systemGestureInsetRight, + this.viewportMetrics.systemGestureInsetBottom, + this.viewportMetrics.systemGestureInsetLeft, + this.viewportMetrics.physicalTouchSlop, + displayFeatureBound, + displayFeatureType, + displayFeatureStatus) + return true; } onKeyPreIme(event: KeyEvent) : boolean { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/TextureRegistry.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/TextureRegistry.ets index 6ba421adf64bc2d3dfacc1ed9f2814a97e432d7b..0d7b06275ace12214adcf8bec9bf5ff543c63df7 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/TextureRegistry.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/TextureRegistry.ets @@ -1,16 +1,11 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE_KHZG file. * -* http://www.apache.org/licenses/LICENSE-2.0 +* Based on TextureRegistry.java originally written by +* Copyright (C) 2013 The Flutter Authors. * -* 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 image from '@ohos.multimedia.image'; @@ -22,6 +17,7 @@ export interface TextureRegistry { registerSurfaceTexture(receiver: image.ImageReceiver): SurfaceTextureEntry; registerPixelMap(pixelMap: PixelMap): number; setTextureBackGroundPixelMap(textureId: number, pixelMap: PixelMap): void; + setTextureBackGroundColor(textureId: number, color: number): void; setTextureBufferSize(textureId: number, width: number, height: number): void; unregisterTexture(textureId: number): void; onTrimMemory(level: number) : void; diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/module.json5 b/shell/platform/ohos/flutter_embedding/flutter/src/main/module.json5 index 61db0f5caed1a2eeec6fc991771d07d842f762d6..fbc27f63179e59f03ae404046aa305a6eeb681fe 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/module.json5 +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/module.json5 @@ -1,17 +1,3 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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": { diff --git a/shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5 b/shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5 index ebe4ba53b079cf5966e7f69c5a98029467543db6..941ccf5d6617fcf0eee14913e230f293eb86ca18 100755 --- a/shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5 +++ b/shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5 @@ -1,18 +1,3 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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.0", "dependencies": { diff --git a/shell/platform/ohos/flutter_embedding/hvigorfile.ts b/shell/platform/ohos/flutter_embedding/hvigorfile.ts index 8f2d2aafe6d6a3a71a9944ebd0c91fbc308ac9d1..acfff37c8a67f074a0fd4692ae3852b44a829a3a 100755 --- a/shell/platform/ohos/flutter_embedding/hvigorfile.ts +++ b/shell/platform/ohos/flutter_embedding/hvigorfile.ts @@ -1,17 +1,3 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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'; diff --git a/shell/platform/ohos/flutter_embedding/oh-package.json5 b/shell/platform/ohos/flutter_embedding/oh-package.json5 index dd166cc567287d35e89516bb40e631c8786e7836..61cb1bb5007087672800f22785a108ebc92f4756 100755 --- a/shell/platform/ohos/flutter_embedding/oh-package.json5 +++ b/shell/platform/ohos/flutter_embedding/oh-package.json5 @@ -1,17 +1,3 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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.0", diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 4f7216d73ef7d48af4a53c339d42817fff345a46..165f9c26f6b6c55dd94acd1f54ea1c38392d49b2 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #include "flutter/shell/platform/ohos/napi/platform_view_ohos_napi.h" @@ -132,6 +123,9 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeSetTextureBackGroundPixelMap", flutter::PlatformViewOHOSNapi::nativeSetTextureBackGroundPixelMap), + DECLARE_NAPI_FUNCTION( + "nativeSetTextureBackGroundColor", + flutter::PlatformViewOHOSNapi::nativeSetTextureBackGroundColor), DECLARE_NAPI_FUNCTION("nativeEncodeUtf8", flutter::PlatformViewOHOSNapi::nativeEncodeUtf8), DECLARE_NAPI_FUNCTION("nativeDecodeUtf8", @@ -146,8 +140,17 @@ static napi_value Init(napi_env env, napi_value exports) { "nativeAccessibilityStateChange", flutter::PlatformViewOHOSNapi::nativeAccessibilityStateChange), DECLARE_NAPI_FUNCTION( - "nativeAnnounce", - flutter::PlatformViewOHOSNapi::nativeAnnounce), + "nativeAccessibilityAnnounce", + flutter::PlatformViewOHOSNapi::nativeAccessibilityAnnounce), + DECLARE_NAPI_FUNCTION( + "nativeAccessibilityOnTap", + flutter::PlatformViewOHOSNapi::nativeAccessibilityOnTap), + DECLARE_NAPI_FUNCTION( + "nativeAccessibilityOnLongPress", + flutter::PlatformViewOHOSNapi::nativeAccessibilityOnLongPress), + DECLARE_NAPI_FUNCTION( + "nativeAccessibilityOnTooltip", + flutter::PlatformViewOHOSNapi::nativeAccessibilityOnTooltip), DECLARE_NAPI_FUNCTION( "nativeSetSemanticsEnabled", flutter::PlatformViewOHOSNapi::nativeSetSemanticsEnabled), @@ -181,6 +184,12 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeUnicodeIsRegionalIndicatorSymbol", flutter::PlatformViewOHOSNapi::nativeUnicodeIsRegionalIndicatorSymbol), + DECLARE_NAPI_FUNCTION( + "nativeGetXComponentId", + flutter::PlatformViewOHOSNapi::nativeGetXComponentId), + DECLARE_NAPI_FUNCTION( + "nativeSetDVsyncSwitch", + flutter::PlatformViewOHOSNapi::nativeSetDVsyncSwitch), }; FML_DLOG(INFO) << "Init NAPI size=" << sizeof(desc) / sizeof(desc[0]); diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index ef196b0b6c15e9ae77a4084999e21b7aa0c308eb..cfa0c2d3090003d006221772fcee25aff931f43e 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #include "platform_view_ohos_napi.h" @@ -31,6 +22,7 @@ #include "flutter/shell/platform/ohos/ohos_xcomponent_adapter.h" #include "flutter/shell/platform/ohos/surface/ohos_native_window.h" #include "flutter/shell/platform/ohos/types.h" +#include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" #include "flutter/lib/ui/plugins/callback_cache.h" #include "unicode/uchar.h" @@ -40,6 +32,7 @@ namespace flutter { napi_env PlatformViewOHOSNapi::env_; std::vector PlatformViewOHOSNapi::system_languages; int64_t PlatformViewOHOSNapi::napi_shell_holder_id_; +const int32_t PlatformViewOHOSNapi::OHOS_API_VERSION = OH_GetSdkApiVersion(); /** * @brief send empty PlatformMessage @@ -1583,6 +1576,24 @@ napi_value PlatformViewOHOSNapi::nativeSetTextureBackGroundPixelMap( return nullptr; } +napi_value PlatformViewOHOSNapi::nativeSetTextureBackGroundColor( + napi_env env, + napi_callback_info info) { + FML_DLOG(INFO) << "PlatformViewOHOSNapi::nativeSetTextureBackGroundColor"; + size_t argc = 3; + napi_value args[3] = {nullptr}; + int64_t shell_holder; + int64_t textureId; + uint32_t color; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); + NAPI_CALL(env, napi_get_value_int64(env, args[0], &shell_holder)); + NAPI_CALL(env, napi_get_value_int64(env, args[1], &textureId)); + NAPI_CALL(env, napi_get_value_uint32(env, args[2], &color)); + OHOS_SHELL_HOLDER->GetPlatformView()->SetExternalTextureBackGroundColor( + textureId, color); + return nullptr; +} + void PlatformViewOHOSNapi::SurfaceCreated(int64_t shell_holder, void* window) { auto native_window = fml::MakeRefCounted( static_cast(window)); @@ -1849,14 +1860,14 @@ napi_value PlatformViewOHOSNapi::nativeAccessibilityStateChange( << ret; return nullptr; } - int64_t shell_holder_id; - ret = napi_get_value_int64(env, args[0], &shell_holder_id); + + int64_t shellHolder = 0; + ret = napi_get_value_int64(env, args[0], &shellHolder); if (ret != napi_ok) { - FML_DLOG(ERROR) << "PlatformViewOHOSNapi::nativeAccessibilityStateChange " - "napi_get_value_int64 error:" - << ret; + LOGE("nativeAccessibilityStateChange shellHolder napi_get_value_int64 error"); return nullptr; } + bool state = false; ret = napi_get_value_bool(env, args[1], &state); if (ret != napi_ok) { @@ -1865,20 +1876,17 @@ napi_value PlatformViewOHOSNapi::nativeAccessibilityStateChange( << ret; return nullptr; } - LOGD( - "PlatformViewOHOSNapi::nativeAccessibilityStateChange state is: " - "%{public}s", - (state ? "true" : "false")); + LOGD("PlatformViewOHOSNapi::nativeAccessibilityStateChange state is: " + "%{public}s, shellholderId: %{public}ld", (state ? "true" : "false"), shellHolder); //send to accessibility bridge - auto a11y_bridge = OhosAccessibilityBridge::GetInstance(); - a11y_bridge->OnOhosAccessibilityStateChange(shell_holder_id, state); - FML_DLOG(INFO) << "nativeAccessibilityStateChange: state=" << state - << " shell_holder_id=" << shell_holder_id; + if (OHOS_API_VERSION >= 13) { + OhosAccessibilityBridge::GetInstance()->OnOhosAccessibilityStateChange(state, shellHolder); + } return nullptr; } -napi_value PlatformViewOHOSNapi::nativeAnnounce( +napi_value PlatformViewOHOSNapi::nativeAccessibilityAnnounce( napi_env env, napi_callback_info info) { size_t argc = 1; @@ -1892,9 +1900,71 @@ napi_value PlatformViewOHOSNapi::nativeAnnounce( auto char_array = std::make_unique(null_terminated_length); napi_get_value_string_utf8(env, args[0], char_array.get(), null_terminated_length, nullptr); - LOGD("PlatformViewOHOSNapi::nativeAnnounce message: %{public}s", char_array.get()); - auto handler = std::make_shared(); - handler->Announce(char_array); + LOGD("PlatformViewOHOSNapi::nativeAccessibilityAnnounce message: %{public}s", char_array.get()); + + if (OHOS_API_VERSION >= 13) { + auto handler = std::make_shared(); + handler->Announce(char_array); + } + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeAccessibilityOnTap( + napi_env env, + napi_callback_info info) { + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + int32_t nodeId; + napi_get_value_int32(env, args[0], &nodeId); + + if (OHOS_API_VERSION >= 13) { + auto handler = std::make_shared(); + handler->OnTap(nodeId); + LOGI("nativeAccessibilityOnTap -> nodeId:%{public}d", nodeId); + } + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeAccessibilityOnLongPress( + napi_env env, + napi_callback_info info) { + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + int32_t nodeId; + napi_get_value_int32(env, args[0], &nodeId);; + + if (OHOS_API_VERSION >= 13) { + auto handler = std::make_shared(); + handler->OnLongPress(nodeId); + LOGI("nativeAccessibilityOnLongPress -> nodeId:%{public}d", nodeId); + } + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeAccessibilityOnTooltip( + napi_env env, + napi_callback_info info) { + size_t argc = 1; + napi_value args[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + size_t length = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &length); + + auto null_terminated_length = length + 1; + auto char_array = std::make_unique(null_terminated_length); + napi_get_value_string_utf8(env, args[0], char_array.get(), + null_terminated_length, nullptr); + LOGD("PlatformViewOHOSNapi::nativeAccessibilityOnTooltip message: %{public}s", char_array.get()); + +if (OHOS_API_VERSION >= 13) { + auto handler = std::make_shared(); + handler->OnTooltip(char_array); + } return nullptr; } @@ -2103,8 +2173,7 @@ napi_value PlatformViewOHOSNapi::nativeGetFlutterNavigationAction(napi_env env, return nullptr; } - auto ohosAccessibilityBridge = OhosAccessibilityBridge::GetInstance(); - ohosAccessibilityBridge->IS_FLUTTER_NAVIGATE = isNavigate; + OhosAccessibilityBridge::GetInstance()->isFlutterNavigated_ = isNavigate; FML_DLOG(INFO) << "PlatformViewOHOSNapi::nativeGetFlutterNavigationAction -> "<currentXComponentId_ = xcomponentId; + FML_DLOG(ERROR) << "nativeGetXComponentId -> xcomponentId: " << xcomponentId; + return nullptr; +} + + +napi_value PlatformViewOHOSNapi::nativeSetDVsyncSwitch(napi_env env, napi_callback_info info) +{ + size_t argc = 2; + napi_value result; + napi_value args[2] = {nullptr}; + napi_status ret = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + if (ret != napi_ok) { + LOGE("nativeSetDVsyncSwitch napi_get_cb_info error"); + napi_create_int32(env, -1, &result); + return result; + } + + int64_t shell_holder; + ret = napi_get_value_int64(env, args[0], &shell_holder); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeSetDVsyncSwitch shell_holder " + "napi_get_value_int64 error"; + return nullptr; + } + + bool isEnable; + ret = napi_get_value_bool(env, args[1], &isEnable); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "nativeSetDVsyncSwitch isEnable " + "napi_get_value_bool error"; + return nullptr; + } + + auto vsyncWaiter = std::shared_ptr(OHOS_SHELL_HOLDER->GetVsyncWaiter().lock()); + auto vsync_waiter_ohos = std::static_pointer_cast(vsyncWaiter); + + if (isEnable) { + LOGD("EnableDVsync"); + } else { + LOGD("DisableDVsync"); + } + + napi_create_int32(env, 0, &result); + return result; +} } // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 34be921e978e026d0d0550abc25ad0ce87b0d52d..65c59694173b2b797d5876c9c84c68346b16e596 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -1,21 +1,13 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #ifndef PLATFORM_VIEW_OHOS_NAPI_H #define PLATFORM_VIEW_OHOS_NAPI_H #include +#include #include "flutter/assets/directory_asset_bundle.h" #include "flutter/common/settings.h" #include "flutter/fml/file.h" @@ -183,6 +175,9 @@ class PlatformViewOHOSNapi { static napi_value nativeSetTextureBackGroundPixelMap(napi_env env, napi_callback_info info); + static napi_value nativeSetTextureBackGroundColor(napi_env env, + napi_callback_info info); + static napi_value nativeRegisterTexture(napi_env env, napi_callback_info info); @@ -218,7 +213,16 @@ class PlatformViewOHOSNapi { static napi_value nativeAccessibilityStateChange( napi_env env, napi_callback_info info); - static napi_value nativeAnnounce( + static napi_value nativeAccessibilityAnnounce( + napi_env env, + napi_callback_info info); + static napi_value nativeAccessibilityOnTap( + napi_env env, + napi_callback_info info); + static napi_value nativeAccessibilityOnLongPress( + napi_env env, + napi_callback_info info); + static napi_value nativeAccessibilityOnTooltip( napi_env env, napi_callback_info info); static napi_value nativeSetSemanticsEnabled(napi_env env, napi_callback_info info); @@ -259,12 +263,21 @@ class PlatformViewOHOSNapi { napi_env env, napi_callback_info info); + static napi_value nativeGetXComponentId( + napi_env env, + napi_callback_info info); + + static napi_value nativeSetDVsyncSwitch( + napi_env env, + napi_callback_info info); + private: static napi_env env_; napi_ref ref_napi_obj_; static std::vector system_languages; fml::RefPtr platform_task_runner_; static int64_t napi_shell_holder_id_; + static const int32_t OHOS_API_VERSION; }; } // namespace flutter diff --git a/shell/platform/ohos/napi_common.h b/shell/platform/ohos/napi_common.h index 9837fa09eb23b31224af63fdde9789c509624ed2..7ce06c7246f5034d4a18af406977ab1d40c6fb2b 100644 --- a/shell/platform/ohos/napi_common.h +++ b/shell/platform/ohos/napi_common.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ // @@ -24,18 +15,18 @@ #define NAPI_RETVAL_NOTHING -#define GET_AND_THROW_LAST_ERROR(env) \ - do { \ - const napi_extended_error_info* errorInfo = nullptr; \ - napi_get_last_error_info((env), &errorInfo); \ - bool isPending = false; \ - napi_is_exception_pending((env), &isPending); \ - if (!isPending && errorInfo != nullptr) { \ - const char* errorMessage = errorInfo->error_message != nullptr \ - ? errorInfo->error_message \ - : "empty error message"; \ - napi_throw_error((env), nullptr, errorMessage); \ - } \ +#define GET_AND_THROW_LAST_ERROR(env) \ + do { \ + const napi_extended_error_info* error_Info = nullptr; \ + napi_get_last_error_info((env), &error_Info); \ + bool isPending = false; \ + napi_is_exception_pending((env), &isPending); \ + if (!isPending && error_Info != nullptr) { \ + const char* errorMessage = error_Info->error_message != nullptr \ + ? error_Info->error_message \ + : "empty error message"; \ + napi_throw_error((env), nullptr, errorMessage); \ + } \ } while (0) #define NAPI_ASSERT_BASE(env, assertion, message, retVal) \ @@ -53,12 +44,12 @@ #define NAPI_ASSERT_RETURN_VOID(env, assertion, message) \ NAPI_ASSERT_BASE(env, assertion, message, NAPI_RETVAL_NOTHING) -#define NAPI_CALL_BASE(env, theCall, retVal) \ - do { \ - if ((theCall) != napi_ok) { \ - GET_AND_THROW_LAST_ERROR((env)); \ - return retVal; \ - } \ +#define NAPI_CALL_BASE(env, theCall, retValue) \ + do { \ + if ((theCall) != napi_ok) { \ + GET_AND_THROW_LAST_ERROR((env)); \ + return retValue; \ + } \ } while (0) #define NAPI_CALL(env, theCall) NAPI_CALL_BASE(env, theCall, nullptr) diff --git a/shell/platform/ohos/ohos_asset_provider.cpp b/shell/platform/ohos/ohos_asset_provider.cpp index c7b60e2b15ed437b80beacd2bf842ebf6723b4df..291ce56bc82aec74a9114939f5ec906dc587e0e3 100755 --- a/shell/platform/ohos/ohos_asset_provider.cpp +++ b/shell/platform/ohos/ohos_asset_provider.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "ohos_asset_provider.h" diff --git a/shell/platform/ohos/ohos_asset_provider.h b/shell/platform/ohos/ohos_asset_provider.h index 666aeb69b66cedb6e7859821efeb6c9fec59965a..a55aca69a39ead16e386f530eddbe18613e8556f 100755 --- a/shell/platform/ohos/ohos_asset_provider.h +++ b/shell/platform/ohos/ohos_asset_provider.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef OHOS_ASSET_PROVIDER_H diff --git a/shell/platform/ohos/ohos_context_gl_impeller.cpp b/shell/platform/ohos/ohos_context_gl_impeller.cpp index 1610073bb8364a0d9f55134dd5be5de8a85770d7..1c7cf7d9bf0b575778a44f9239e053dc92032eac 100755 --- a/shell/platform/ohos/ohos_context_gl_impeller.cpp +++ b/shell/platform/ohos/ohos_context_gl_impeller.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "ohos_context_gl_impeller.h" diff --git a/shell/platform/ohos/ohos_context_gl_impeller.h b/shell/platform/ohos/ohos_context_gl_impeller.h index 9be28a018c788ccd7f27c9a811bd16169257c5e4..bd6f48628f69868df93e530e8ee1fbfe227337f2 100755 --- a/shell/platform/ohos/ohos_context_gl_impeller.h +++ b/shell/platform/ohos/ohos_context_gl_impeller.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef OHOS_CONTEXT_GL_IMPELLER_H diff --git a/shell/platform/ohos/ohos_context_gl_skia.cpp b/shell/platform/ohos/ohos_context_gl_skia.cpp index 2dbd1a971833dc6f5d6d5bbd3ab90b921c1dfe96..43ecdd16126b560d261e974e41786dade6d1d12c 100755 --- a/shell/platform/ohos/ohos_context_gl_skia.cpp +++ b/shell/platform/ohos/ohos_context_gl_skia.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/ohos_context_gl_skia.h" diff --git a/shell/platform/ohos/ohos_context_gl_skia.h b/shell/platform/ohos/ohos_context_gl_skia.h index c30a24da87310f8b2e02f62c53de08875e1152d6..cb80b6604513e842fb3c132462f3c208cff49ca3 100755 --- a/shell/platform/ohos/ohos_context_gl_skia.h +++ b/shell/platform/ohos/ohos_context_gl_skia.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_CONTEXT_GL_SKIA_H_ diff --git a/shell/platform/ohos/ohos_display.cpp b/shell/platform/ohos/ohos_display.cpp index 3f23e95b007803dcf71befb620d0a0043e46a6ba..fa9afd45504f9c49881d3b1bd0b6a6b83ff2de7a 100644 --- a/shell/platform/ohos/ohos_display.cpp +++ b/shell/platform/ohos/ohos_display.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/ohos_display.h" @@ -19,11 +11,14 @@ namespace flutter { const double defaultFPS = 60; -OHOSDisplay::OHOSDisplay(std::shared_ptr napi_facade) - : Display(defaultFPS), napi_facade_(std::move(napi_facade)) {} +OHOSDisplay::OHOSDisplay(std::shared_ptr vsync_waiter_ohos) + : Display(defaultFPS), vsync_waiter_ohos_(std::move(vsync_waiter_ohos)) {} double OHOSDisplay::GetRefreshRate() const { - return defaultFPS; + if (vsync_waiter_ohos_ != nullptr) { + return (double)vsync_waiter_ohos_->GetRefreshRate(); + } + return defaultFPS; } } // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/ohos_display.h b/shell/platform/ohos/ohos_display.h index 873f2cff90e15467199eda7890a68b7c66229b62..098be0f1df5f01f5cd3fb0e75a28cb99986a6d2d 100644 --- a/shell/platform/ohos/ohos_display.h +++ b/shell/platform/ohos/ohos_display.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef OHOS_DISPLAY_H @@ -21,17 +13,18 @@ #include "flutter/fml/macros.h" #include "flutter/shell/common/display.h" #include "flutter/shell/platform/ohos/napi/platform_view_ohos_napi.h" +#include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" namespace flutter { class OHOSDisplay : public Display { public: - explicit OHOSDisplay(std::shared_ptr napi_facade_); + explicit OHOSDisplay(std::shared_ptr vsync_waiter_ohos); ~OHOSDisplay() = default; double GetRefreshRate() const override; private: - std::shared_ptr napi_facade_; + std::shared_ptr vsync_waiter_ohos_; FML_DISALLOW_COPY_AND_ASSIGN(OHOSDisplay); }; } // namespace flutter diff --git a/shell/platform/ohos/ohos_egl_surface.cpp b/shell/platform/ohos/ohos_egl_surface.cpp index a9e5ece5cb4a2f49c44c203b31e09adf7f5e21b8..caab7cd7b2eeae643af117b1145a0dff3c8f0f14 100755 --- a/shell/platform/ohos/ohos_egl_surface.cpp +++ b/shell/platform/ohos/ohos_egl_surface.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/ohos_egl_surface.h" diff --git a/shell/platform/ohos/ohos_egl_surface.h b/shell/platform/ohos/ohos_egl_surface.h index a2f98f90a40b295fe836e065c890a491e4b1df6f..dd1cb98e25ba0c767b89605a3ccff51aafe197ff 100755 --- a/shell/platform/ohos/ohos_egl_surface.h +++ b/shell/platform/ohos/ohos_egl_surface.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 FLUTTER_SHELL_PLATFORM_OHOS_EGL_SURFACE_H_ diff --git a/shell/platform/ohos/ohos_environment_gl.cpp b/shell/platform/ohos/ohos_environment_gl.cpp index b179e6a05aa5c15d4585c610c4db40cb1ae9f819..545b7037b2c9fcd2ed25f6948ff2a0b1be082974 100755 --- a/shell/platform/ohos/ohos_environment_gl.cpp +++ b/shell/platform/ohos/ohos_environment_gl.cpp @@ -1,18 +1,11 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/ohos_environment_gl.h" namespace flutter { diff --git a/shell/platform/ohos/ohos_environment_gl.h b/shell/platform/ohos/ohos_environment_gl.h index a2e925f61284b27471b703a6c903558758ac4c30..591a8bb57c37be1a329a7e6bc609834700aef218 100755 --- a/shell/platform/ohos/ohos_environment_gl.h +++ b/shell/platform/ohos/ohos_environment_gl.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 FLUTTER_SHELL_PLATFORM_OHOS_ENVIRONMENT_GL_H_ diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index f160e09469ace687db0b6cd5c68f5cf8cd91e85a..e3343dd8cc8ef754f39e9168b81f2f703d36f143 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "ohos_external_texture_gl.h" @@ -39,7 +30,6 @@ constexpr const char *CHARACTER_STRING_WHITESPACE = " "; constexpr const char *EGL_EXT_PLATFORM_WAYLAND = "EGL_EXT_platform_wayland"; constexpr const char *EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; constexpr const char *EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; -constexpr uint32_t WHITE_COLOR = 0xFFFFFFFF; const SkScalar DEFAULT_MATRIX[] = {1, 0, 0, 0, -1, 1, 0, 0, 1}; @@ -104,7 +94,6 @@ OHOSExternalTextureGL::OHOSExternalTextureGL( backGroundPixelMap_ = nullptr; lastImage_ = nullptr; isEmulator_ = OhosMain::IsEmulator(); - frameData_ = nullptr; } OHOSExternalTextureGL::~OHOSExternalTextureGL() @@ -125,24 +114,37 @@ OHOSExternalTextureGL::~OHOSExternalTextureGL() lastImage_ = nullptr; } -void OnNativeImageFrameAvailable(void *data) +void OnNativeImageFrameAvailable(void *context) { - auto frameData = reinterpret_cast(data); - if (frameData == nullptr) { - FML_LOG(ERROR) << "OnNativeImageFrameAvailable, frameData is null."; + auto ohosExternalTextureGL = reinterpret_cast(context); + if (ohosExternalTextureGL == nullptr) { + FML_LOG(ERROR) << "OnNativeImageFrameAvailable, ohosExternalTextureGL is null."; return; } - frameData->OnPlatformViewMarkTextureFrameAvailable(); + + if (ohosExternalTextureGL != nullptr) { + auto wp_ohosExternalTextureGL = std::weak_ptr( + ohosExternalTextureGL->shared_from_this()); + fml::TaskRunner::RunNowOrPostTask( + ohosExternalTextureGL->task_runners_.GetPlatformTaskRunner(), + [wp_ohosExternalTextureGL]() { + if (auto sp_ohosExternalTextureGL = wp_ohosExternalTextureGL.lock()) { + PlatformView::Delegate& delegate = + sp_ohosExternalTextureGL->delegate_; + delegate.OnPlatformViewMarkTextureFrameAvailable(sp_ohosExternalTextureGL->Id()); + } + }); + } } -bool RegisterFrameAvailableListener(OH_NativeImage *nativeImage, OhosImageFrameData *frameData) +bool RegisterFrameAvailableListener(OH_NativeImage *nativeImage, void *context) { - if (frameData == nullptr) { - FML_LOG(ERROR) << "Error with RegisterFrameAvailableListener, frameData is null"; + if (context == nullptr) { + FML_LOG(ERROR) << "Error with RegisterFrameAvailableListener, context is null"; return false; } OH_OnFrameAvailableListener listener; - listener.context = frameData; + listener.context = context; listener.onFrameAvailable = OnNativeImageFrameAvailable; int64_t ret = OH_NativeImage_SetOnFrameAvailableListener(nativeImage, listener); if (ret != 0) { @@ -191,12 +193,7 @@ void OHOSExternalTextureGL::Attach() FML_LOG(ERROR) << "OHOSExternalTextureGL OH_NativeImage_AttachContext err code:" << ret; } - if (frameData_ == nullptr) { - frameData_ = new OhosImageFrameData(this, Id()); - } - if (!RegisterFrameAvailableListener(nativeImage_, (OhosImageFrameData *)frameData_)) { - delete (OhosImageFrameData *)frameData_; - frameData_ = nullptr; + if (!RegisterFrameAvailableListener(nativeImage_, this)) { return; } state_ = AttachmentState::attached; @@ -273,14 +270,74 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, } } +void OHOSExternalTextureGL::Show() +{ + if (state_ != AttachmentState::hide) { + FML_LOG(WARNING) << "OHOSExternalTextureGL show, state is not hide, ignore this call"; + return; + } + OHOSSurface* ohos_surface_ptr = ohos_surface_.get(); + OhosSurfaceGLSkia* ohosSurfaceGLSkia_ = (OhosSurfaceGLSkia*)ohos_surface_ptr; + if (ohosSurfaceGLSkia_->GetOnscreenSurface() == nullptr) { + FML_LOG(ERROR) << "OHOSExternalTextureGL show, GetSurface failed"; + return; + } + auto result = ohosSurfaceGLSkia_->GLContextMakeCurrent(); + if (result->GetResult()) { + FML_DLOG(INFO) << "OHOSExternalTextureGL show, MakeCurrent successed"; + glGenTextures(1, &texture_name_); + FML_DLOG(INFO) << "OHOSExternalTextureGL show, glGenTextures texture_name_=" + << texture_name_ << ", Id()=" << Id(); + int32_t ret = OH_NativeImage_AttachContext(nativeImage_, texture_name_); + if (ret != 0) { + FML_LOG(ERROR) << "OHOSExternalTextureGL show, AttachContext failed, err code:" << ret; + } + state_ = AttachmentState::attached; + fml::TaskRunner::RunNowOrPostTask( + task_runners_.GetPlatformTaskRunner(), + [this]() { + delegate_.OnPlatformViewMarkTextureFrameAvailable(Id()); + }); + } else { + FML_LOG(ERROR) << "OHOSExternalTextureGL show, MakeCurrent failed"; + return; + } +} + void OHOSExternalTextureGL::OnGrContextCreated() { FML_DLOG(INFO) << " OHOSExternalTextureGL::OnGrContextCreated" << ", texture_name_=" << texture_name_ << ", Id()=" << Id(); - if (state_ == AttachmentState::attached) { - delegate_.OnPlatformViewMarkTextureFrameAvailable(Id()); + fml::TaskRunner::RunNowOrPostTask( + task_runners_.GetRasterTaskRunner(), + [this]() { + Show(); + }); +} + +void OHOSExternalTextureGL::Hide() +{ + if (state_ != AttachmentState::attached) { + FML_LOG(WARNING) << "OHOSExternalTextureGL hide, state is not attached, ignore this call"; + return; + } + if (nativeImage_ != nullptr) { + OH_NativeImage_DetachContext(nativeImage_); + if (texture_name_ != 0) { + glDeleteTextures(1, &texture_name_); + texture_name_ = 0; + } } + if (backGroundNativeWindow_ != nullptr) { + OH_NativeImage_DetachContext(backGroundNativeImage_); + if (backGroundTextureName_ != 0) { + infoMap.erase(backGroundTextureName_); + glDeleteTextures(1, &backGroundTextureName_); + backGroundTextureName_ = 0; + } + } + state_ = AttachmentState::hide; } void OHOSExternalTextureGL::OnGrContextDestroyed() @@ -288,6 +345,11 @@ void OHOSExternalTextureGL::OnGrContextDestroyed() FML_DLOG(INFO) << " OHOSExternalTextureGL::OnGrContextDestroyed" << ", texture_name_=" << texture_name_ << ", Id()=" << Id(); + fml::TaskRunner::RunNowOrPostTask( + task_runners_.GetRasterTaskRunner(), + [this]() { + Hide(); + }); } void OHOSExternalTextureGL::MarkNewFrameAvailable() @@ -313,10 +375,14 @@ void OHOSExternalTextureGL::OnTextureUnregistered() << ", nativeImage_=" << nativeImage_ << ", backGroundNativeImage_=" << backGroundNativeImage_; first_update_ = false; - if (state_ == AttachmentState::attached) { - Detach(); - state_ = AttachmentState::detached; - } + fml::TaskRunner::RunNowOrPostTask( + task_runners_.GetRasterTaskRunner(), + [this]() { + if (state_ == AttachmentState::attached || state_ == AttachmentState::hide) { + Detach(); + state_ = AttachmentState::detached; + } + }); } bool OHOSExternalTextureGL::IsContextCurrent() @@ -343,7 +409,7 @@ bool OHOSExternalTextureGL::IsContextCurrent() void OHOSExternalTextureGL::Update() { FML_DLOG(INFO) << "OHOSExternalTextureGL::Update, texture_name_=" << texture_name_; - if (!IsContextCurrent() && context_) { + if (!IsContextCurrent() && context_ && display_ && draw_surface_ && read_surface_) { if (eglMakeCurrent(display_, draw_surface_, read_surface_, context_) != EGL_TRUE) { FML_LOG(WARNING) << "eglMakeCurrent in update failed"; } @@ -365,38 +431,35 @@ void OHOSExternalTextureGL::Update() void OHOSExternalTextureGL::Detach() { FML_LOG(INFO) << "OHOSExternalTextureGL::Detach, texture_name_=" << texture_name_; - if (state_ != AttachmentState::attached) { - FML_LOG(ERROR) << "OHOSExternalTextureGL::Detach, the current status is not attached"; + if (state_ != AttachmentState::attached && state_ != AttachmentState::hide) { + FML_LOG(ERROR) << "OHOSExternalTextureGL::Detach, the current status is not attached or hide"; return; } if (nativeImage_ != nullptr) { - OH_NativeImage_DetachContext(nativeImage_); + if (state_ == AttachmentState::attached) { + OH_NativeImage_DetachContext(nativeImage_); + } OH_NativeImage_UnsetOnFrameAvailableListener(nativeImage_); OH_NativeImage_Destroy(&nativeImage_); nativeImage_ = nullptr; - } - if (frameData_ != nullptr) { - delete (OhosImageFrameData *)frameData_; - frameData_ = nullptr; - } - if (nativeWindow_ != nullptr) { - OH_NativeWindow_DestroyNativeWindow(nativeWindow_); nativeWindow_ = nullptr; } if (backGroundNativeImage_ != nullptr) { - OH_NativeImage_DetachContext(backGroundNativeImage_); + if (state_ == AttachmentState::attached) { + OH_NativeImage_DetachContext(backGroundNativeImage_); + } OH_NativeImage_Destroy(&backGroundNativeImage_); backGroundNativeImage_ = nullptr; - } - if (backGroundNativeWindow_ != nullptr) { - OH_NativeWindow_DestroyNativeWindow(backGroundNativeWindow_); backGroundNativeWindow_ = nullptr; } - glDeleteTextures(1, &texture_name_); - glDeleteTextures(1, &backGroundTextureName_); - if (backGroundTextureName_ != 0) { - infoMap.erase(backGroundTextureName_); + + if (state_ == AttachmentState::attached) { + glDeleteTextures(1, &texture_name_); + glDeleteTextures(1, &backGroundTextureName_); + if (backGroundTextureName_ != 0) { + infoMap.erase(backGroundTextureName_); + } } } @@ -523,7 +586,7 @@ void OHOSExternalTextureGL::ProduceColorToBackGroundImage(int32_t width, int32_t uint32_t* destAddr = static_cast(mappedAddr); for (int32_t x = 0; x < handle->size / PIXEL_SIZE; x++) { - *destAddr++ = WHITE_COLOR; + *destAddr++ = backGroundColor_; } // munmap after use @@ -608,6 +671,36 @@ void OHOSExternalTextureGL::ProducePixelMapToBackGroundImage() UpdateTransform(backGroundNativeImage_); } +void CopyPixelToHandle(uint32_t *destAddr, uint32_t *pixel, OhosPixelMapInfos pixelMapInfo, BufferHandle *handle) +{ + uint32_t real_height = pixelMapInfo.height; + if (IsPixelMapYUVFormat((PIXEL_FORMAT)pixelMapInfo.pixelFormat)) { + // y is height, uv is height/2 + real_height = pixelMapInfo.height + (pixelMapInfo.height + 1) / 2; + } + + // 复制图片纹理数据到内存中,需要处理DMA内存补齐相关的逻辑 + if (pixelMapInfo.width * PIXEL_SIZE != pixelMapInfo.rowSize) { + // 直接复制整块内存 + if ((real_height * pixelMapInfo.rowSize) > (uint32_t)handle->size) { + memcpy(destAddr, pixel, handle->size); + } else { + memcpy(destAddr, pixel, real_height * pixelMapInfo.rowSize); + } + } else { + // 需要处理DMA内存补齐相关的逻辑 + for (uint32_t i = 0; i < real_height; i++) { + if (pixelMapInfo.rowSize > (uint32_t)handle->stride) { + memcpy(destAddr, pixel, handle->stride); + } else { + memcpy(destAddr, pixel, pixelMapInfo.rowSize); + } + destAddr += handle->stride / PIXEL_SIZE; + pixel += pixelMapInfo.width; + } + } +} + void OHOSExternalTextureGL::HandlePixelMapBuffer(NativePixelMap* pixelMap, OHNativeWindowBuffer* buffer) { BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); @@ -639,24 +732,8 @@ void OHOSExternalTextureGL::HandlePixelMapBuffer(NativePixelMap* pixelMap, OHNat FML_DLOG(INFO) << "OHOSExternalTextureGL pixelMapInfo rowSize:" << pixelMapInfo.rowSize << " format:" << pixelMapInfo.pixelFormat; - uint32_t real_height = pixelMapInfo.height; - if (IsPixelMapYUVFormat((PIXEL_FORMAT)pixelMapInfo.pixelFormat)) { - // y is height, uv is height/2 - real_height = pixelMapInfo.height + (pixelMapInfo.height + 1) / 2; - } + CopyPixelToHandle(destAddr, pixel, pixelMapInfo, handle); - // 复制图片纹理数据到内存中,需要处理DMA内存补齐相关的逻辑 - if (pixelMapInfo.width * PIXEL_SIZE != pixelMapInfo.rowSize) { - // 直接复制整块内存 - memcpy(destAddr, pixel, real_height * pixelMapInfo.rowSize); - } else { - // 需要处理DMA内存补齐相关的逻辑 - for (uint32_t i = 0; i < real_height; i++) { - memcpy(destAddr, pixel, pixelMapInfo.rowSize); - destAddr += stride / PIXEL_SIZE; - pixel += pixelMapInfo.width; - } - } OH_PixelMap_UnAccessPixels(pixelMap); // munmap after use ret = munmap(mappedAddr, handle->size); @@ -770,28 +847,9 @@ void OHOSExternalTextureGL::DispatchBackGroundPixelMap(NativePixelMap* pixelMap) } } -OhosImageFrameData::OhosImageFrameData( - OHOSExternalTextureGL *ohosExternalTextureGL, - int64_t textureId) - : ohosExternalTextureGL(ohosExternalTextureGL), - textureId_(textureId) -{} - -OhosImageFrameData::~OhosImageFrameData() -{ - ohosExternalTextureGL = nullptr; - textureId_ = 0; -} - -void OhosImageFrameData::OnPlatformViewMarkTextureFrameAvailable() +void OHOSExternalTextureGL::DispatchBackGroundColor(uint32_t color) { - if (ohosExternalTextureGL != nullptr) { - fml::TaskRunner::RunNowOrPostTask( - ohosExternalTextureGL->task_runners_.GetPlatformTaskRunner(), [textureId = textureId_, this]() { - PlatformView::Delegate& dalegate = this->ohosExternalTextureGL->delegate_; - dalegate.OnPlatformViewMarkTextureFrameAvailable(textureId); - }); - } + backGroundColor_ = color; } } // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 24beb3279de48788e6d3b945b06c0caa96859db1..e30c52e820d5feee5d50ac20f9f18ec54dd7fa6d 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef OHOS_EXTERNAL_TEXTURE_GL_H @@ -36,7 +27,8 @@ // maybe now unused namespace flutter { -class OHOSExternalTextureGL : public flutter::Texture { +// Represents an external texture for OHOS platform, using std::weak_ptr to avoid circular reference. +class OHOSExternalTextureGL : public flutter::Texture, public std::enable_shared_from_this { public: explicit OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface); explicit OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface, @@ -52,8 +44,6 @@ class OHOSExternalTextureGL : public flutter::Texture { OH_NativeImage *backGroundNativeImage_; - void *frameData_; - bool first_update_ = false; void Paint(PaintContext& context, @@ -81,6 +71,8 @@ class OHOSExternalTextureGL : public flutter::Texture { void DispatchBackGroundPixelMap(NativePixelMap* pixelMap); + void DispatchBackGroundColor(uint32_t color); + private: void Attach(); @@ -88,6 +80,10 @@ class OHOSExternalTextureGL : public flutter::Texture { void Detach(); + void Hide(); + + void Show(); + void UpdateTransform(OH_NativeImage *image); EGLDisplay GetPlatformEglDisplay(EGLenum platform, void *native_display, const EGLint *attrib_list); @@ -102,7 +98,7 @@ class OHOSExternalTextureGL : public flutter::Texture { void ProducePixelMapToBackGroundImage(); - enum class AttachmentState { uninitialized, attached, detached }; + enum class AttachmentState { uninitialized, attached, detached, hide }; AttachmentState state_; @@ -120,6 +116,8 @@ class OHOSExternalTextureGL : public flutter::Texture { NativePixelMap* backGroundPixelMap_; + uint32_t backGroundColor_ = 0xFFFFFFFF; // white color + NativePixelMap* pixelMap_; ImageNative* lastImage_; @@ -145,22 +143,5 @@ class OHOSExternalTextureGL : public flutter::Texture { bool IsContextCurrent(); }; -class OhosImageFrameData { - public: - OhosImageFrameData(OHOSExternalTextureGL *ohosExternalTextureGL, int64_t textureId); - - OhosImageFrameData() = delete; - - ~OhosImageFrameData(); - - void OnPlatformViewMarkTextureFrameAvailable(); - - private: - - OHOSExternalTextureGL *ohosExternalTextureGL; - - int64_t textureId_; -}; - } // namespace flutter #endif \ No newline at end of file diff --git a/shell/platform/ohos/ohos_image_generator.cpp b/shell/platform/ohos/ohos_image_generator.cpp index 2256ca2a237876f7312f5557eb6bd13843533b10..c00ffd88b354b6e07f4bfe2f04644ca3cbb8a59e 100755 --- a/shell/platform/ohos/ohos_image_generator.cpp +++ b/shell/platform/ohos/ohos_image_generator.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "ohos_image_generator.h" diff --git a/shell/platform/ohos/ohos_image_generator.h b/shell/platform/ohos/ohos_image_generator.h index 74b38a70806437a81b6a34d0f435f27aed76b97b..cd677e20cc2e7658a765f400a0e87fb6f8605565 100755 --- a/shell/platform/ohos/ohos_image_generator.h +++ b/shell/platform/ohos/ohos_image_generator.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef FLUTTER_IMAGE_GENERATOR_H @@ -45,23 +36,17 @@ class OHOSImageGenerator : public ImageGenerator { ~OHOSImageGenerator(); - // |ImageGenerator| const SkImageInfo& GetInfo() override; - // |ImageGenerator| unsigned int GetFrameCount() const override; - // |ImageGenerator| unsigned int GetPlayCount() const override; - // |ImageGenerator| const ImageGenerator::FrameInfo GetFrameInfo( unsigned int frame_index) const override; - // |ImageGenerator| SkISize GetScaledDimensions(float desired_scale) override; - // |ImageGenerator| bool GetPixels(const SkImageInfo& info, void* pixels, size_t row_bytes, diff --git a/shell/platform/ohos/ohos_logger.c b/shell/platform/ohos/ohos_logger.c index 95d0446d0e580112fe366cd8e87741d933539f30..294cbedc55026e319f3af88357d510290431a9a0 100644 --- a/shell/platform/ohos/ohos_logger.c +++ b/shell/platform/ohos/ohos_logger.c @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #include "ohos_logger.h" diff --git a/shell/platform/ohos/ohos_logger.h b/shell/platform/ohos/ohos_logger.h index da4bd255817d551bd9db9c74962a7a0d5195d803..b5bc191a590bc2532415705c740383f02da9acde 100644 --- a/shell/platform/ohos/ohos_logger.h +++ b/shell/platform/ohos/ohos_logger.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #ifndef __OHOS__LOGGER_H diff --git a/shell/platform/ohos/ohos_logging.h b/shell/platform/ohos/ohos_logging.h index d1d275f04a939b99fb890f679828ddc7b03a978e..85c817e636e661986d9175ce0e21105c82cb9a6a 100644 --- a/shell/platform/ohos/ohos_logging.h +++ b/shell/platform/ohos/ohos_logging.h @@ -1,16 +1,7 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #ifndef OHOS_LOGGING_H diff --git a/shell/platform/ohos/ohos_main.cpp b/shell/platform/ohos/ohos_main.cpp index 6e5553f5cf1570f14a7d103da5bddbee7bc90c5a..492e9b48c1f100d3f459e3ae58d16b1b8173ad2e 100644 --- a/shell/platform/ohos/ohos_main.cpp +++ b/shell/platform/ohos/ohos_main.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/shell/platform/ohos/ohos_main.h" diff --git a/shell/platform/ohos/ohos_main.h b/shell/platform/ohos/ohos_main.h index 3e8f7355977a4a51e4894bd076741a9dd8fa877b..f548a141678369ec8da910b7d63d0bb9eee92258 100644 --- a/shell/platform/ohos/ohos_main.h +++ b/shell/platform/ohos/ohos_main.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef __OHOS__MAIN__H diff --git a/shell/platform/ohos/ohos_shell_holder.cpp b/shell/platform/ohos/ohos_shell_holder.cpp index 2cb763fc04889ce0342e708451dc485f04bfc023..35970f42a18b4dd27d227f3c636abe8d378b8a63 100644 --- a/shell/platform/ohos/ohos_shell_holder.cpp +++ b/shell/platform/ohos/ohos_shell_holder.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/ohos_shell_holder.h" @@ -94,7 +86,7 @@ OHOSShellHolder::OHOSShellHolder( Shell::CreateCallback on_create_platform_view = [&napi_facade, &weak_platform_view](Shell& shell) { - FML_DLOG(INFO) << "on_create_platform_view"; + FML_LOG(INFO) << "on_create_platform_view"; std::unique_ptr platform_view_OHOS; platform_view_OHOS = std::make_unique( shell, // delegate @@ -104,19 +96,8 @@ OHOSShellHolder::OHOSShellHolder( .enable_software_rendering, // use software rendering shell.GetSettings().msaa_samples // msaa sample count ); - LOGI("on_create_platform_view LOGI"); - FML_LOG(INFO) << "on_create_platform_view end"; weak_platform_view = platform_view_OHOS->GetWeakPtr(); - LOGI("on_create_platform_view LOGI2"); - FML_LOG(INFO) << "on_create_platform_view end1"; - std::vector> displays; - displays.push_back(std::make_unique(napi_facade)); - FML_DLOG(INFO) << "on_create_platform_view LOGI3"; - FML_LOG(INFO) << "on_create_platform_view end3"; - shell.OnDisplayUpdates(DisplayUpdateType::kStartup, - std::move(displays)); - LOGI("on_create_platform_view LOGI4"); - FML_LOG(INFO) << "on_create_platform_view end3"; + FML_LOG(INFO) << "on_create_platform_view end"; return platform_view_OHOS; }; @@ -155,6 +136,13 @@ OHOSShellHolder::OHOSShellHolder( ); FML_DLOG(INFO) << "shell create end"; if (shell_) { + // For getting the RefreshRate of display + std::vector> displays; + auto vsync_waiter = std::shared_ptr(shell_->GetVsyncWaiter().lock()); + auto vsync_waiter_ohos = std::static_pointer_cast(vsync_waiter); + displays.push_back(std::make_unique(vsync_waiter_ohos)); + shell_->OnDisplayUpdates(DisplayUpdateType::kStartup, std::move(displays)); + shell_->GetDartVM()->GetConcurrentMessageLoop()->PostTaskToAllWorkers([]() { if (::setpriority(PRIO_PROCESS, gettid(), 1) != 0) { FML_DLOG(ERROR) << "Failed to set Workers task runner priority"; diff --git a/shell/platform/ohos/ohos_shell_holder.h b/shell/platform/ohos/ohos_shell_holder.h index 4a87730862c4ded233a6f08ace2154ae3eba29cb..1fadd18a3d7d7ea05b7eb09c5412b7a1022a8d3c 100644 --- a/shell/platform/ohos/ohos_shell_holder.h +++ b/shell/platform/ohos/ohos_shell_holder.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef OHOS_SHELL_HOLDER_H @@ -68,6 +60,10 @@ class OHOSShellHolder { return shell_->GetPlatformMessageHandler(); } + const std::weak_ptr GetVsyncWaiter() const { + return shell_->GetVsyncWaiter(); + } + private: std::optional BuildRunConfiguration( const std::string& entrypoint, diff --git a/shell/platform/ohos/ohos_surface_gl_impeller.cpp b/shell/platform/ohos/ohos_surface_gl_impeller.cpp index b50e8c8d7b6e812216114ea2e2af98041967a319..1363ef19c1f20fc89b988d99a4c9713230cc7870 100755 --- a/shell/platform/ohos/ohos_surface_gl_impeller.cpp +++ b/shell/platform/ohos/ohos_surface_gl_impeller.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "ohos_surface_gl_impeller.h" diff --git a/shell/platform/ohos/ohos_surface_gl_impeller.h b/shell/platform/ohos/ohos_surface_gl_impeller.h index 87b2fa4bf601f51700c3c24c6829518f035cbec4..0fee28fc818ac41792125aedae88f799ee69f119 100755 --- a/shell/platform/ohos/ohos_surface_gl_impeller.h +++ b/shell/platform/ohos/ohos_surface_gl_impeller.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef OHOS_SURFACE_GL_IMPELLER_H diff --git a/shell/platform/ohos/ohos_surface_gl_skia.cpp b/shell/platform/ohos/ohos_surface_gl_skia.cpp index 6c8d5ea57ee03d74f5e9e83a3ed37020544439d5..729817992539dc4ecc6c57fd0746d2c74aa69fd6 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.cpp +++ b/shell/platform/ohos/ohos_surface_gl_skia.cpp @@ -1,18 +1,11 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/ohos_surface_gl_skia.h" #include @@ -47,10 +40,7 @@ OhosSurfaceGLSkia::OhosSurfaceGLSkia( FML_LOG(INFO) << "OhosSurfaceGLSkia constructor end"; } -OhosSurfaceGLSkia::~OhosSurfaceGLSkia() { - eglMakeCurrent(eglGetCurrentDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT); -} +OhosSurfaceGLSkia::~OhosSurfaceGLSkia() = default; void OhosSurfaceGLSkia::TeardownOnScreenContext() { // When the onscreen surface is destroyed, the context and the surface diff --git a/shell/platform/ohos/ohos_surface_gl_skia.h b/shell/platform/ohos/ohos_surface_gl_skia.h index 4a99529433248f7f0a6677120d5e5b61cb896c66..50a90c713df8e98a9ddcf27544980c27788a92ba 100755 --- a/shell/platform/ohos/ohos_surface_gl_skia.h +++ b/shell/platform/ohos/ohos_surface_gl_skia.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef OHOS_SURFACE_GL_SKIA_H diff --git a/shell/platform/ohos/ohos_surface_software.cpp b/shell/platform/ohos/ohos_surface_software.cpp index 5a3fb5ca3e1f367a0e87294015e09a0854e88ce5..3d1f7611928762ab316b7af51ac4c9f4691a4fc2 100644 --- a/shell/platform/ohos/ohos_surface_software.cpp +++ b/shell/platform/ohos/ohos_surface_software.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/shell/platform/ohos/ohos_surface_software.h" diff --git a/shell/platform/ohos/ohos_surface_software.h b/shell/platform/ohos/ohos_surface_software.h index a0dfd8ae0044bac6d03d3b523453a3c91beae9aa..1aafcbc98c668809bfa12ce9a9638a775d551443 100644 --- a/shell/platform/ohos/ohos_surface_software.h +++ b/shell/platform/ohos/ohos_surface_software.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ #ifndef OHOS_SURFACE_SOFTWARE_H diff --git a/shell/platform/ohos/ohos_surface_vulkan_impeller.cpp b/shell/platform/ohos/ohos_surface_vulkan_impeller.cpp index 3e6a3937fc39c33d7ec8526253fb0b7dc7883f1e..e3cca9670fca0ba097f64ec3d3368f81b8ef8a31 100755 --- a/shell/platform/ohos/ohos_surface_vulkan_impeller.cpp +++ b/shell/platform/ohos/ohos_surface_vulkan_impeller.cpp @@ -1,18 +1,11 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "ohos_surface_vulkan_impeller.h" #include diff --git a/shell/platform/ohos/ohos_surface_vulkan_impeller.h b/shell/platform/ohos/ohos_surface_vulkan_impeller.h index b5bbb42e7a123c0804503a450906210f26edfdee..f7df35895658b60230bbe80e5ee4746cd83569a8 100755 --- a/shell/platform/ohos/ohos_surface_vulkan_impeller.h +++ b/shell/platform/ohos/ohos_surface_vulkan_impeller.h @@ -1,18 +1,11 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ + #ifndef OHOS_SURFACE_VULKAN_IMPELLER_H #define OHOS_SURFACE_VULKAN_IMPELLER_H diff --git a/shell/platform/ohos/ohos_touch_processor.cpp b/shell/platform/ohos/ohos_touch_processor.cpp index 32d2ed1ef8d0f420c4c0af25ca01194e299d1923..72d08a1b8862ab4fa1b001edb595e8a74113412e 100644 --- a/shell/platform/ohos/ohos_touch_processor.cpp +++ b/shell/platform/ohos/ohos_touch_processor.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #include "flutter/shell/platform/ohos/ohos_touch_processor.h" @@ -179,11 +170,9 @@ void OhosTouchProcessor::HandleTouchEvent( OH_NativeXComponent_TouchPointToolType toolType; OH_NativeXComponent_GetTouchPointToolType(component, 0, &toolType); pointerData.kind = getPointerDeviceTypeForToolType(toolType); - if (pointerData.kind == PointerData::DeviceKind::kTouch) { - if (pointerData.change == PointerData::Change::kDown || - pointerData.change == PointerData::Change::kMove) { - pointerData.buttons = kPointerButtonTouchContact; - } + if (pointerData.change == PointerData::Change::kDown || + pointerData.change == PointerData::Change::kMove) { + pointerData.buttons = kPointerButtonTouchContact; } pointerData.pan_x = 0.0; pointerData.pan_y = 0.0; @@ -261,7 +250,7 @@ void OhosTouchProcessor::HandleMouseEvent( pointerData.pressure = 0.0; pointerData.pressure_max = 1.0; pointerData.pressure_min = 0.0; - pointerData.kind = PointerData::DeviceKind::kTouch; + pointerData.kind = PointerData::DeviceKind::kMouse; // kMouse支持鼠标框选文字 pointerData.buttons = getPointerButtonFromMouse(mouseEvent.button); // hover support if (mouseEvent.button == OH_NATIVEXCOMPONENT_NONE_BUTTON && pointerData.change == PointerData::Change::kMove) { diff --git a/shell/platform/ohos/ohos_touch_processor.h b/shell/platform/ohos/ohos_touch_processor.h index 892bd672939a038bb718bb7e17b87afb10f9f61a..fb4494a1ea68104709755de604ffc1df745cf5d3 100644 --- a/shell/platform/ohos/ohos_touch_processor.h +++ b/shell/platform/ohos/ohos_touch_processor.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #ifndef OHOS_TOUCH_PROCESSOR_H diff --git a/shell/platform/ohos/ohos_unified_surface.cpp b/shell/platform/ohos/ohos_unified_surface.cpp index 73c3a0c954d6b7f9ee95af2336d8e7b4f37284bb..46ac41fd96a5d5faf71619a4a60b572013e816d5 100644 --- a/shell/platform/ohos/ohos_unified_surface.cpp +++ b/shell/platform/ohos/ohos_unified_surface.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #include "flutter/shell/platform/ohos/ohos_unified_surface.h" diff --git a/shell/platform/ohos/ohos_unified_surface.h b/shell/platform/ohos/ohos_unified_surface.h index 591ba0dddfc5c9e80c6c6d811626a0d82e19fcc8..1234ff13981fd08eeeafb562086a295079c072be 100644 --- a/shell/platform/ohos/ohos_unified_surface.h +++ b/shell/platform/ohos/ohos_unified_surface.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #ifndef OHOS_UNIFIED_SURFACE_H diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index e9a0e82d033a8de6ec55b9df7f5a3142f49311ba..f9ef00ee506479c5e598858fd9dc193807da87e7 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #include "ohos_xcomponent_adapter.h" @@ -18,6 +9,7 @@ #include "types.h" #include "ohos_logging.h" #include +#include "flutter/fml/logging.h" namespace flutter { @@ -194,12 +186,15 @@ void OnSurfaceChangedCB(OH_NativeXComponent* component, void* window) { } void OnSurfaceDestroyedCB(OH_NativeXComponent* component, void* window) { + std::lock_guard lock(XComponentAdapter::GetInstance()->mutex_); for(auto it = XComponentAdapter::GetInstance()->xcomponetMap_.begin(); it != XComponentAdapter::GetInstance()->xcomponetMap_.end();) { if(it->second->nativeXComponent_ == component) { it->second->OnSurfaceDestroyed(component, window); delete it->second; + // 将当前要销毁的xcomponent对应的无障碍provider指针置nullptr + it->second->accessibilityProvider_ = nullptr; it = XComponentAdapter::GetInstance()->xcomponetMap_.erase(it); } else { ++it; @@ -247,9 +242,8 @@ int32_t FindAccessibilityNodeInfosById( int32_t requestId, ArkUI_AccessibilityElementInfoList* elementList) { - auto ohosAccessibilityBridge = OhosAccessibilityBridge::GetInstance(); - ohosAccessibilityBridge->FindAccessibilityNodeInfosById(elementId, mode, requestId, elementList); - LOGD("accessibilityProviderCallback_.FindAccessibilityNodeInfosById"); + OhosAccessibilityBridge::GetInstance()->FindAccessibilityNodeInfosById(elementId, mode, requestId, elementList); + FML_DLOG(INFO) << "accessibilityProviderCallback_.FindAccessibilityNodeInfosById"; return 0; } @@ -260,8 +254,7 @@ int32_t FindAccessibilityNodeInfosByText( int32_t requestId, ArkUI_AccessibilityElementInfoList* elementList) { - auto ohosAccessibilityBridge = OhosAccessibilityBridge::GetInstance(); - ohosAccessibilityBridge->FindAccessibilityNodeInfosByText(elementId, text, requestId, elementList); + OhosAccessibilityBridge::GetInstance()->FindAccessibilityNodeInfosByText(elementId, text, requestId, elementList); LOGD("accessibilityProviderCallback_.FindAccessibilityNodeInfosByText"); return 0; } @@ -273,8 +266,7 @@ int32_t FindFocusedAccessibilityNode( int32_t requestId, ArkUI_AccessibilityElementInfo* elementinfo) { - auto ohosAccessibilityBridge = OhosAccessibilityBridge::GetInstance(); - ohosAccessibilityBridge->FindFocusedAccessibilityNode(elementId, focusType, requestId, elementinfo); + OhosAccessibilityBridge::GetInstance()->FindFocusedAccessibilityNode(elementId, focusType, requestId, elementinfo); LOGD("accessibilityProviderCallback_.FindFocusedAccessibilityNode"); return 0; } @@ -286,8 +278,7 @@ int32_t FindNextFocusAccessibilityNode( int32_t requestId, ArkUI_AccessibilityElementInfo *elementList) { - auto ohosAccessibilityBridge = OhosAccessibilityBridge::GetInstance(); - ohosAccessibilityBridge->FindNextFocusAccessibilityNode(elementId, direction, requestId, elementList); + OhosAccessibilityBridge::GetInstance()->FindNextFocusAccessibilityNode(elementId, direction, requestId, elementList); LOGD("accessibilityProviderCallback_.FindNextFocusAccessibilityNode"); return 0; } @@ -299,8 +290,7 @@ int32_t ExecuteAccessibilityAction( ArkUI_AccessibilityActionArguments* actionArguments, int32_t requestId) { - auto ohosAccessibilityBridge = OhosAccessibilityBridge::GetInstance(); - ohosAccessibilityBridge->ExecuteAccessibilityAction(elementId, action, actionArguments, requestId); + OhosAccessibilityBridge::GetInstance()->ExecuteAccessibilityAction(elementId, action, actionArguments, requestId); LOGD("accessibilityProviderCallback_.ExecuteAccessibilityAction"); return 0; } @@ -318,8 +308,7 @@ int32_t GetAccessibilityNodeCursorPosition( int32_t requestId, int32_t* index) { - auto ohosAccessibilityBridge = OhosAccessibilityBridge::GetInstance(); - ohosAccessibilityBridge->GetAccessibilityNodeCursorPosition(elementId, requestId, index); + OhosAccessibilityBridge::GetInstance()->GetAccessibilityNodeCursorPosition(elementId, requestId, index); LOGD("accessibilityProviderCallback_.GetAccessibilityNodeCursorPosition"); return 0; } @@ -369,47 +358,54 @@ void XComponentBase::DetachFlutterEngine() { isEngineAttached_ = false; } +ArkUI_AccessibilityProvider* XComponentAdapter::GetAccessibilityProvider(const std::string& xcompId) +{ + auto it = xcomponetMap_.find(xcompId); + if (it != xcomponetMap_.end()) { + return it->second->accessibilityProvider_; + } else { + return nullptr; + } +} + +void XComponentBase::RegisterArkUIAccessibilityService(OH_NativeXComponent* nativeXComponent) +{ + BindAccessibilityProviderCallback(); + + auto OH_NativeXComponent_GetNativeAccessibilityProvider = + OhosAccessibilityDDL::DLLoadGetNativeA11yProvider(ArkUIAccessibilityConstant::OH_GET_A11Y_PROVIDER); + CHECK_DLL_NULL_PTR(OH_NativeXComponent_GetNativeAccessibilityProvider); + + ArkUI_AccessibilityProvider* a11yProvider = nullptr; + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_NativeXComponent_GetNativeAccessibilityProvider(nativeXComponent, &a11yProvider) + ); + + auto OH_ArkUI_AccessibilityProviderRegisterCallback = + OhosAccessibilityDDL::DLLoadRegisterFunc(ArkUIAccessibilityConstant::ARKUI_REGISTER_CALLBACK); + CHECK_DLL_NULL_PTR(OH_ArkUI_AccessibilityProviderRegisterCallback); + CHECK_NULL_PTR(a11yProvider, RegisterArkUIAccessibilityService); + ARKUI_ACCESSIBILITY_CALL_CHECK( + OH_ArkUI_AccessibilityProviderRegisterCallback(a11yProvider, &accessibilityProviderCallback_) + ); + + std::lock_guard lock(XComponentAdapter::GetInstance()->mutex_); + auto* base = XComponentAdapter::GetInstance()->xcomponetMap_[id_]; + base->accessibilityProvider_ = a11yProvider; + base->nativeXComponent_ = nativeXComponent; + + FML_DLOG(INFO) << "RegisterArkUIAccessibilityService is finished"; +} + void XComponentBase::SetNativeXComponent(OH_NativeXComponent* nativeXComponent){ nativeXComponent_ = nativeXComponent; if (nativeXComponent_ != nullptr) { BindXComponentCallback(); OH_NativeXComponent_RegisterCallback(nativeXComponent_, &callback_); OH_NativeXComponent_RegisterMouseEventCallback(nativeXComponent_, &mouseCallback_); - - if (OH_GetSdkApiVersion() >= 13) { - LOGD("api version: %{public}d", OH_GetSdkApiVersion()); - BindAccessibilityProviderCallback(); - - int32_t (*OH_NativeXComponent_GetNativeAccessibilityProvider)(OH_NativeXComponent*, ArkUI_AccessibilityProvider**) = - OhosAccessibilityDDL::DLLoadGetNativeA11yProvider("OH_NativeXComponent_GetNativeAccessibilityProvider"); - if (OH_NativeXComponent_GetNativeAccessibilityProvider == nullptr) { - LOGE("OH_NativeXComponent_GetNativeAccessibilityProvider is null, %{public}s", dlerror()); - } - ArkUI_AccessibilityProvider* accessibilityProvider = nullptr; - int32_t ret1 = OH_NativeXComponent_GetNativeAccessibilityProvider(nativeXComponent_, &accessibilityProvider); - if (ret1 != 0) { - LOGE("OH_NativeXComponent_GetNativeAccessibilityProvider is failed"); - return; - } - - int32_t (*OH_ArkUI_AccessibilityProviderRegisterCallback)(ArkUI_AccessibilityProvider*, ArkUI_AccessibilityProviderCallbacks*) = - OhosAccessibilityDDL::DLLoadRegisterFunc("OH_ArkUI_AccessibilityProviderRegisterCallback"); - if (OH_ArkUI_AccessibilityProviderRegisterCallback == nullptr) { - LOGE("OH_ArkUI_AccessibilityProviderRegisterCallback is null, %{public}s", dlerror()); - } - int32_t ret2 = OH_ArkUI_AccessibilityProviderRegisterCallback(accessibilityProvider, &accessibilityProviderCallback_); - if (ret2 != 0) { - LOGE("OH_ArkUI_AccessibilityProviderRegisterCallback is failed"); - return; - } - LOGE("OH_ArkUI_AccessibilityProviderRegisterCallback is %{public}d", ret2); - - //将ArkUI_AccessibilityProvider传到无障碍bridge类 - auto ohosAccessibilityBridge = OhosAccessibilityBridge::GetInstance(); - ohosAccessibilityBridge->provider_ = accessibilityProvider; - - LOGI("XComponentBase::SetNativeXComponent OH_ArkUI_AccessibilityProviderRegisterCallback is succeed"); - } + // register the OH_ArkUI accessibility callbacks + if (OH_GetSdkApiVersion() < 13) { return; } + RegisterArkUIAccessibilityService(nativeXComponent_); } } @@ -532,7 +528,8 @@ void XComponentBase::OnDispatchMouseWheelEvent(mouseWheelEvent event) } if (event.eventType == "actionUpdate") { OH_NativeXComponent_MouseEvent mouseEvent; - double scrollY = event.offsetY - g_scrollDistance; + // 调整鼠标滚轮滚动时,列表滑动的方向。和Windows保持一致。 + double scrollY = g_scrollDistance - event.offsetY; g_scrollDistance = event.offsetY; // fix resize ratio mouseEvent.x = event.globalX / g_resizeRate; diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.h b/shell/platform/ohos/ohos_xcomponent_adapter.h index d2c14146134bffd6d364ddf3e8a57f8326fba305..c2b0b70aad7eec2facd183211cdbe2e0fb31ff05 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.h +++ b/shell/platform/ohos/ohos_xcomponent_adapter.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #ifndef OHOS_XCOMPONENT_ADAPTER_H @@ -20,12 +11,13 @@ #include #include #include +#include #include "flutter/shell/platform/ohos/ohos_touch_processor.h" #include "flutter/shell/platform/ohos/napi/platform_view_ohos_napi.h" #include "napi/native_api.h" #include "napi_common.h" #include "flutter/shell/platform/ohos/accessibility/ohos_accessibility_bridge.h" - +#include "flutter/shell/platform/ohos/utils/ddl_utils.h" namespace flutter { class XComponentBase @@ -50,6 +42,9 @@ public: void OnDispatchMouseEvent(OH_NativeXComponent* component, void* window); void OnDispatchMouseWheelEvent(mouseWheelEvent event); + void RegisterArkUIAccessibilityService( + OH_NativeXComponent* nativeXComponent); + OH_NativeXComponent_TouchEvent touchEvent_; OH_NativeXComponent_Callback callback_; OH_NativeXComponent_MouseEvent_Callback mouseCallback_; @@ -64,7 +59,7 @@ public: uint64_t width_; uint64_t height_; OhosTouchProcessor ohosTouchProcessor_; - + ArkUI_AccessibilityProvider* accessibilityProvider_; }; class XComponentAdapter { @@ -79,8 +74,12 @@ class XComponentAdapter { void DetachFlutterEngine(std::string& id); void OnMouseWheel(std::string& id, mouseWheelEvent event); + ArkUI_AccessibilityProvider* GetAccessibilityProvider(const std::string& xcompId); + public: std::map xcomponetMap_; + std::string currentXComponentId_; + std::mutex mutex_; private: static XComponentAdapter mXComponentAdapter; diff --git a/shell/platform/ohos/platform_message_handler_ohos.cpp b/shell/platform/ohos/platform_message_handler_ohos.cpp index 111334f721368bebc5bea4aed8d4b0f4392790f6..3e6b8b3d8ec29c620bd7b6ce4f382008948878be 100644 --- a/shell/platform/ohos/platform_message_handler_ohos.cpp +++ b/shell/platform/ohos/platform_message_handler_ohos.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #include "flutter/shell/platform/ohos/platform_message_handler_ohos.h" diff --git a/shell/platform/ohos/platform_message_handler_ohos.h b/shell/platform/ohos/platform_message_handler_ohos.h index 5536f269015b8f3dfe29b88ccc1c09d628a96f67..6670793b52dd9ca3f3edbc882927ae741aad8880 100644 --- a/shell/platform/ohos/platform_message_handler_ohos.h +++ b/shell/platform/ohos/platform_message_handler_ohos.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 PLATFORM_MESSAGE_HANDLER_OHOS_H diff --git a/shell/platform/ohos/platform_message_response_ohos.cpp b/shell/platform/ohos/platform_message_response_ohos.cpp index 75954cd0aceffc90a03028c4963b67f23e4d33bd..f663f53b6d2e1b867f6d9d8f58e9513a7a53c160 100644 --- a/shell/platform/ohos/platform_message_response_ohos.cpp +++ b/shell/platform/ohos/platform_message_response_ohos.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/platform_message_response_ohos.h" diff --git a/shell/platform/ohos/platform_message_response_ohos.h b/shell/platform/ohos/platform_message_response_ohos.h index eaf144f10cb5080f3eddc73b74dea47f1c542567..b113f4ac224ba6dfef6361888e40c90b95f07ebf 100644 --- a/shell/platform/ohos/platform_message_response_ohos.h +++ b/shell/platform/ohos/platform_message_response_ohos.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 PLATFORM_MESSAGE_REPONSE_OHOS_H @@ -27,10 +19,9 @@ namespace flutter { class PlatformMessageResponseOHOS : public flutter::PlatformMessageResponse { public: - // |flutter::PlatformMessageResponse| + void Complete(std::unique_ptr data) override; - // |flutter::PlatformMessageResponse| void CompleteEmpty() override; private: diff --git a/shell/platform/ohos/platform_view_ohos.cpp b/shell/platform/ohos/platform_view_ohos.cpp index b1aca3a69c025b1c28c7870d49ea4e43f4af1521..d164be8830d1d3c8d7884bb3ce8df125b3738c06 100644 --- a/shell/platform/ohos/platform_view_ohos.cpp +++ b/shell/platform/ohos/platform_view_ohos.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/shell/platform/ohos/platform_view_ohos.h" @@ -27,6 +18,7 @@ #include "flutter/shell/platform/ohos/platform_view_ohos_delegate.h" #include + namespace flutter { OhosSurfaceFactoryImpl::OhosSurfaceFactoryImpl( @@ -117,15 +109,16 @@ PlatformViewOHOS::PlatformViewOHOS( PlatformViewOHOS::~PlatformViewOHOS() { FML_LOG(INFO) << "PlatformViewOHOS::~PlatformViewOHOS"; - for (std::map>::iterator it = external_texture_gl_.begin(); - it != external_texture_gl_.end(); ++it) { - if (it->second != nullptr) { - OH_NativeImage_Destroy(&(it->second->nativeImage_)); - it->second->nativeImage_ = nullptr; + for (auto const &it : external_texture_gl_) { + if (it.second != nullptr) { + FML_LOG(INFO) << " nativeImage of textureId " << it.first << " will destroy"; + if (it.second->nativeImage_ != nullptr) { + OH_NativeImage_Destroy(&(it.second->nativeImage_)); + it.second->nativeImage_ = nullptr; + } } } external_texture_gl_.clear(); - FML_LOG(INFO) << "PlatformViewOHOS::~PlatformViewOHOS finish"; } void PlatformViewOHOS::NotifyCreate( @@ -176,21 +169,10 @@ void PlatformViewOHOS::NotifySurfaceWindowChanged( } void PlatformViewOHOS::NotifyChanged(const SkISize& size) { - LOGI("PlatformViewOHOS NotifyChanged enter"); - if (ohos_surface_) { - fml::AutoResetWaitableEvent latch; - fml::TaskRunner::RunNowOrPostTask( - task_runners_.GetRasterTaskRunner(), // - [&latch, surface = ohos_surface_.get(), size, this]() { - if (GetDestroyed()) { - LOGW("NotifyChanged, GetDestroyed is true, ignore this call."); - } else { - surface->OnScreenSurfaceResize(size); - } - latch.Signal(); - }); - latch.Wait(); - } + //Do nothing, because SetViewportMetrics has notified window size change event + //If raster thread post task, Synchronization signal block application main thread + //(https://gitee.com/openharmony-sig/flutter_engine/issues/IBI4PK?from=project-issue) + return; } bool PlatformViewOHOS::GetDestroyed() { @@ -296,9 +278,9 @@ void PlatformViewOHOS::UpdateAssetResolverByType( void PlatformViewOHOS::UpdateSemantics( flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) { - FML_DLOG(INFO) << "PlatformViewOHOS::UpdateSemantics is called"; - auto nativeAccessibilityChannel_ = std::make_shared(); - nativeAccessibilityChannel_->UpdateSemantics(update, actions); + FML_DLOG(INFO) << "PlatformViewOHOS::UpdateSemantics()"; + auto nativeAccessibilityChannel_ = std::make_shared(); + nativeAccessibilityChannel_->UpdateSemantics(update, actions); } // |PlatformView| @@ -524,6 +506,17 @@ void PlatformViewOHOS::SetExternalTextureBackGroundPixelMap( } } +void PlatformViewOHOS::SetExternalTextureBackGroundColor( + int64_t texture_id, + uint32_t color) { + if (ohos_context_->RenderingApi() == OHOSRenderingAPI::kOpenGLES) { + auto iter = external_texture_gl_.find(texture_id); + if (iter != external_texture_gl_.end()) { + iter->second->DispatchBackGroundColor(color); + } + } +} + void PlatformViewOHOS::OnTouchEvent( const std::shared_ptr touchPacketString, int size) { diff --git a/shell/platform/ohos/platform_view_ohos.h b/shell/platform/ohos/platform_view_ohos.h index c6dd57ccfb4241e6d16a568f0f2c08d3c2e1a81a..75e49c12c4e3ffdab6ece07c84666205eb4b7da2 100644 --- a/shell/platform/ohos/platform_view_ohos.h +++ b/shell/platform/ohos/platform_view_ohos.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef OHOS_PLATFORM_VIEW_H @@ -109,22 +100,23 @@ class PlatformViewOHOS final : public PlatformView { void SetExternalTextureBackGroundPixelMap(int64_t texture_id, NativePixelMap* pixelMap); + void SetExternalTextureBackGroundColor(int64_t texture_id, uint32_t color); + void UnRegisterExternalTexture(int64_t texture_id); // |PlatformView| PointerDataDispatcherMaker GetDispatcherMaker() override; - // |PlatformView| void LoadDartDeferredLibrary( intptr_t loading_unit_id, std::unique_ptr snapshot_data, std::unique_ptr snapshot_instructions) override; + // |PlatformView| void LoadDartDeferredLibraryError(intptr_t loading_unit_id, const std::string error_message, bool transient) override; - // |PlatformView| void UpdateAssetResolverByType( std::unique_ptr updated_asset_resolver, AssetResolver::AssetResolverType type) override; @@ -161,45 +153,33 @@ class PlatformViewOHOS final : public PlatformView { void SetDestroyed(bool isDestroyed_); - // |PlatformView| void UpdateSemantics( flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) override; - // |PlatformView| void HandlePlatformMessage( std::unique_ptr message) override; - // |PlatformView| void OnPreEngineRestart() const override; - // |PlatformView| std::unique_ptr CreateVSyncWaiter() override; - // |PlatformView| std::unique_ptr CreateRenderingSurface() override; - // |PlatformView| std::shared_ptr CreateExternalViewEmbedder() override; - // |PlatformView| std::unique_ptr CreateSnapshotSurfaceProducer() override; - // |PlatformView| sk_sp CreateResourceContext() const override; - // |PlatformView| void ReleaseResourceContext() const override; - // |PlatformView| std::shared_ptr GetImpellerContext() const override; - // |PlatformView| std::unique_ptr> ComputePlatformResolvedLocales( const std::vector& supported_locale_data) override; - // |PlatformView| void RequestDartDeferredLibrary(intptr_t loading_unit_id) override; void InstallFirstFrameCallback(); diff --git a/shell/platform/ohos/platform_view_ohos_delegate.cpp b/shell/platform/ohos/platform_view_ohos_delegate.cpp index ab423233dc76315ff4bae7de22f59d09053f1250..07746a4c7d1aba0112210ff3706b8d17dbcebf40 100644 --- a/shell/platform/ohos/platform_view_ohos_delegate.cpp +++ b/shell/platform/ohos/platform_view_ohos_delegate.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/platform_view_ohos_delegate.h" diff --git a/shell/platform/ohos/platform_view_ohos_delegate.h b/shell/platform/ohos/platform_view_ohos_delegate.h index 5b5fa634f01a7a025b2e85c5b32e27dbc19d0583..cc586263dcbd8d86c7e4ee908c94adec3969b8b2 100644 --- a/shell/platform/ohos/platform_view_ohos_delegate.h +++ b/shell/platform/ohos/platform_view_ohos_delegate.h @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 SHELL_PLATFORM_OHOS_PLATFORM_VIEW_OHOS_DELEGATE diff --git a/shell/platform/ohos/surface/ohos_native_window.cpp b/shell/platform/ohos/surface/ohos_native_window.cpp index 4e256eb7d67ecfaec08daad9bef4e5929c9767bc..68a11aa46d7bd51d27f5d51aa311f4c15763b165 100644 --- a/shell/platform/ohos/surface/ohos_native_window.cpp +++ b/shell/platform/ohos/surface/ohos_native_window.cpp @@ -1,16 +1,8 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. * - * 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 "flutter/shell/platform/ohos/surface/ohos_native_window.h" diff --git a/shell/platform/ohos/surface/ohos_native_window.h b/shell/platform/ohos/surface/ohos_native_window.h index 29ecfee97a64e0e23663778039505be0fd342cb7..5f239ef70c16344b29b24935f425e01c67f965b5 100644 --- a/shell/platform/ohos/surface/ohos_native_window.h +++ b/shell/platform/ohos/surface/ohos_native_window.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef OHOS_NATIVE_WINDOW_H diff --git a/shell/platform/ohos/surface/ohos_snapshot_surface_producer.cpp b/shell/platform/ohos/surface/ohos_snapshot_surface_producer.cpp index 21d0d333f3063a4761cdf3f9b4ad6a506102788b..a44b12e1575152e86c83cb954a2ba2f2b85f4230 100755 --- a/shell/platform/ohos/surface/ohos_snapshot_surface_producer.cpp +++ b/shell/platform/ohos/surface/ohos_snapshot_surface_producer.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h" diff --git a/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h b/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h index ba890b03587156759c0e33dd3436aaf0701e5db9..fe7037d7efb73cb7ae60dc5bd120e86b95a90e84 100755 --- a/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h +++ b/shell/platform/ohos/surface/ohos_snapshot_surface_producer.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef OHOS_SNAPSHOT_SURFACE_PRODUCER_H diff --git a/shell/platform/ohos/surface/ohos_surface.cpp b/shell/platform/ohos/surface/ohos_surface.cpp index 9d887f3d894704583da1b92b9eb5ea2f6f12a8fb..d2449c5c60563abed06e337c47bb30ae3170c666 100644 --- a/shell/platform/ohos/surface/ohos_surface.cpp +++ b/shell/platform/ohos/surface/ohos_surface.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/shell/platform/ohos/surface/ohos_surface.h" diff --git a/shell/platform/ohos/surface/ohos_surface.h b/shell/platform/ohos/surface/ohos_surface.h index b87757d5f5d7d6b2d55118ee93ff445b1cd7d346..1a91020770def5aac209567c1927ecf7505ecdb1 100644 --- a/shell/platform/ohos/surface/ohos_surface.h +++ b/shell/platform/ohos/surface/ohos_surface.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef OHOS_SURFACE_H diff --git a/shell/platform/ohos/testing/ohos_assert_provider_unittests.cpp b/shell/platform/ohos/testing/ohos_assert_provider_unittests.cpp index c9a810e5daa0a3a8f43c6007e51e80020f07d87d..ecf58e727e0869395a7671264cb1ebc893a2c836 100644 --- a/shell/platform/ohos/testing/ohos_assert_provider_unittests.cpp +++ b/shell/platform/ohos/testing/ohos_assert_provider_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_context_gl_skia_uinttests.cpp b/shell/platform/ohos/testing/ohos_context_gl_skia_uinttests.cpp index c6c129c0a30876387fa038a0c9ca11c7bfe8109a..cb7cfb0c1ca93c0fa64e8981fd687bbdb4ae1698 100644 --- a/shell/platform/ohos/testing/ohos_context_gl_skia_uinttests.cpp +++ b/shell/platform/ohos/testing/ohos_context_gl_skia_uinttests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_display_uinttests.cpp b/shell/platform/ohos/testing/ohos_display_uinttests.cpp index 78bd056765e2e4b663f167073fa55b80ed15b530..f76e1b96e2a1a9c73cf1e828396884640d0e1455 100644 --- a/shell/platform/ohos/testing/ohos_display_uinttests.cpp +++ b/shell/platform/ohos/testing/ohos_display_uinttests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_egl_surface_unittests.cpp b/shell/platform/ohos/testing/ohos_egl_surface_unittests.cpp index 62980266b09e6056113db236ed43044032ea8dec..02c01d63619ce92c558d4e436b3b023deda5b8cf 100644 --- a/shell/platform/ohos/testing/ohos_egl_surface_unittests.cpp +++ b/shell/platform/ohos/testing/ohos_egl_surface_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_environment_gl_unittests.cpp b/shell/platform/ohos/testing/ohos_environment_gl_unittests.cpp index 096ae8bfe50b41fc77fc1ae73f495af5582e7f06..d9d62ce0c1673a39b9c488ca873c26b7899a175e 100644 --- a/shell/platform/ohos/testing/ohos_environment_gl_unittests.cpp +++ b/shell/platform/ohos/testing/ohos_environment_gl_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_external_texture_gl_unittests.cpp b/shell/platform/ohos/testing/ohos_external_texture_gl_unittests.cpp index 5e1cda2737104ea246098ac915609e6150b7fd16..10696192f5724af13efc37def714eabf93cd7a26 100644 --- a/shell/platform/ohos/testing/ohos_external_texture_gl_unittests.cpp +++ b/shell/platform/ohos/testing/ohos_external_texture_gl_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_surface_gl_skia_unittests.cpp b/shell/platform/ohos/testing/ohos_surface_gl_skia_unittests.cpp index f1d98fb76554fe3e2ba102b467da25aa69668ca6..2ce4441f6db8df3d30fa3e9a55dcf3190f9ce82f 100644 --- a/shell/platform/ohos/testing/ohos_surface_gl_skia_unittests.cpp +++ b/shell/platform/ohos/testing/ohos_surface_gl_skia_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_surface_software_unittests.cpp b/shell/platform/ohos/testing/ohos_surface_software_unittests.cpp index c84c1826612bc3ebf16b367f749f20c48f7ec7e5..d8bc8b39346e8d1f6d4e8b359e7190842ba48916 100644 --- a/shell/platform/ohos/testing/ohos_surface_software_unittests.cpp +++ b/shell/platform/ohos/testing/ohos_surface_software_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_touch_processor_unittests.cpp b/shell/platform/ohos/testing/ohos_touch_processor_unittests.cpp index c9b2a74de2cdf6c10c4b6418f2dc097e7c5c15c1..6e7a4c99bc724461f63bfd54bd41800b786707cd 100644 --- a/shell/platform/ohos/testing/ohos_touch_processor_unittests.cpp +++ b/shell/platform/ohos/testing/ohos_touch_processor_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/ohos_xcomponent_adapter_unittests.cpp b/shell/platform/ohos/testing/ohos_xcomponent_adapter_unittests.cpp index aa1538956c72448ef158f108c89c7c1a5e31d497..22b076484e9e7df81a1ce3b46a61922eb20b6a10 100644 --- a/shell/platform/ohos/testing/ohos_xcomponent_adapter_unittests.cpp +++ b/shell/platform/ohos/testing/ohos_xcomponent_adapter_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/testing/vsync_waiter_ohos_unittests.cpp b/shell/platform/ohos/testing/vsync_waiter_ohos_unittests.cpp index 48245deba360d6b47e17d43339ddd7f79c066180..bdb182c8f5e79e0b20e354b0f7e5e9e121aa633e 100644 --- a/shell/platform/ohos/testing/vsync_waiter_ohos_unittests.cpp +++ b/shell/platform/ohos/testing/vsync_waiter_ohos_unittests.cpp @@ -1,16 +1,7 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include #include diff --git a/shell/platform/ohos/types.h b/shell/platform/ohos/types.h index 69fa5fd484d54e9d6e878aaaa56ae7c9ee86f0cd..dc68de62c09905c0e1888723e69e9e8b0f62e73f 100644 --- a/shell/platform/ohos/types.h +++ b/shell/platform/ohos/types.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_KHZG file. */ #ifndef OHOS_TYPES_H #define OHOS_TYPES_H diff --git a/shell/platform/ohos/utils/arkui_accessibility_constant.h b/shell/platform/ohos/utils/arkui_accessibility_constant.h new file mode 100644 index 0000000000000000000000000000000000000000..fcaebd27d72b2a3f4f024074dc4e0e99eb1d8a5f --- /dev/null +++ b/shell/platform/ohos/utils/arkui_accessibility_constant.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. + */ +#ifndef ARKUI_ACCESSIBILITY_CONSTANT_H +#define ARKUI_ACCESSIBILITY_CONSTANT_H +namespace flutter { + +/** + * 封装ArkUI无障碍C-API的符号表中接口名称常量, + * 方便动态加载libflutter_accessiblity.so中的无障碍接口 + */ +class ArkUIAccessibilityConstant { +public: + static constexpr char OH_GET_A11Y_PROVIDER[] = "OH_NativeXComponent_GetNativeAccessibilityProvider"; + static constexpr char ARKUI_REGISTER_CALLBACK[] = "OH_ArkUI_AccessibilityProviderRegisterCallback"; + static constexpr char ARKUI_SEND_A11Y_EVENT[] = "OH_ArkUI_SendAccessibilityAsyncEvent"; + static constexpr char ARKUI_GET_A11Y_NODE[] = "OH_ArkUI_AddAndGetAccessibilityElementInfo"; + + static constexpr char ARKUI_CREATE_NODE[] = "OH_ArkUI_CreateAccessibilityElementInfo"; + static constexpr char ARKUI_DESTORY_NODE[] = "OH_ArkUI_DestoryAccessibilityElementInfo"; + static constexpr char ARKUI_CREATE_EVENT[] = "OH_ArkUI_CreateAccessibilityEventInfo"; + static constexpr char ARKUI_DESTORY_EVENT[] = "OH_ArkUI_DestoryAccessibilityEventInfo"; + + static constexpr char ARKUI_SET_NODE_ID[] = "OH_ArkUI_AccessibilityElementInfoSetElementId"; + static constexpr char ARKUI_SET_PARENT_ID[] = "OH_ArkUI_AccessibilityElementInfoSetParentId"; + static constexpr char ARKUI_SET_COMPONENT_TYPE[] = "OH_ArkUI_AccessibilityElementInfoSetComponentType"; + static constexpr char ARKUI_SET_CONTENTS[] = "OH_ArkUI_AccessibilityElementInfoSetContents"; + static constexpr char ARKUI_SET_HINT[] = "OH_ArkUI_AccessibilityElementInfoSetHintText"; + static constexpr char ARKUI_SET_A11Y_TEXT[] = "OH_ArkUI_AccessibilityElementInfoSetAccessibilityText"; + static constexpr char ARKUI_SET_A11Y_DESC[] = "OH_ArkUI_AccessibilityElementInfoSetAccessibilityDescription"; + static constexpr char ARKUI_SET_CHILD_IDS[] = "OH_ArkUI_AccessibilityElementInfoSetChildNodeIds"; + static constexpr char ARKUI_SET_ACTIONS[] = "OH_ArkUI_AccessibilityElementInfoSetOperationActions"; + static constexpr char ARKUI_SET_SCREEN_RECT[] = "OH_ArkUI_AccessibilityElementInfoSetScreenRect"; + static constexpr char ARKUI_SET_CHECKABLE[] = "OH_ArkUI_AccessibilityElementInfoSetCheckable"; + static constexpr char ARKUI_SET_CHECKED[] = "OH_ArkUI_AccessibilityElementInfoSetChecked"; + static constexpr char ARKUI_SET_FOCUSABLE[] = "OH_ArkUI_AccessibilityElementInfoSetFocusable"; + static constexpr char ARKUI_SET_FOCUSED[] = "OH_ArkUI_AccessibilityElementInfoSetFocused"; + static constexpr char ARKUI_SET_VISIBLE[] = "OH_ArkUI_AccessibilityElementInfoSetVisible"; + static constexpr char ARKUI_SET_A11Y_FOCUSED[] = "OH_ArkUI_AccessibilityElementInfoSetAccessibilityFocused"; + static constexpr char ARKUI_SET_SELECTED[] = "OH_ArkUI_AccessibilityElementInfoSetSelected"; + static constexpr char ARKUI_SET_CLICKABLE[] = "OH_ArkUI_AccessibilityElementInfoSetClickable"; + static constexpr char ARKUI_SET_LONG_PRESS[] = "OH_ArkUI_AccessibilityElementInfoSetLongClickable"; + static constexpr char ARKUI_SET_ENABLED[] = "OH_ArkUI_AccessibilityElementInfoSetEnabled"; + static constexpr char ARKUI_SET_IS_PASSWORD[] = "OH_ArkUI_AccessibilityElementInfoSetIsPassword"; + static constexpr char ARKUI_SET_SCROLLABLE[] = "OH_ArkUI_AccessibilityElementInfoSetScrollable"; + static constexpr char ARKUI_SET_EDITABLE[] = "OH_ArkUI_AccessibilityElementInfoSetEditable"; + static constexpr char ARKUI_SET_IS_HINT[] = "OH_ArkUI_AccessibilityElementInfoSetIsHint"; + static constexpr char ARKUI_SET_A11Y_GROUP[] = "OH_ArkUI_AccessibilityElementInfoSetAccessibilityGroup"; + static constexpr char ARKUI_SET_A11Y_LEVEL[] = "OH_ArkUI_AccessibilityElementInfoSetAccessibilityLevel"; + + static constexpr char ARKUI_SET_CURR_ITEM_IDX[] = "OH_ArkUI_AccessibilityElementInfoSetCurrentItemIndex"; + static constexpr char ARKUI_SET_START_ITEM_IDX[] = "OH_ArkUI_AccessibilityElementInfoSetStartItemIndex"; + static constexpr char ARKUI_SET_END_ITEM_IDX[] = "OH_ArkUI_AccessibilityElementInfoSetEndItemIndex"; + static constexpr char ARKUI_SET_ITEM_COUNT[] = "OH_ArkUI_AccessibilityElementInfoSetItemCount"; + + static constexpr char ARKUI_SET_EVENT_TYPE[] = "OH_ArkUI_AccessibilityEventSetEventType"; + static constexpr char ARKUI_SET_ANNOUNCED_TEXT[] = "OH_ArkUI_AccessibilityEventSetTextAnnouncedForAccessibility"; + static constexpr char ARKUI_SET_REQ_FOCUSED_ID[] = "OH_ArkUI_AccessibilityEventSetRequestFocusId"; + static constexpr char ARKUI_EVENT_SET_NODE[] = "OH_ArkUI_AccessibilityEventSetElementInfo"; + + static constexpr char ARKUI_SET_SELECTED_START[] = "OH_ArkUI_AccessibilityElementInfoSetSelectedTextStart"; + static constexpr char ARKUI_SET_SELECTED_END[] = "OH_ArkUI_AccessibilityElementInfoSetSelectedTextEnd"; + static constexpr char ARKUI_FIND_ACTION_ARG_BY_KEY[] = "OH_ArkUI_FindAccessibilityActionArgumentByKey"; + + static constexpr char ARKUI_SET_RANGE_INFO[] = "OH_ArkUI_AccessibilityElementInfoSetRangeInfo"; + static constexpr char ARKUI_SET_GRID_INFO[] = "OH_ArkUI_AccessibilityElementInfoSetGridInfo"; + static constexpr char ARKUI_SET_A11Y_OFFSET[] = "OH_ArkUI_AccessibilityElementInfoSetAccessibilityOffset"; + static constexpr char ARKUI_SET_Z_INDEX[] = "OH_ArkUI_AccessibilityElementInfoSetZIndex"; + static constexpr char ARKUI_SET_A11Y_OPACITY[] = "OH_ArkUI_AccessibilityElementInfoSetAccessibilityOpacity"; + static constexpr char ARKUI_SET_BACKGROUND_COLOR[] = "OH_ArkUI_AccessibilityElementInfoSetBackgroundColor"; + static constexpr char ARKUI_SET_BRACKGROUND_IMG[] = "OH_ArkUI_AccessibilityElementInfoSetBackgroundImage"; + static constexpr char ARKUI_SET_BLUR[] = "OH_ArkUI_AccessibilityElementInfoSetBlur"; + static constexpr char ARKUI_SET_HIT_TEST_BEHAVIOR[] = "OH_ArkUI_AccessibilityElementInfoSetHitTestBehavior"; +}; + +} +#endif \ No newline at end of file diff --git a/shell/platform/ohos/utils/ddl_utils.h b/shell/platform/ohos/utils/ddl_utils.h index 5ddbb0e954e9df73b55e955b54b266fa1adca117..630c439bfd673b169a890f2ea9721c7758d67a74 100644 --- a/shell/platform/ohos/utils/ddl_utils.h +++ b/shell/platform/ohos/utils/ddl_utils.h @@ -1,16 +1,7 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. */ #ifndef DDL_UTILS_H @@ -21,5 +12,54 @@ using LIBHANDLE = void*; #define LOAD_LIB(libPath) dlopen(libPath, RTLD_LAZY|RTLD_LOCAL) #define CLOSE_LIB(libHandle) dlclose(libHandle) #define LOAD_SYM(libHandle, symbol) dlsym(libHandle, symbol) +#define LOAD_ERROR() dlerror() + +#define ARKUI_SUCCEED_CODE 0 +#define ARKUI_FAILED_CODE -1 +#define ARKUI_BAD_PARAM_CODE -2 +#define ARKUI_OOM_CODE -3 + +#define ARKUI_ACCESSIBILITY_CALL_CHECK(X) \ + do { \ + int32_t RET = X; \ + if (RET != ARKUI_SUCCEED_CODE) { \ + LOGE("Failed function %{public}s call, error code:%{public}d",\ + #X, RET); \ + } \ + } while (false) \ + +#define CHECK_DLL_NULL_PTR(func) \ + do { \ + if (func == nullptr) { \ + LOGE("Error: Function %{public}s is nullptr, %{public}s", \ + #func, LOAD_ERROR()); \ + } \ + } while (false) \ + +#define CHECK_NULL_PTR(PARAM, FUNC) \ + do { \ + if (PARAM == nullptr) { \ + LOGE("Error: %{public}s -> %{public}s is nullptr", \ + #FUNC, #PARAM); \ + } \ + } while (false) \ + +#define CHECK_NULL_PTR_WITH_RET(PARAM, FUNC) \ + do { \ + if (PARAM == nullptr) { \ + LOGE("Error: %{public}s -> %{public}s is nullptr", \ + #FUNC, #PARAM); \ + return ARKUI_FAILED_CODE; \ + } \ + } while (false) \ + +#define CHECK_NULL_PTR_RET_VOID(PARAM, FUNC) \ + do { \ + if (PARAM == nullptr) { \ + LOGE("Error: %{public}s -> %{public}s is nullptr", \ + #FUNC, #PARAM); \ + return; \ + } \ + } while (false) \ #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UTILS_H diff --git a/shell/platform/ohos/utils/ohos_utils.cpp b/shell/platform/ohos/utils/ohos_utils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3c828266f07c489fb55cfc7b77305cb5f0320033 --- /dev/null +++ b/shell/platform/ohos/utils/ohos_utils.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. + */ +#include "ohos_utils.h" +namespace flutter { + +OHOSUtils::OHOSUtils() {}; +OHOSUtils::~OHOSUtils() {}; + +/** + * 判断源字符串是否包含目标字符串 + */ +bool OHOSUtils::Contains(const std::string source, + const std::string target) +{ + return source.find(target) != std::string::npos; +} + +/** + * 将string序列化为uint8字节数组 + */ +void OHOSUtils::SerializeString(const std::string& str, std::vector& buffer) +{ + // store the length of the string as a uint8_t + uint32_t length = str.size(); + buffer.insert(buffer.end(), + reinterpret_cast(&length), + reinterpret_cast(&length) + sizeof(length)); + // store the actual string data + buffer.insert(buffer.end(), str.begin(), str.end()); +} + +/** + * 将map序列化为uint8字节数组 + */ +std::vector OHOSUtils::SerializeStringIntMap(const std::map& mp) +{ + std::vector buffer; + + // Store the number of elements in the map + uint32_t mapSize = mp.size(); + buffer.insert(buffer.end(), + reinterpret_cast(&mapSize), + reinterpret_cast(&mapSize) + sizeof(mapSize)); + + // Iterate over the map and serialize each key-value pair + for (const auto& it : mp) { + SerializeString(it.first, buffer); + buffer.insert(buffer.end(), + reinterpret_cast(&it.second), + reinterpret_cast(&it.second) + sizeof(it.second)); + } + + return buffer; +} + +/** + * convert char* type to int32_t type with a safe way + */ +void OHOSUtils::CharArrayToInt32(const char* str, int32_t& target) +{ + char* end; + long int num = std::strtol(str, &end, 10); + + // Check if the entire string was converted + if (*end == '\0') { + target = static_cast(num); + LOGD("The int32_t value is: %{public}d", target); + } else { + target = 0; + LOGE("Conversion error, non-convertible part: %{public}s", end); + } +} + +} \ No newline at end of file diff --git a/shell/platform/ohos/utils/ohos_utils.h b/shell/platform/ohos/utils/ohos_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..cb27d3e6da31eb134654121b25cdffc074102c46 --- /dev/null +++ b/shell/platform/ohos/utils/ohos_utils.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE_HW file. + */ + +#ifndef OHOS_UTILS_H +#define OHOS_UTILS_H +#include +#include +#include +#include +#include +#include "flutter/shell/platform/ohos/ohos_logging.h" +namespace flutter { + +class OHOSUtils { +public: + OHOSUtils(); + ~OHOSUtils(); + + static bool Contains(const std::string source, const std::string target); + static void SerializeString(const std::string& str, std::vector& buffer); + static std::vector SerializeStringIntMap(const std::map& mp); + static void CharArrayToInt32(const char* str, int32_t& target); +}; + +} +#endif diff --git a/shell/platform/ohos/vsync_waiter_ohos.cpp b/shell/platform/ohos/vsync_waiter_ohos.cpp index 1330506a8a08223fee39ccb5f4b86da21e49a99c..c5cb15f858a82c1bac7a19cefcf313da7c1cb175 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.cpp +++ b/shell/platform/ohos/vsync_waiter_ohos.cpp @@ -1,28 +1,22 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "flutter/shell/platform/ohos/vsync_waiter_ohos.h" #include "napi_common.h" #include "ohos_logging.h" +#include #include namespace flutter { static std::atomic_uint g_refresh_rate_ = 60; +static constexpr int32_t SUPPORT_API_VERSION = 14; const char* flutterSyncName = "flutter_connect"; +const char* NATIVE_DVSYNC_SO = "libnative_vsync.so"; thread_local bool VsyncWaiterOHOS::firstCall = true; @@ -35,6 +29,11 @@ VsyncWaiterOHOS::VsyncWaiterOHOS(const flutter::TaskRunners& task_runners) VsyncWaiterOHOS::~VsyncWaiterOHOS() { OH_NativeVSync_Destroy(vsyncHandle); vsyncHandle = nullptr; + nativeDvsyncFunc_ = nullptr; + if (handle_) { + dlclose(handle_); + handle_ = nullptr; + } } void VsyncWaiterOHOS::AwaitVSync() { @@ -69,10 +68,6 @@ void VsyncWaiterOHOS::OnVsyncFromOHOS(long long timestamp, void* data) { int64_t frame_nanos = static_cast(timestamp); auto frame_time = fml::TimePoint::FromEpochDelta( fml::TimeDelta::FromNanoseconds(frame_nanos)); - auto now = fml::TimePoint::Now(); - if (frame_time > now) { - frame_time = now; - } auto target_time = frame_time + fml::TimeDelta::FromNanoseconds( 1000000000.0 / g_refresh_rate_); auto* weak_this = reinterpret_cast*>(data); @@ -96,4 +91,51 @@ void VsyncWaiterOHOS::OnUpdateRefreshRate(long long refresh_rate) { g_refresh_rate_ = static_cast(refresh_rate); } +int VsyncWaiterOHOS::GetRefreshRate(void) +{ + return g_refresh_rate_; +} + +void VsyncWaiterOHOS::DisableDVsync() { + if (dvsyncEnabled.load()) { + SetDvsyncSwitch(false); + dvsyncEnabled.store(false); + } +} + +void VsyncWaiterOHOS::EnableDVsync() { + if (!dvsyncEnabled.load()) { + SetDvsyncSwitch(true); + dvsyncEnabled.store(true); + } +} + +void VsyncWaiterOHOS::SetDvsyncSwitch(bool enableDvsync) { + if (apiVersion_ == 0) { + apiVersion_ = OH_GetSdkApiVersion(); + } + if (apiVersion_ < SUPPORT_API_VERSION) { + LOGI("current api version not support native dvsync!"); + return; + } + if (!handle_) { + handle_ = dlopen(NATIVE_DVSYNC_SO, RTLD_NOW); + } + if (!handle_) { + LOGE("SetDvsyncSwitch load %{public}s failed!", NATIVE_DVSYNC_SO); + return; + } + + if (!nativeDvsyncFunc_) { + nativeDvsyncFunc_ = reinterpret_cast(dlsym(handle_, "OH_NativeVSync_DVSyncSwitch")); + } + if (!nativeDvsyncFunc_) { + LOGE("SetDvsyncSwitch load OH_NativeVSync_DVSyncSwitch failed!"); + dlclose(handle_); + handle_ = nullptr; + return; + } + nativeDvsyncFunc_(vsyncHandle, enableDvsync); +} + } // namespace flutter diff --git a/shell/platform/ohos/vsync_waiter_ohos.h b/shell/platform/ohos/vsync_waiter_ohos.h index e9aac66c852b888b7495c27d0843fe777e3af169..fb71db929f6153ca7a54a3a7e138cee9249f9380 100644 --- a/shell/platform/ohos/vsync_waiter_ohos.h +++ b/shell/platform/ohos/vsync_waiter_ohos.h @@ -1,47 +1,50 @@ /* - * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #ifndef VSYNC_WAITER_OHOS_H #define VSYNC_WAITER_OHOS_H +#include #include +#include #include #include "flutter/fml/macros.h" #include "flutter/shell/common/vsync_waiter.h" namespace flutter { +using NativeDvsyncFunc = int (*)(OH_NativeVSync* nativeVSync, bool enable); class VsyncWaiterOHOS final : public VsyncWaiter { - public: - explicit VsyncWaiterOHOS(const flutter::TaskRunners& task_runners); - static void OnUpdateRefreshRate(long long refresh_rate); +public: + explicit VsyncWaiterOHOS(const flutter::TaskRunners& task_runners); + ~VsyncWaiterOHOS() override; - ~VsyncWaiterOHOS() override; + static void OnUpdateRefreshRate(long long refresh_rate); - private: - thread_local static bool firstCall; - // |VsyncWaiter| - void AwaitVSync() override; + int GetRefreshRate(void); + void DisableDVsync() override; + void EnableDVsync() override; - static void OnVsyncFromOHOS(long long timestamp, void* data); - static void ConsumePendingCallback(std::weak_ptr* weak_this, +private: + // |VsyncWaiter| + void AwaitVSync() override; + + static void OnVsyncFromOHOS(long long timestamp, void* data); + static void ConsumePendingCallback(std::weak_ptr* weak_this, fml::TimePoint frame_start_time, fml::TimePoint frame_target_time); - - OH_NativeVSync* vsyncHandle; - FML_DISALLOW_COPY_AND_ASSIGN(VsyncWaiterOHOS); + void SetDvsyncSwitch(bool enableDvsync); + + std::atomic dvsyncEnabled{false}; + thread_local static bool firstCall; + OH_NativeVSync* vsyncHandle; + NativeDvsyncFunc nativeDvsyncFunc_ = nullptr; + void *handle_ = nullptr; + int32_t apiVersion_ = 0; + FML_DISALLOW_COPY_AND_ASSIGN(VsyncWaiterOHOS); }; -} // namespace flutter +} // namespace flutter #endif diff --git a/third_party/accessibility/ax/ax_table_info.h b/third_party/accessibility/ax/ax_table_info.h index 53086c42693c18501c3786bff29804464e01f2f3..ef9266f2e5c4145824c451d14c3075f8daf22310 100644 --- a/third_party/accessibility/ax/ax_table_info.h +++ b/third_party/accessibility/ax/ax_table_info.h @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/third_party/txt/src/txt/platform_ohos.cc b/third_party/txt/src/txt/platform_ohos.cc index 3a0be33881a7846ee40672e9ccdc027f44b4951d..595d6431302a7c1db7e4f709ddc8620ad878f230 100644 --- a/third_party/txt/src/txt/platform_ohos.cc +++ b/third_party/txt/src/txt/platform_ohos.cc @@ -1,16 +1,7 @@ /* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + * Copyright 2013 The Flutter Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #include "txt/platform.h"