From 656c5d18cfb7838714d4a5b52ccaa1ea1a27c4fa Mon Sep 17 00:00:00 2001 From: houhaoyue Date: Tue, 24 Sep 2024 15:47:06 +0800 Subject: [PATCH 01/22] fix the onAreaChange position Signed-off-by: houhaoyue --- .../flutter/src/main/ets/view/FlutterView.ets | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 59038f9f33..02838a0127 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 @@ -336,7 +336,7 @@ export class FlutterView { } // 根据是否全屏显示,设置标题栏高度(若全屏,则及时规避) - if (this.checkFullScreen && (setFullScreen || FlutterManager.getInstance().getFullScreenListener().useFullScreen())) { // 全屏显示 + if (this.checkFullScreen && (setFullScreen || this.mainWindow.getWindowProperties().isLayoutFullScreen)) { // 全屏显示 this.viewportMetrics.physicalViewPaddingTop = this.systemAvoidArea?.topRect.height ?? 0; this.viewportMetrics.physicalViewPaddingBottom = this.navigationAvoidArea?.bottomRect.height ?? 0; } else { // 非全屏显示(保持规避效果) @@ -358,10 +358,10 @@ export class FlutterView { private onKeyboardAreaChange() { if (this.checkKeyboard) { let keyboardAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); - this.viewportMetrics.physicalViewInsetTop = keyboardAvoidArea?.topRect.height ?? 0 - this.viewportMetrics.physicalViewInsetLeft = keyboardAvoidArea?.leftRect.width ?? 0 - this.viewportMetrics.physicalViewInsetBottom = keyboardAvoidArea?.bottomRect.height ?? 0 - this.viewportMetrics.physicalViewInsetRight = keyboardAvoidArea?.rightRect.width ?? 0 + this.viewportMetrics.physicalViewInsetTop = this.keyboardAvoidArea!.topRect.height + this.viewportMetrics.physicalViewInsetLeft = this.keyboardAvoidArea!.leftRect.width + this.viewportMetrics.physicalViewInsetBottom = this.keyboardAvoidArea!.bottomRect.height + this.viewportMetrics.physicalViewInsetRight = this.keyboardAvoidArea!.rightRect.width } else { this.viewportMetrics.physicalViewInsetTop = 0 this.viewportMetrics.physicalViewInsetLeft = 0 @@ -373,10 +373,10 @@ export class FlutterView { private onGestureAreaChange() { if (this.checkGesture) { let gestureAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); - this.viewportMetrics.systemGestureInsetTop = gestureAvoidArea?.topRect.height ?? 0 - this.viewportMetrics.systemGestureInsetLeft = gestureAvoidArea?.leftRect.width ?? 0 - this.viewportMetrics.systemGestureInsetBottom = gestureAvoidArea?.bottomRect.height ?? 0 - this.viewportMetrics.systemGestureInsetRight = gestureAvoidArea?.rightRect.width ?? 0 + this.viewportMetrics.systemGestureInsetTop = this.gestureAvoidArea!.topRect.height + this.viewportMetrics.systemGestureInsetLeft = this.gestureAvoidArea!.leftRect.width + this.viewportMetrics.systemGestureInsetBottom = this.gestureAvoidArea!.bottomRect.height + this.viewportMetrics.systemGestureInsetRight = this.gestureAvoidArea!.rightRect.width } else { this.viewportMetrics.systemGestureInsetTop = 0 this.viewportMetrics.systemGestureInsetLeft = 0 -- Gitee From d49c19745a1a849a343a552745d4fadf3b862ee8 Mon Sep 17 00:00:00 2001 From: houhaoyue Date: Tue, 24 Sep 2024 19:09:26 +0800 Subject: [PATCH 02/22] fix Signed-off-by: houhaoyue --- .../flutter/src/main/ets/view/FlutterView.ets | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 02838a0127..0a0ffca259 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 @@ -166,16 +166,16 @@ export class FlutterView { private avoidAreaChangeCallback = (data: window.AvoidAreaOptions) => { Log.i(TAG, "avoidAreaChangeCallback, type=" + data.type); + if (data.type == window.AvoidAreaType.TYPE_SYSTEM) { //0 + this.systemAvoidArea = data.area; + } else if (data.type == window.AvoidAreaType.TYPE_SYSTEM_GESTURE) { //2 + this.gestureAvoidArea = data.area; + } else if (data.type == window.AvoidAreaType.TYPE_KEYBOARD) { //3 + this.keyboardAvoidArea = data.area; + } else if (data.type == window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { //4 + this.navigationAvoidArea = data.area; + } if (this.isAttachedToFlutterEngine()) { - if (data.type == window.AvoidAreaType.TYPE_SYSTEM) { //0 - this.systemAvoidArea = data.area; - } else if (data.type == window.AvoidAreaType.TYPE_SYSTEM_GESTURE) { //2 - this.gestureAvoidArea = data.area; - } else if (data.type == window.AvoidAreaType.TYPE_KEYBOARD) { //3 - this.keyboardAvoidArea = data.area; - } else if (data.type == window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { //4 - this.navigationAvoidArea = data.area; - } this.onAreaChange(null); } } -- Gitee From 94d91b8d2d6ca8de7ecf0f447d6d93964d56ff00 Mon Sep 17 00:00:00 2001 From: houhaoyue Date: Wed, 25 Sep 2024 17:08:29 +0800 Subject: [PATCH 03/22] fix the issue where physicalSize is overwritten by display size when the app invokes onAreaChange before attaching the engine Signed-off-by: houhaoyue --- .../flutter/src/main/ets/view/FlutterView.ets | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 0a0ffca259..a1e447533d 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 @@ -135,6 +135,7 @@ export class FlutterView { private navigationAvoidArea: window.AvoidArea; private gestureAvoidArea: window.AvoidArea; private keyboardAvoidArea: window.AvoidArea; + private needSetViewport: boolean = false; constructor(viewId: string, context: Context) { @@ -350,8 +351,10 @@ export class FlutterView { this.onKeyboardAreaChange() this.onGestureAreaChange() - if (!this.viewportMetrics.isEqual(originalMetrics)) { - this.updateViewportMetrics() + if (!this.viewportMetrics.isEqual(originalMetrics) || this.needSetViewport) { + if (!this.updateViewportMetrics()) { + this.needSetViewport = true; + } } } @@ -389,7 +392,7 @@ export class FlutterView { return this.flutterEngine != null } - private updateViewportMetrics() { + private updateViewportMetrics(): boolean{ if (this.isAttachedToFlutterEngine()) { this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, this.viewportMetrics.physicalWidth, @@ -410,7 +413,9 @@ export class FlutterView { new Array(0), new Array(0), new Array(0)) + return true; } + return false; } onKeyEvent(event: KeyEvent) { -- Gitee From 5d12789e71e8358266b99a7bb53f6042f229b3dd Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Mon, 7 Oct 2024 16:26:42 +0800 Subject: [PATCH 04/22] =?UTF-8?q?=E5=9B=9E=E9=80=80PR416=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=E5=A2=9E=E5=8A=A0InputMethod=E7=9A=84detach?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BF=9D=E8=AF=81=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=8B=89=E8=B5=B7=E8=BD=AF=E9=94=AE=E7=9B=98=E5=8F=AF=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../ets/plugin/editing/TextInputPlugin.ets | 32 +------------------ 1 file changed, 1 insertion(+), 31 deletions(-) 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 c499dacb39..36c52b7faa 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 @@ -17,17 +17,11 @@ import TextInputChannel, { Configuration, TextEditState, TextInputMethodHandler, - TextInputType } from '../../embedding/engine/systemchannels/TextInputChannel'; import inputMethod from '@ohos.inputMethod'; import Log from '../../util/Log'; import { EditingStateWatcher, ListenableEditingState } from './ListenableEditingState'; import Any from '../common/Any'; -import { window } from '@kit.ArkUI'; -import FlutterManager from '../../embedding/ohos/FlutterManager'; -import { IntentionCode } from '@ohos.multimodalInput.intentionCode'; -import {KeyCode} from '@kit.InputKit'; -import { BusinessError } from '@kit.BasicServicesKit'; /// 临时规避缺少newline对应枚举问题 const NEWLINE_KEY_TYPE: number = 8; @@ -273,37 +267,12 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.imcFlag = true; } - sendKeyboardEvent(type: KeyType, keyCode: number): void { - let event: KeyEvent = { - type: type, - keyCode: keyCode, - keyText: '', - keySource: KeySource.Keyboard, - deviceId: 0, - metaKey: 0, - timestamp: 0, - stopPropagation: (): void => { - throw new Error('Function not implemented.'); - }, - intentionCode: IntentionCode.INTENTION_BACK - } - FlutterManager.getInstance().getFlutterViewList().forEach((value) => { - value.onKeyEvent(event) - }) - } - private insertTextCallback = (text: string) => { Log.d(TextInputMethodHandlerImpl.TAG, "insertText: " + text); this.mEditable.handleInsertTextEvent(text); } private deleteLeftCallback = (length: number) => { - /// 暂时规避方案 - /// OS机制与Android不一致,需要去监听软键盘事件才能发送KeyEvent事件 - if (this.mEditable.getStringCache() == "") { - this.sendKeyboardEvent(KeyType.Down, KeyCode.KEYCODE_DEL) - this.sendKeyboardEvent(KeyType.Up, KeyCode.KEYCODE_DEL) - } this.mEditable.handleDeleteEvent(false, length); } @@ -340,6 +309,7 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.inputMethodController.off('sendKeyboardStatus', this.sendKeyboardStatusCallback); this.inputMethodController.off('selectByRange', this.selectByRangeCallback); this.imcFlag = false; + this.inputMethodController.detach() } public clearTextInputClient(): void { -- Gitee From f8a8256a8fed52524e9eb4eca776d8d4fa10b02c Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Mon, 7 Oct 2024 18:44:41 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E7=BA=B9=E7=90=86=E9=A6=96=E5=B8=A7=E6=B8=B2=E6=9F=93=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 46fa22e2a0..59887d8d3d 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -134,7 +134,7 @@ void OHOSExternalTextureGL::Paint(PaintContext& context, GrGLTextureInfo textureInfo; - if (!freeze && !first_update_ && !isEmulator_ && backGroundTextureName_ == 0 && pixelMap_ == nullptr) { + if (!freeze && !first_update_ && !isEmulator_ && !new_frame_ready_ && pixelMap_ == nullptr) { setBackground(bounds.width(), bounds.height()); textureInfo = {GL_TEXTURE_EXTERNAL_OES, backGroundTextureName_, GL_RGBA8_OES}; } else { -- Gitee From ff03e9210aaa7a024d91db05ced7cc503b08494a Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Tue, 8 Oct 2024 14:58:34 +0800 Subject: [PATCH 06/22] =?UTF-8?q?=E9=80=82=E9=85=8D=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=B3=95=E9=A2=84=E4=B8=8A=E5=B1=8F=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../src/main/ets/plugin/editing/TextInputPlugin.ets | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 36c52b7faa..6a6b814e38 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 @@ -270,14 +270,17 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { private insertTextCallback = (text: string) => { Log.d(TextInputMethodHandlerImpl.TAG, "insertText: " + text); this.mEditable.handleInsertTextEvent(text); + this.changeSelection(); } private deleteLeftCallback = (length: number) => { this.mEditable.handleDeleteEvent(false, length); + this.changeSelection(); } private deleteRightCallback = (length: number) => { this.mEditable.handleDeleteEvent(true, length); + this.changeSelection(); } private sendFunctionKeyCallback = (functionKey: inputMethod.FunctionKey) => { @@ -301,6 +304,14 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.mEditable.handleSelectByRange(range); } + changeSelection(): void { + try { + this.inputMethodController.changeSelection(this.mEditable.getStringCache(), this.mEditable.getSelectionStart(), this.mEditable.getSelectionEnd()); + } catch (err) { + Log.e(TextInputMethodHandlerImpl.TAG, "Failed to changeSelection:" + JSON.stringify(err)); + } + } + cancelListenKeyBoardEvent(): void { this.inputMethodController.off('insertText', this.insertTextCallback); this.inputMethodController.off('deleteLeft', this.deleteLeftCallback); -- Gitee From 0aa37307d94dea6bb2e8ed4684c6f2a081fb92f6 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 8 Oct 2024 18:59:42 +0800 Subject: [PATCH 07/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9NativeWindow=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E7=A8=B3=E5=AE=9A=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_xcomponent_adapter.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index 4d49b0c753..12c633ec66 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -330,9 +330,13 @@ void XComponentBase::OnSurfaceCreated(OH_NativeXComponent* component, (int)height_); ret = SetNativeWindowOpt((OHNativeWindow*)window, width_, height_); if (ret) { - LOGD("SetNativeWindowOpt failed:%{public}d", ret); + LOGE("SetNativeWindowOpt failed:%{public}d", ret); } if (isEngineAttached_) { + ret = OH_NativeWindow_NativeObjectReference(window); + if (ret) { + LOGE("NativeObjectReference failed:%{public}d", ret); + } PlatformViewOHOSNapi::SurfaceCreated(std::stoll(shellholderId_), window); } else { LOGE("OnSurfaceCreated XComponentBase is not attached"); @@ -362,8 +366,12 @@ void XComponentBase::OnSurfaceDestroyed(OH_NativeXComponent* component, LOGD("XComponentManger::OnSurfaceDestroyed"); if (isEngineAttached_) { PlatformViewOHOSNapi::SurfaceDestroyed(std::stoll(shellholderId_)); + int32_t ret = OH_NativeWindow_NativeObjectUnreference(window); + if (ret) { + LOGE("NativeObjectReference failed:%{public}d", ret); + } } else { - LOGE("OnSurfaceCreated OnSurfaceDestroyed is not attached"); + LOGE("XComponentManger::OnSurfaceDestroyed XComponentBase is not attached"); } } -- Gitee From ca0289c1c054f46c044a2897e36738ef422b7da5 Mon Sep 17 00:00:00 2001 From: hezhengyi Date: Tue, 8 Oct 2024 21:31:56 +0800 Subject: [PATCH 08/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hezhengyi --- shell/platform/ohos/ohos_xcomponent_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index 12c633ec66..d6b8f9446d 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -368,7 +368,7 @@ void XComponentBase::OnSurfaceDestroyed(OH_NativeXComponent* component, PlatformViewOHOSNapi::SurfaceDestroyed(std::stoll(shellholderId_)); int32_t ret = OH_NativeWindow_NativeObjectUnreference(window); if (ret) { - LOGE("NativeObjectReference failed:%{public}d", ret); + LOGE("NativeObjectUnreference failed:%{public}d", ret); } } else { LOGE("XComponentManger::OnSurfaceDestroyed XComponentBase is not attached"); -- Gitee From 89b5494a05189e6f10183224b8ebaa34b7b48f89 Mon Sep 17 00:00:00 2001 From: wwyang <137208408@qq.com> Date: Wed, 9 Oct 2024 11:43:09 +0800 Subject: [PATCH 09/22] =?UTF-8?q?=E8=A7=A3=E5=86=B3YUV10bit=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E7=BC=A9=E7=95=A5=E5=9B=BE=E8=8A=B1=E5=B1=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwyang <137208408@qq.com> --- .../ohos/ohos_external_texture_gl.cpp | 53 ++++++++++++++++++- .../platform/ohos/ohos_external_texture_gl.h | 1 + 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 59887d8d3d..966afa007a 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -39,6 +39,42 @@ 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"; +static int PixelMapToWindowFormat(PIXEL_FORMAT pixel_format) { + switch (pixel_format) { + case PIXEL_FORMAT_RGB_565: + return NATIVEBUFFER_PIXEL_FMT_RGB_565; + case PIXEL_FORMAT_RGBA_8888: + return NATIVEBUFFER_PIXEL_FMT_RGBA_8888; + case PIXEL_FORMAT_BGRA_8888: + return NATIVEBUFFER_PIXEL_FMT_BGRA_8888; + case PIXEL_FORMAT_RGB_888: + return NATIVEBUFFER_PIXEL_FMT_RGB_888; + case PIXEL_FORMAT_NV21: + return NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP; + case PIXEL_FORMAT_NV12: + return NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP; + case PIXEL_FORMAT_RGBA_1010102: + return NATIVEBUFFER_PIXEL_FMT_RGBA_1010102; + case PIXEL_FORMAT_YCBCR_P010: + return NATIVEBUFFER_PIXEL_FMT_YCBCR_P010; + case PIXEL_FORMAT_YCRCB_P010: + return NATIVEBUFFER_PIXEL_FMT_YCRCB_P010; + case PIXEL_FORMAT_ALPHA_8: + case PIXEL_FORMAT_RGBA_F16: + case PIXEL_FORMAT_UNKNOWN: + default: + // no support/unknow format: cannot copy + return 0; + } + return 0; +} + +static bool IsPixelMapYUVFormat(PIXEL_FORMAT format) { + return format == PIXEL_FORMAT_NV21 || format == PIXEL_FORMAT_NV12 || + format == PIXEL_FORMAT_YCBCR_P010 || format == PIXEL_FORMAT_YCRCB_P010; +} + + OHOSExternalTextureGL::OHOSExternalTextureGL(int64_t id, const std::shared_ptr& ohos_surface) : Texture(id), ohos_surface_(std::move(ohos_surface)), transform(SkMatrix::I()) { @@ -410,6 +446,10 @@ void OHOSExternalTextureGL::ProducePixelMapToBackGroundImage() << ret; return; } + + int window_format = PixelMapToWindowFormat((PIXEL_FORMAT)pixelMapInfo.pixelFormat); + ret = OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, SET_FORMAT, window_format); + uint64_t usage = 0; OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, GET_USAGE, &usage); usage |= NATIVEBUFFER_USAGE_CPU_READ; @@ -478,13 +518,22 @@ void OHOSExternalTextureGL::HandlePixelMapBuffer(NativePixelMap* pixelMap, OHNat FML_DLOG(INFO) << "OHOSExternalTextureGL pixelMapInfo rowSize:" << pixelMapInfo.rowSize << " format:" << pixelMapInfo.pixelFormat; + FML_LOG(ERROR)<<"OHOSExternalTextureGL IsPixelMapYUVFormat 0"; + + uint32_t real_height = pixelMapInfo.height; + if (IsPixelMapYUVFormat((PIXEL_FORMAT)pixelMapInfo.pixelFormat)) { + FML_LOG(ERROR)<<"OHOSExternalTextureGL IsPixelMapYUVFormat 1"; + // y is height, uv is height/2 + real_height = pixelMapInfo.height + (pixelMapInfo.height + 1) / 2; + } + // 复制图片纹理数据到内存中,需要处理DMA内存补齐相关的逻辑 if (pixelMapInfo.width * PIXEL_SIZE != pixelMapInfo.rowSize) { // 直接复制整块内存 - memcpy(destAddr, pixel, pixelMapInfo.height * pixelMapInfo.rowSize); + memcpy(destAddr, pixel, real_height * pixelMapInfo.rowSize); } else { // 需要处理DMA内存补齐相关的逻辑 - for (uint32_t i = 0; i < pixelMapInfo.height; i++) { + for (uint32_t i = 0; i < real_height; i++) { memcpy(destAddr, pixel, pixelMapInfo.rowSize); destAddr += stride / PIXEL_SIZE; pixel += pixelMapInfo.width; diff --git a/shell/platform/ohos/ohos_external_texture_gl.h b/shell/platform/ohos/ohos_external_texture_gl.h index 5ac18743a6..2458ac9c54 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.h +++ b/shell/platform/ohos/ohos_external_texture_gl.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include -- Gitee From 388d241eea692a83e22556d41f81ef7491a61375 Mon Sep 17 00:00:00 2001 From: wwyang <137208408@qq.com> Date: Wed, 9 Oct 2024 11:47:03 +0800 Subject: [PATCH 10/22] =?UTF-8?q?=E8=A7=A3=E5=86=B3YUV10bit=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E7=BC=A9=E7=95=A5=E5=9B=BE=E8=8A=B1=E5=B1=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwyang <137208408@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index 966afa007a..ac9f116b78 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -518,11 +518,9 @@ void OHOSExternalTextureGL::HandlePixelMapBuffer(NativePixelMap* pixelMap, OHNat FML_DLOG(INFO) << "OHOSExternalTextureGL pixelMapInfo rowSize:" << pixelMapInfo.rowSize << " format:" << pixelMapInfo.pixelFormat; - FML_LOG(ERROR)<<"OHOSExternalTextureGL IsPixelMapYUVFormat 0"; uint32_t real_height = pixelMapInfo.height; if (IsPixelMapYUVFormat((PIXEL_FORMAT)pixelMapInfo.pixelFormat)) { - FML_LOG(ERROR)<<"OHOSExternalTextureGL IsPixelMapYUVFormat 1"; // y is height, uv is height/2 real_height = pixelMapInfo.height + (pixelMapInfo.height + 1) / 2; } -- Gitee From 3f7f42b91ca42d9ba4fd3c35fd0e1f60b9f2d10e Mon Sep 17 00:00:00 2001 From: wwyang <137208408@qq.com> Date: Wed, 9 Oct 2024 16:52:40 +0800 Subject: [PATCH 11/22] =?UTF-8?q?=E9=97=A8=E7=A6=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwyang <137208408@qq.com> --- shell/platform/ohos/ohos_external_texture_gl.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shell/platform/ohos/ohos_external_texture_gl.cpp b/shell/platform/ohos/ohos_external_texture_gl.cpp index ac9f116b78..05c8449bf5 100755 --- a/shell/platform/ohos/ohos_external_texture_gl.cpp +++ b/shell/platform/ohos/ohos_external_texture_gl.cpp @@ -39,7 +39,8 @@ 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"; -static int PixelMapToWindowFormat(PIXEL_FORMAT pixel_format) { +static int PixelMapToWindowFormat(PIXEL_FORMAT pixel_format) +{ switch (pixel_format) { case PIXEL_FORMAT_RGB_565: return NATIVEBUFFER_PIXEL_FMT_RGB_565; @@ -69,7 +70,8 @@ static int PixelMapToWindowFormat(PIXEL_FORMAT pixel_format) { return 0; } -static bool IsPixelMapYUVFormat(PIXEL_FORMAT format) { +static bool IsPixelMapYUVFormat(PIXEL_FORMAT format) +{ return format == PIXEL_FORMAT_NV21 || format == PIXEL_FORMAT_NV12 || format == PIXEL_FORMAT_YCBCR_P010 || format == PIXEL_FORMAT_YCRCB_P010; } @@ -447,8 +449,8 @@ void OHOSExternalTextureGL::ProducePixelMapToBackGroundImage() return; } - int window_format = PixelMapToWindowFormat((PIXEL_FORMAT)pixelMapInfo.pixelFormat); - ret = OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, SET_FORMAT, window_format); + int windowFormat = PixelMapToWindowFormat((PIXEL_FORMAT)pixelMapInfo.pixelFormat); + ret = OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, SET_FORMAT, windowFormat); uint64_t usage = 0; OH_NativeWindow_NativeWindowHandleOpt(backGroundNativeWindow_, GET_USAGE, &usage); @@ -518,7 +520,6 @@ 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 -- Gitee From 2e9492b727c6b4cabec265fbf3ce7952b114b099 Mon Sep 17 00:00:00 2001 From: houhaoyue Date: Thu, 10 Oct 2024 09:18:47 +0800 Subject: [PATCH 12/22] fix Signed-off-by: houhaoyue --- .../flutter_embedding/flutter/src/main/ets/view/FlutterView.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a1e447533d..0488d6e131 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 @@ -337,7 +337,7 @@ export class FlutterView { } // 根据是否全屏显示,设置标题栏高度(若全屏,则及时规避) - if (this.checkFullScreen && (setFullScreen || this.mainWindow.getWindowProperties().isLayoutFullScreen)) { // 全屏显示 + if (this.checkFullScreen && (setFullScreen || this.mainWindow?.getWindowProperties().isLayoutFullScreen)) { // 全屏显示 this.viewportMetrics.physicalViewPaddingTop = this.systemAvoidArea?.topRect.height ?? 0; this.viewportMetrics.physicalViewPaddingBottom = this.navigationAvoidArea?.bottomRect.height ?? 0; } else { // 非全屏显示(保持规避效果) -- Gitee From a05a3a39e3fc95b51d95dc2c31091fca5fe9e0ee Mon Sep 17 00:00:00 2001 From: houhaoyue Date: Thu, 10 Oct 2024 14:33:36 +0800 Subject: [PATCH 13/22] fix: code check Signed-off-by: houhaoyue --- .../flutter/src/main/ets/view/FlutterView.ets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 0488d6e131..2649e43296 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 @@ -360,7 +360,7 @@ export class FlutterView { private onKeyboardAreaChange() { if (this.checkKeyboard) { - let keyboardAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); + let keyboardAvoidArea: window.AvoidArea | null = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); this.viewportMetrics.physicalViewInsetTop = this.keyboardAvoidArea!.topRect.height this.viewportMetrics.physicalViewInsetLeft = this.keyboardAvoidArea!.leftRect.width this.viewportMetrics.physicalViewInsetBottom = this.keyboardAvoidArea!.bottomRect.height @@ -375,7 +375,7 @@ export class FlutterView { private onGestureAreaChange() { if (this.checkGesture) { - let gestureAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); + let gestureAvoidArea: window.AvoidArea | null = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); this.viewportMetrics.systemGestureInsetTop = this.gestureAvoidArea!.topRect.height this.viewportMetrics.systemGestureInsetLeft = this.gestureAvoidArea!.leftRect.width this.viewportMetrics.systemGestureInsetBottom = this.gestureAvoidArea!.bottomRect.height @@ -392,7 +392,7 @@ export class FlutterView { return this.flutterEngine != null } - private updateViewportMetrics(): boolean{ + private updateViewportMetrics(): boolean { if (this.isAttachedToFlutterEngine()) { this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, this.viewportMetrics.physicalWidth, -- Gitee From efd86c6e94c76a2b69cd1d12c566a0a543626ff3 Mon Sep 17 00:00:00 2001 From: houhaoyue Date: Thu, 10 Oct 2024 17:08:45 +0800 Subject: [PATCH 14/22] fix Signed-off-by: houhaoyue --- .../flutter/src/main/ets/view/FlutterView.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 2649e43296..a508977720 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 @@ -360,7 +360,7 @@ export class FlutterView { private onKeyboardAreaChange() { if (this.checkKeyboard) { - let keyboardAvoidArea: window.AvoidArea | null = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); + let keyboardAvoidArea: window.AvoidArea | undefined = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); this.viewportMetrics.physicalViewInsetTop = this.keyboardAvoidArea!.topRect.height this.viewportMetrics.physicalViewInsetLeft = this.keyboardAvoidArea!.leftRect.width this.viewportMetrics.physicalViewInsetBottom = this.keyboardAvoidArea!.bottomRect.height @@ -375,7 +375,7 @@ export class FlutterView { private onGestureAreaChange() { if (this.checkGesture) { - let gestureAvoidArea: window.AvoidArea | null = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); + let gestureAvoidArea: window.AvoidArea | undefined = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); this.viewportMetrics.systemGestureInsetTop = this.gestureAvoidArea!.topRect.height this.viewportMetrics.systemGestureInsetLeft = this.gestureAvoidArea!.leftRect.width this.viewportMetrics.systemGestureInsetBottom = this.gestureAvoidArea!.bottomRect.height -- Gitee From 66d3e41a7d452c150e0603235effe371fcca7de1 Mon Sep 17 00:00:00 2001 From: houhaoyue Date: Thu, 10 Oct 2024 18:48:32 +0800 Subject: [PATCH 15/22] fix Signed-off-by: houhaoyue --- .../flutter/src/main/ets/view/FlutterView.ets | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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 a508977720..7a15e99e5d 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 @@ -360,11 +360,10 @@ export class FlutterView { private onKeyboardAreaChange() { if (this.checkKeyboard) { - let keyboardAvoidArea: window.AvoidArea | undefined = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); - this.viewportMetrics.physicalViewInsetTop = this.keyboardAvoidArea!.topRect.height - this.viewportMetrics.physicalViewInsetLeft = this.keyboardAvoidArea!.leftRect.width - this.viewportMetrics.physicalViewInsetBottom = this.keyboardAvoidArea!.bottomRect.height - this.viewportMetrics.physicalViewInsetRight = this.keyboardAvoidArea!.rightRect.width + 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 } else { this.viewportMetrics.physicalViewInsetTop = 0 this.viewportMetrics.physicalViewInsetLeft = 0 @@ -375,11 +374,10 @@ export class FlutterView { private onGestureAreaChange() { if (this.checkGesture) { - let gestureAvoidArea: window.AvoidArea | undefined = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); - this.viewportMetrics.systemGestureInsetTop = this.gestureAvoidArea!.topRect.height - this.viewportMetrics.systemGestureInsetLeft = this.gestureAvoidArea!.leftRect.width - this.viewportMetrics.systemGestureInsetBottom = this.gestureAvoidArea!.bottomRect.height - this.viewportMetrics.systemGestureInsetRight = this.gestureAvoidArea!.rightRect.width + 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 } else { this.viewportMetrics.systemGestureInsetTop = 0 this.viewportMetrics.systemGestureInsetLeft = 0 -- Gitee From 02aa5430550b20b586b8431450d522be8c608e20 Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Fri, 11 Oct 2024 16:34:52 +0800 Subject: [PATCH 16/22] =?UTF-8?q?=E5=9B=9E=E9=80=80pr486=E7=9A=84=E4=B8=8D?= =?UTF-8?q?=E5=90=88=E7=90=86=E4=BF=AE=E6=94=B9=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=B8=8D=E5=90=88=E7=90=86=E7=9A=84=E6=96=B9=E6=B3=95=E8=B0=83?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../ets/plugin/editing/TextInputPlugin.ets | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) 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 6a6b814e38..60888e9b95 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 @@ -78,7 +78,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { mEditable: ListenableEditingState; private mRestartInputPending: boolean = false; private plugin: EditingStateWatcher | Any; - private imcFlag: boolean = false; private inputTypeNone: string = 'NONE' private keyboardStatus: inputMethod.KeyboardStatus = inputMethod.KeyboardStatus.HIDE; private inputAttribute: inputMethod.InputAttribute = { textInputType: 0, enterKeyType: 1 } @@ -144,22 +143,11 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { return; } await this.attach(true); - if (!this.imcFlag) { - this.listenKeyBoardEvent(); - } - this.inputMethodController.showTextInput().then(() => { - Log.d(TextInputMethodHandlerImpl.TAG, "Succeeded in showing softKeyboard"); - }).catch((err: Any) => { - Log.e(TextInputMethodHandlerImpl.TAG, "Failed to show softKeyboard:" + JSON.stringify(err)); - }); + this.listenKeyBoardEvent(); } private async hideTextInput(): Promise { - this.inputMethodController.hideTextInput().then(() => { - Log.d(TextInputMethodHandlerImpl.TAG, "Succeeded in hide softKeyboard"); - }).catch((err: Any) => { - Log.e(TextInputMethodHandlerImpl.TAG, "Failed to hide softKeyboard:" + JSON.stringify(err)); - }) + this.inputMethodController.detach(); } async attach(showKeyboard: boolean): Promise { @@ -264,23 +252,19 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { return; } Log.d(TextInputMethodHandlerImpl.TAG, "listenKeyBoardEvent success"); - this.imcFlag = true; } private insertTextCallback = (text: string) => { Log.d(TextInputMethodHandlerImpl.TAG, "insertText: " + text); this.mEditable.handleInsertTextEvent(text); - this.changeSelection(); } private deleteLeftCallback = (length: number) => { this.mEditable.handleDeleteEvent(false, length); - this.changeSelection(); } private deleteRightCallback = (length: number) => { this.mEditable.handleDeleteEvent(true, length); - this.changeSelection(); } private sendFunctionKeyCallback = (functionKey: inputMethod.FunctionKey) => { @@ -304,14 +288,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.mEditable.handleSelectByRange(range); } - changeSelection(): void { - try { - this.inputMethodController.changeSelection(this.mEditable.getStringCache(), this.mEditable.getSelectionStart(), this.mEditable.getSelectionEnd()); - } catch (err) { - Log.e(TextInputMethodHandlerImpl.TAG, "Failed to changeSelection:" + JSON.stringify(err)); - } - } - cancelListenKeyBoardEvent(): void { this.inputMethodController.off('insertText', this.insertTextCallback); this.inputMethodController.off('deleteLeft', this.deleteLeftCallback); @@ -319,8 +295,6 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.inputMethodController.off('sendFunctionKey', this.sendFunctionKeyCallback); this.inputMethodController.off('sendKeyboardStatus', this.sendKeyboardStatusCallback); this.inputMethodController.off('selectByRange', this.selectByRangeCallback); - this.imcFlag = false; - this.inputMethodController.detach() } public clearTextInputClient(): void { -- Gitee From f2c4e1ee0fc2a7cdbf3a9f26c727732dddd2afd2 Mon Sep 17 00:00:00 2001 From: SimpleLove520 <1960997571@qq.com> Date: Fri, 11 Oct 2024 20:48:46 +0800 Subject: [PATCH 17/22] =?UTF-8?q?=E5=87=8F=E5=B0=91resize=E6=97=B6Platform?= =?UTF-8?q?View=E6=8B=89=E4=BC=B8=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SimpleLove520 <1960997571@qq.com> --- .../src/main/ets/plugin/platform/PlatformViewsController.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 8afcd87043..c3fd15e16e 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 @@ -89,7 +89,7 @@ export default class PlatformViewsController implements PlatformViewsAccessibili private platformViewParent: Map; private nodeControllers: Stack; private viewPhysicalInfo: Map = new Map(); - private dValue: number = 3; + private dValue: number = 1; constructor() { this.registry = new PlatformViewRegistryImpl(); @@ -188,7 +188,7 @@ export default class PlatformViewsController implements PlatformViewsAccessibili let oldPhysicalHeight: number = 0; if (this.viewPhysicalInfo.has(viewId)) { oldPhysicalHeight = this.viewPhysicalInfo.get(viewId) as number; - //高度变化小于3,不做刷新处理,减少闪烁 + //高度变化小于1,不做刷新处理,减少闪烁 if (physicalHeight - oldPhysicalHeight < this.dValue) { this.setParams(params!, "width", physicalWidth); -- Gitee From 01816ef0623f811d5863acf82d8c8a6c5c2a8c1b Mon Sep 17 00:00:00 2001 From: zjxi Date: Fri, 11 Oct 2024 20:51:58 +0800 Subject: [PATCH 18/22] =?UTF-8?q?feat:=E6=97=A0=E9=9A=9C=E7=A2=8D=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E7=B2=97=E7=BB=86=E9=9C=80=E6=B1=82=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zjxi --- shell/platform/ohos/BUILD.gn | 2 + .../ohos_accessibility_features.cpp | 58 +++++++++++++++++++ .../ohos_accessibility_features.h | 43 ++++++++++++++ .../src/main/cpp/types/libflutter/index.d.ets | 24 +++++++- .../main/ets/embedding/engine/FlutterNapi.ets | 22 ++++++- .../ets/embedding/ohos/FlutterAbility.ets | 7 +++ .../src/main/ets/view/AccessibilityBridge.ets | 25 ++++++++ shell/platform/ohos/library_loader.cpp | 16 ++++- .../ohos/napi/platform_view_ohos_napi.cpp | 53 +++++++++++++++++ .../ohos/napi/platform_view_ohos_napi.h | 22 +++++-- 10 files changed, 263 insertions(+), 9 deletions(-) create mode 100644 shell/platform/ohos/accessibility/ohos_accessibility_features.cpp create mode 100644 shell/platform/ohos/accessibility/ohos_accessibility_features.h diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 689f5015c2..c8e36f5796 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -84,6 +84,7 @@ source_set("flutter_ohos_sources") { "ohos_surface_gl_skia.h", "types.h", "ohos_logging.h", + "./accessibility/ohos_accessibility_features.h", ] #configs += [ "//flutter/shell/platform/ohos/config:gtk" ] @@ -114,6 +115,7 @@ source_set("flutter_ohos_sources") { "ohos_image_generator.cpp", "ohos_external_texture_gl.cpp", "./surface/ohos_snapshot_surface_producer.cpp", + "./accessibility/ohos_accessibility_features.cpp", ] # Set flag to stop headers being directly included (library users should not do this) diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp b/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp new file mode 100644 index 0000000000..caea517fee --- /dev/null +++ b/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp @@ -0,0 +1,58 @@ +/* + * 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. + */ +#include "flutter/shell/platform/ohos/accessibility/ohos_accessibility_features.h" +#include "flutter/shell/platform/ohos/ohos_shell_holder.h" +#include "flutter/fml/logging.h" + +namespace flutter { + + OhosAccessibilityFeatures OhosAccessibilityFeatures::instance; + + OhosAccessibilityFeatures::OhosAccessibilityFeatures() {}; + OhosAccessibilityFeatures::~OhosAccessibilityFeatures() {}; + + OhosAccessibilityFeatures* OhosAccessibilityFeatures::GetInstance() { + return &OhosAccessibilityFeatures::instance; + } + + /** + * bold text for AccessibilityFeature + */ + void OhosAccessibilityFeatures::SetBoldText(double fontWeightScale, int64_t shell_holder_id) { + bool shouldBold = fontWeightScale > 1.0; + + if (shouldBold) { + accessibilityFeatureFlags |= static_cast(flutter::AccessibilityFeatureFlag::kBoldText); + FML_DLOG(INFO) << "SetBoldText -> accessibilityFeatureFlags: "<(flutter::AccessibilityFeatureFlag::kBoldText); + } + + SendAccessibilityFlags(shell_holder_id); + } + + /** + * send the accessibility flags to flutter dart sdk + */ + void OhosAccessibilityFeatures::SendAccessibilityFlags(int64_t shell_holder_id) { + auto ohos_shell_holder = reinterpret_cast(shell_holder_id); + ohos_shell_holder->GetPlatformView()->PlatformView::SetAccessibilityFeatures(accessibilityFeatureFlags); + FML_DLOG(INFO) << "SendAccessibilityFlags -> accessibilityFeatureFlags = " + << accessibilityFeatureFlags; + accessibilityFeatureFlags = 0; + } + +} \ No newline at end of file diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_features.h b/shell/platform/ohos/accessibility/ohos_accessibility_features.h new file mode 100644 index 0000000000..093e89ce11 --- /dev/null +++ b/shell/platform/ohos/accessibility/ohos_accessibility_features.h @@ -0,0 +1,43 @@ +/* + * 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. + */ +#ifndef OHOS_ACCESSIBILITY_FEATURES_H +#define OHOS_ACCESSIBILITY_FEATURES_H +#include +#include "flutter/lib/ui/window/platform_configuration.h" +#include "flutter/shell/platform/ohos/napi/platform_view_ohos_napi.h" + +namespace flutter { + +class OhosAccessibilityFeatures { + public: + OhosAccessibilityFeatures(); + ~OhosAccessibilityFeatures(); + + static OhosAccessibilityFeatures* GetInstance(); + + void SetBoldText(double fontWeightScale, int64_t shell_holder_id); + void SendAccessibilityFlags(int64_t shell_holder_id); + + private: + static OhosAccessibilityFeatures instance; + + // Font weight adjustment (FontWeight.Bold - FontWeight.Normal = w700 - w400 = 300) + static const int32_t BOLD_TEXT_WEIGHT_ADJUSTMENT = 300; + int32_t accessibilityFeatureFlags = 0; +}; + +} + +#endif \ No newline at end of file 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 53a5eabeca..0cf14a41b0 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 @@ -17,6 +17,7 @@ import common from '@ohos.app.ability.common'; import resourceManager from '@ohos.resourceManager'; import image from '@ohos.multimedia.image'; import FlutterNapi from '../../../ets/embedding/engine/FlutterNapi'; +import { ByteBuffer } from '../../../ets/util/ByteBuffer'; import { FlutterCallbackInformation } from '../../../ets/view/FlutterCallbackInformation'; export const getContext: (a: number) => napiContext; @@ -110,6 +111,12 @@ export const nativeXComponentDispatchMouseWheel: (nativeShellHolderId: number, timestamp: number ) => void; + +// send updateSemantics and updateCustomAccessibilityActions from ets to c++ +export const nativeUpdateSemantics: (buffer: ByteBuffer, strings: string[], stringAttributeArgs: ByteBuffer[]) => void; +export const nativeUpdateCustomAccessibilityActions: (buffer: ByteBuffer, strings: string[]) => void; + + /** * Detaches flutterNapi和engine之间的关联 * 这个方法执行前提是flutterNapi已经和engine关联 @@ -134,4 +141,19 @@ export const nativeDecodeUtf8: (array: Uint8Array) => string; export const nativeSetTextureBufferSize: (nativeShellHolderId: number, textureId: number, width: number, height: number) => void; -export const nativeLookupCallbackInformation: (callback: FlutterCallbackInformation, handler: number) => number; \ No newline at end of file +/** + * accessibiltyChannel中的 + */ +export const nativeSetAccessibilityFeatures: (accessibilityFeatureFlags: number, responseId: number) => void; + +export const nativeAccessibilityStateChange: (state: Boolean) => void; + +export const nativeAnnounce: (message: string) => void; + +export const nativeSetSemanticsEnabled: (nativeShellHolderId: number, enabled: boolean) => void; + +export const nativeSetFontWeightScale: (nativeShellHolderId: number, fontWeightScale: number) => void; + +export const nativeGetShellHolderId: (nativeShellHolderId: number) => void; + +export const nativeLookupCallbackInformation: (callback: FlutterCallbackInformation, handler: number) => number; 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 78f1a520e7..787722ab06 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 @@ -22,7 +22,7 @@ import { FlutterCallbackInformation } from '../../view/FlutterCallbackInformatio import image from '@ohos.multimedia.image'; import { EngineLifecycleListener } from './FlutterEngine'; import { ByteBuffer } from '../../util/ByteBuffer'; -import { Action } from '../../view/AccessibilityBridge' +import { AccessibilityManager, Action } from '../../view/AccessibilityBridge' import LocalizationPlugin from '../../plugin/localization/LocalizationPlugin'; import i18n from '@ohos.i18n'; import Any from '../../plugin/common/Any'; @@ -54,6 +54,9 @@ export default class FlutterNapi { localizationPlugin: LocalizationPlugin | null = null; isDisplayingFlutterUi: boolean = false; + accessibilityManager: AccessibilityManager | null = null; + + /** * 更新刷新率 * @param rate @@ -502,6 +505,23 @@ export default class FlutterNapi { } } + getShellHolderId(): void { + this.ensureRunningOnMainThread(); + if (this.isAttached()) { + flutter.nativeGetShellHolderId(this.nativeShellHolderId!); + } + } + + setFontWeightScale(fontWeightScale: number): void { + this.ensureRunningOnMainThread(); + if (this.isAttached()) { + Log.i(TAG, "setFontWeightScale: " + fontWeightScale); + flutter.nativeSetFontWeightScale(this.nativeShellHolderId!, fontWeightScale); + } else { + Log.w(TAG, "setFontWeightScale is detached !"); + } + } + } export interface AccessibilityDelegate { 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 8ba4463178..5904485da1 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 @@ -36,6 +36,7 @@ import appRecovery from '@ohos.app.ability.appRecovery'; import FlutterManager from './FlutterManager'; import { FlutterView } from '../../view/FlutterView'; import ApplicationInfoLoader from '../engine/loader/ApplicationInfoLoader'; +import { AccessibilityManager } from '../../view/AccessibilityBridge'; const TAG = "FlutterAbility"; const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS'; @@ -51,6 +52,7 @@ export class FlutterAbility extends UIAbility implements Host { private flutterView: FlutterView | null = null; private mainWindow?: window.Window | null; private errorManagerId:number = 0; + private accessibilityManager?: AccessibilityManager | null; getFlutterView(): FlutterView | null { return this.flutterView; @@ -377,6 +379,11 @@ export class FlutterAbility extends UIAbility implements Host { .setTextScaleFactor(config.fontSizeScale == undefined? 1.0 : config.fontSizeScale) .send(); //热启动生命周期内,实时监听系统设置环境改变并实时发送相应信息 + //实时获取系统字体加粗系数 + // this.accessibilityManager?.setFontWeightScale(config.fontWeightScale == undefined? 0 : config.fontWeightScale); + this.delegate?.getFlutterNapi()?.setFontWeightScale(config.fontWeightScale == undefined? 0 : config.fontWeightScale); + Log.i(TAG, 'fontWeightScale: ' + JSON.stringify(config.fontWeightScale)); + if (config.language != '') { this.getFlutterEngine()?.getLocalizationPlugin()?.sendLocaleToFlutter(); } 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 0e08f41fe9..e5a9c5bfab 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 @@ -12,11 +12,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import AccessibilityChannel from '../embedding/engine/systemchannels/AccessibilityChannel'; +import { ByteBuffer } from '../util/ByteBuffer'; +import Log from '../util/Log'; + +const TAG = "AccessibilityBridge"; export default class AccessibilityBridge { + + private accessibilityChannel: AccessibilityChannel | null = null; + constructor(){ } + + + +} + +export class AccessibilityManager { + private fontWeightScale: number | null = null; + + setFontWeightScale(fontWeightScale: number): void { + this.fontWeightScale = fontWeightScale; + Log.i(TAG, 'setFontWeightScale: ' + JSON.stringify(this.fontWeightScale)); + } + + getFontWeightScale(): number { + Log.i(TAG, 'getFontWeightScale: ' + JSON.stringify(this.fontWeightScale)); + return this.fontWeightScale!; + } } export enum Action { diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 473feb562e..f596341474 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -132,9 +132,21 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION( "nativeSetTextureBackGroundPixelMap", flutter::PlatformViewOHOSNapi::nativeSetTextureBackGroundPixelMap), + DECLARE_NAPI_FUNCTION("nativeEncodeUtf8", + flutter::PlatformViewOHOSNapi::nativeEncodeUtf8), + DECLARE_NAPI_FUNCTION("nativeDecodeUtf8", + flutter::PlatformViewOHOSNapi::nativeDecodeUtf8), DECLARE_NAPI_FUNCTION( - "nativeEncodeUtf8", - flutter::PlatformViewOHOSNapi::nativeEncodeUtf8), + "nativeUpdateSemantics", + flutter::PlatformViewOHOSNapi::nativeUpdateSemantics), + DECLARE_NAPI_FUNCTION( + "nativeUpdateCustomAccessibilityActions", + flutter::PlatformViewOHOSNapi::nativeUpdateCustomAccessibilityActions), + + DECLARE_NAPI_FUNCTION( + "nativeSetFontWeightScale", + flutter::PlatformViewOHOSNapi::nativeSetFontWeightScale), + DECLARE_NAPI_FUNCTION( "nativeDecodeUtf8", flutter::PlatformViewOHOSNapi::nativeDecodeUtf8), diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index d46617ef3a..102a162404 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1798,6 +1798,59 @@ napi_value PlatformViewOHOSNapi::nativeDecodeUtf8(napi_env env, napi_callback_in return result; } +napi_value PlatformViewOHOSNapi::nativeUpdateSemantics( + napi_env env, + napi_callback_info info) { + // TODO ets calls c++ + + return nullptr; +} + +napi_value PlatformViewOHOSNapi::nativeUpdateCustomAccessibilityActions( + napi_env env, + napi_callback_info info) { + // TODO ets calls c++ + + return nullptr; +} + + + + +napi_value PlatformViewOHOSNapi::nativeSetFontWeightScale(napi_env env, napi_callback_info info) { + napi_status ret; + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + // get param nativeShellHolderId + int64_t shell_holder; + ret = napi_get_value_int64(env, args[0], &shell_holder); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "PlatformViewOHOSNapi::nativeSetFontWeightScale " + "napi_get_value_int64 error:" + << ret; + return nullptr; + } + //get param fontWeightScale + double fontWeightScale = 1.0; + ret = napi_get_value_double(env, args[1], &fontWeightScale); + if (ret != napi_ok) { + FML_DLOG(ERROR) << "PlatformViewOHOSNapi::nativeSetFontWeightScale " + "napi_get_value_double error:" + << ret; + return nullptr; + } + // accessibility features get the params + auto ohosAccessibilityFeatures = OhosAccessibilityFeatures::GetInstance(); + ohosAccessibilityFeatures->SetBoldText(fontWeightScale, shell_holder); + FML_DLOG(INFO) << "PlatformViewOHOSNapi::nativeSetFontWeightScale -> shell_holder: " + << shell_holder + << " fontWeightScale: "<< fontWeightScale; + return nullptr; +} + + + napi_value PlatformViewOHOSNapi::nativeLookupCallbackInformation(napi_env env, napi_callback_info info) { napi_value result; diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.h b/shell/platform/ohos/napi/platform_view_ohos_napi.h index 9ca6b6f90b..4cbe6cd572 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.h +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.h @@ -28,6 +28,9 @@ #include "flutter/shell/common/run_configuration.h" #include "flutter/shell/platform/ohos/napi_common.h" #include "napi/native_api.h" + +#include "flutter/shell/platform/ohos/accessibility/ohos_accessibility_features.h" + // class for all c++ to call js function namespace flutter { @@ -199,15 +202,24 @@ class PlatformViewOHOSNapi { static napi_value nativeXComponentDetachFlutterEngine( napi_env env, napi_callback_info info); - static napi_value nativeXComponentDispatchMouseWheel( - napi_env env, - napi_callback_info info); - static napi_value nativeEncodeUtf8( + static napi_value nativeXComponentDispatchMouseWheel(napi_env env, + napi_callback_info info); + static napi_value nativeEncodeUtf8(napi_env env, napi_callback_info info); + static napi_value nativeDecodeUtf8(napi_env env, napi_callback_info info); + + /** + * ets call c++ + */ + static napi_value nativeUpdateSemantics(napi_env env, + napi_callback_info info); + static napi_value nativeUpdateCustomAccessibilityActions( napi_env env, napi_callback_info info); - static napi_value nativeDecodeUtf8( + + static napi_value nativeSetFontWeightScale( napi_env env, napi_callback_info info); + static napi_value nativeLookupCallbackInformation( napi_env env, napi_callback_info info); -- Gitee From 4382cc3108927083c43f64e2ee1e1ee64bf40b8c Mon Sep 17 00:00:00 2001 From: zjxi Date: Fri, 11 Oct 2024 21:10:16 +0800 Subject: [PATCH 19/22] =?UTF-8?q?fix:=E5=AE=8C=E5=96=84=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zjxi --- .../ohos/accessibility/ohos_accessibility_features.cpp | 1 - .../platform/ohos/accessibility/ohos_accessibility_features.h | 3 +-- shell/platform/ohos/napi/platform_view_ohos_napi.cpp | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp b/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp index caea517fee..a99bcbd96d 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp +++ b/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp @@ -54,5 +54,4 @@ namespace flutter { << accessibilityFeatureFlags; accessibilityFeatureFlags = 0; } - } \ No newline at end of file diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_features.h b/shell/platform/ohos/accessibility/ohos_accessibility_features.h index 093e89ce11..b6abf906b0 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_features.h +++ b/shell/platform/ohos/accessibility/ohos_accessibility_features.h @@ -37,7 +37,6 @@ class OhosAccessibilityFeatures { static const int32_t BOLD_TEXT_WEIGHT_ADJUSTMENT = 300; int32_t accessibilityFeatureFlags = 0; }; - + } - #endif \ No newline at end of file diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index 102a162404..b78d86d0b8 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1801,7 +1801,6 @@ napi_value PlatformViewOHOSNapi::nativeDecodeUtf8(napi_env env, napi_callback_in napi_value PlatformViewOHOSNapi::nativeUpdateSemantics( napi_env env, napi_callback_info info) { - // TODO ets calls c++ return nullptr; } @@ -1809,7 +1808,6 @@ napi_value PlatformViewOHOSNapi::nativeUpdateSemantics( napi_value PlatformViewOHOSNapi::nativeUpdateCustomAccessibilityActions( napi_env env, napi_callback_info info) { - // TODO ets calls c++ return nullptr; } -- Gitee From cb70e81753cd06dc382524289bca21f1ef38e9ed Mon Sep 17 00:00:00 2001 From: zjxi Date: Sat, 12 Oct 2024 11:02:57 +0800 Subject: [PATCH 20/22] =?UTF-8?q?refactor:=E5=AE=8C=E5=96=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83=EF=BC=8C=E8=A1=A5=E5=85=85=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zjxi --- .../ohos/accessibility/ohos_accessibility_features.cpp | 2 ++ .../flutter/src/main/ets/view/AccessibilityBridge.ets | 7 +------ shell/platform/ohos/napi/platform_view_ohos_napi.cpp | 8 +++----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp b/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp index a99bcbd96d..6953998fe3 100644 --- a/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp +++ b/shell/platform/ohos/accessibility/ohos_accessibility_features.cpp @@ -52,6 +52,8 @@ namespace flutter { ohos_shell_holder->GetPlatformView()->PlatformView::SetAccessibilityFeatures(accessibilityFeatureFlags); FML_DLOG(INFO) << "SendAccessibilityFlags -> accessibilityFeatureFlags = " << accessibilityFeatureFlags; + // set accessibility feature flag to 0 accessibilityFeatureFlags = 0; } + } \ No newline at end of file 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 e5a9c5bfab..cff9525630 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 @@ -22,12 +22,7 @@ export default class AccessibilityBridge { private accessibilityChannel: AccessibilityChannel | null = null; - constructor(){ - - } - - - + constructor(){} } export class AccessibilityManager { diff --git a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp index b78d86d0b8..2594687c15 100644 --- a/shell/platform/ohos/napi/platform_view_ohos_napi.cpp +++ b/shell/platform/ohos/napi/platform_view_ohos_napi.cpp @@ -1812,9 +1812,9 @@ napi_value PlatformViewOHOSNapi::nativeUpdateCustomAccessibilityActions( return nullptr; } - - - +/** + * 无障碍特征之字体加粗功能,获取ets侧系统字体粗细系数 + */ napi_value PlatformViewOHOSNapi::nativeSetFontWeightScale(napi_env env, napi_callback_info info) { napi_status ret; size_t argc = 2; @@ -1847,8 +1847,6 @@ napi_value PlatformViewOHOSNapi::nativeSetFontWeightScale(napi_env env, napi_cal return nullptr; } - - napi_value PlatformViewOHOSNapi::nativeLookupCallbackInformation(napi_env env, napi_callback_info info) { napi_value result; -- Gitee From 7541d65894132268b745d5e386c8ab1c3f463266 Mon Sep 17 00:00:00 2001 From: zjxi Date: Sat, 12 Oct 2024 13:00:42 +0800 Subject: [PATCH 21/22] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zjxi --- .../flutter/src/main/ets/embedding/ohos/FlutterAbility.ets | 1 - 1 file changed, 1 deletion(-) 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 5904485da1..4013fed189 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 @@ -380,7 +380,6 @@ export class FlutterAbility extends UIAbility implements Host { .send(); //热启动生命周期内,实时监听系统设置环境改变并实时发送相应信息 //实时获取系统字体加粗系数 - // this.accessibilityManager?.setFontWeightScale(config.fontWeightScale == undefined? 0 : config.fontWeightScale); this.delegate?.getFlutterNapi()?.setFontWeightScale(config.fontWeightScale == undefined? 0 : config.fontWeightScale); Log.i(TAG, 'fontWeightScale: ' + JSON.stringify(config.fontWeightScale)); -- Gitee From 6ba65294b9ae1a206e16054a4189a4920f0c9aee Mon Sep 17 00:00:00 2001 From: changleipeng Date: Mon, 21 Oct 2024 17:18:57 +0800 Subject: [PATCH 22/22] test --- BUILD.gn | 1 + shell/platform/ohos/BUILD.gn | 10 +++++++ .../ohos/testing/ohos_assert_provider_test.cc | 30 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 shell/platform/ohos/testing/ohos_assert_provider_test.cc diff --git a/BUILD.gn b/BUILD.gn index 7a102d594b..66d7f4ee30 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -152,6 +152,7 @@ group("unittests") { "//flutter/runtime:no_dart_plugin_registrant_unittests", "//flutter/runtime:runtime_unittests", "//flutter/shell/common:shell_unittests", + "//flutter/shell/platform/ohos:flutter_ohos_unittests", "//flutter/shell/platform/embedder:embedder_a11y_unittests", "//flutter/shell/platform/embedder:embedder_proctable_unittests", "//flutter/shell/platform/embedder:embedder_unittests", diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index c8e36f5796..3b1b9c21c2 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -176,6 +176,7 @@ executable("flutter_ohos_unittests") { sources = [ #"testing/mock_texture_registrar.cc", + "testing/ohos_assert_provider_test.cc" ] public_configs = [ "//flutter:config" ] @@ -197,6 +198,15 @@ executable("flutter_ohos_unittests") { "//flutter/shell/platform/embedder:embedder_test_utils", "//flutter/testing", ] + + ldflags = ["-lace_ndk.z"] + ldflags += ["-lnative_window"] + ldflags += ["-lnative_vsync"] + ldflags += ["-limage_ndk.z"] + ldflags += ["-lrawfile.z"] + ldflags += ["-lnative_image"] + ldflags += ["-lpixelmap_ndk.z"] + ldflags += ["-lqos"] } shared_library("flutter_shell_native") { diff --git a/shell/platform/ohos/testing/ohos_assert_provider_test.cc b/shell/platform/ohos/testing/ohos_assert_provider_test.cc new file mode 100644 index 0000000000..2a67bc5a1c --- /dev/null +++ b/shell/platform/ohos/testing/ohos_assert_provider_test.cc @@ -0,0 +1,30 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include + +#include "gtest/gtest.h" +#include "gmock/gmock.h" + +#include "../ohos_asset_provider.h" + +TEST(OHOSAssetProviderTest, Build001) { + std::shared_ptr provider = std::make_shared(nullptr); + EXPECT_EQ(provider, nullptr); +} -- Gitee