From 537ba6bb349718181ee964c09e8d1969fe7124b7 Mon Sep 17 00:00:00 2001 From: keminLuo Date: Tue, 7 Jan 2025 20:48:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Flutter=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=86=85=E6=BB=91=E5=8A=A8=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: keminLuo --- .../engine/systemchannels/PlatformChannel.ets | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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 caf39c4916..32615eee23 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 @@ -13,6 +13,7 @@ * limitations under the License. */ +import hiTraceMeter form '@ohos.hiTraceMeter'; import JSONMethodCodec from '../../../plugin/common/JSONMethodCodec'; import MethodCall from '../../../plugin/common/MethodCall'; import MethodChannel, { MethodCallHandler, MethodResult } from '../../../plugin/common/MethodChannel'; @@ -175,6 +176,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 +294,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 +407,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 +496,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; + } + } } -- Gitee From b35924516da60cf6154465b64f0cc8f6d16b7327 Mon Sep 17 00:00:00 2001 From: keminLuo Date: Tue, 18 Feb 2025 14:44:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: keminLuo --- .../ets/embedding/engine/systemchannels/PlatformChannel.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 32615eee23..445cd3ebd5 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 @@ -13,7 +13,7 @@ * limitations under the License. */ -import hiTraceMeter form '@ohos.hiTraceMeter'; +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'; -- Gitee