diff --git a/attachment/scripts/__init__ .py b/attachment/scripts/__init__.py similarity index 100% rename from attachment/scripts/__init__ .py rename to attachment/scripts/__init__.py diff --git a/build/dart/rules.gni b/build/dart/rules.gni index 00b801b2c204f4a0cdecace2803ec78bf1963baa..c239d536c13fbaf70b242396b5543ae0c2ec3886 100644 --- a/build/dart/rules.gni +++ b/build/dart/rules.gni @@ -149,6 +149,18 @@ template("flutter_snapshot") { "--snapshot_kind=app-aot-elf", "--elf=" + rebase_path(libapp), ] + } else if (is_ohos) { + if (defined(invoker.output_aot_lib)) { + output_aot_lib = invoker.output_aot_lib + } else { + output_aot_lib = "libapp.so" + } + libapp = "$target_gen_dir/ohos/libs/$output_aot_lib" + outputs += [ libapp ] + args += [ + "--snapshot_kind=app-aot-elf", + "--elf=" + rebase_path(libapp), + ] } else { assert(false) } diff --git a/lib/ui/platform_dispatcher.dart b/lib/ui/platform_dispatcher.dart index 03bcc662c3026f0b81593e0a06075d7c4913f66a..392062ebdec3f8ed079ff443f42ad5ed02da4eba 100644 --- a/lib/ui/platform_dispatcher.dart +++ b/lib/ui/platform_dispatcher.dart @@ -335,7 +335,7 @@ class PlatformDispatcher { // Called from the engine, via hooks.dart void _drawFrame() { - print("platform_dispatcher::drawFrame..${_onDrawFrame}") ; + // print("platform_dispatcher::drawFrame..${_onDrawFrame}") ; _invoke(onDrawFrame, _onDrawFrameZone); } diff --git a/shell/platform/ohos/BUILD.gn b/shell/platform/ohos/BUILD.gn index 025ddff432d9524fa10dd031c8e1d567f1115de0..8d18085468e772ad3fbb9ab6c40482c61e7fb387 100644 --- a/shell/platform/ohos/BUILD.gn +++ b/shell/platform/ohos/BUILD.gn @@ -195,6 +195,10 @@ executable("flutter_ohos_unittests") { shared_library("flutter") { deps = [ ":flutter_ohos_src" ] + if (flutter_runtime_mode == "profile") { + deps += [ "//flutter/shell/vmservice:vmservice_snapshot" ] + } + ldflags = ["--rtlib=compiler-rt", "-fuse-ld=lld", "-static-libstdc++", @@ -222,7 +226,6 @@ shared_library("flutter") { ldflags += ["-lpthread"] ldflags += ["-lpixelmap_ndk.z"] - public_configs = [ "//flutter:config" ] } 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 615dac78fbc63252a13e2b485dde37c9ffdacbac..d4892d51cd61a2e7aad20ba4fd7eae053a6d63c1 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 @@ -129,21 +129,16 @@ export default class PlatformChannel { getClipboardContentFormatFromValue(encodedName: string): ClipboardContentFormat { let clipboardFormats : string[]= [ClipboardContentFormat.PLAIN_TEXT]; - for (let i = 0; i < clipboardFormats.length; i++) { - let format = clipboardFormats[i]; - if (ClipboardContentFormat[format] === encodedName) { - return ClipboardContentFormat[format]; - } + if (clipboardFormats.includes(encodedName as ClipboardContentFormat)) { + return encodedName as ClipboardContentFormat; } return ClipboardContentFormat.PLAIN_TEXT; } + getSystemUiOverlayFromValue(encodedName: string): SystemUiOverlay { let systemUiOverlays : string[] = [SystemUiOverlay.TOP_OVERLAYS, SystemUiOverlay.BOTTOM_OVERLAYS]; - for (let i = 0; i < systemUiOverlays.length; i++) { - let overlay = systemUiOverlays[i]; - if (SystemUiOverlay[overlay] === encodedName) { - return SystemUiOverlay[overlay]; - } + if (systemUiOverlays.includes(encodedName as SystemUiOverlay)) { + return encodedName as SystemUiOverlay; } throw new Error("No such SystemUiOverlay: " + encodedName); } @@ -153,36 +148,27 @@ export default class PlatformChannel { SystemUiMode.LEAN_BACK, SystemUiMode.IMMERSIVE, SystemUiMode.IMMERSIVE_STICKY, SystemUiMode.EDGE_TO_EDGE ]; - for (let i = 0; i < systemUiModes.length; i++) { - let mode = systemUiModes[i]; - if (SystemUiMode[mode] === encodedName) { - return SystemUiMode[mode]; - } + if (systemUiModes.includes(encodedName as SystemUiMode)) { + return encodedName as SystemUiMode; } throw new Error("No such SystemUiOverlay: " + encodedName); } getBrightnessFromValue(encodedName: string): Brightness { let brightnesses : string[] = [Brightness.LIGHT, Brightness.DARK]; - for (let i = 0; i < brightnesses.length; i++) { - let brightness = brightnesses[i]; - if (Brightness[brightness] === encodedName) { - return Brightness[brightness]; - } + if (brightnesses.includes(encodedName as Brightness)) { + return encodedName as Brightness; } throw new Error("No such Brightness: " + encodedName); } getDeviceOrientationFromValue(encodedName: string): DeviceOrientation { - let deviceOrientations: string[] = [ + let deviceOrientations: DeviceOrientation[] = [ DeviceOrientation.PORTRAIT_UP, DeviceOrientation.PORTRAIT_DOWN, DeviceOrientation.LANDSCAPE_LEFT, DeviceOrientation.LANDSCAPE_RIGHT ]; - for (let i = 0; i < deviceOrientations.length; i++) { - let orientation = deviceOrientations[i]; - if (DeviceOrientation[orientation] === encodedName) { - return DeviceOrientation[orientation]; - } + if (deviceOrientations.includes(encodedName as DeviceOrientation)) { + return encodedName as DeviceOrientation; } throw new Error("No such DeviceOrientation: " + encodedName); } diff --git a/shell/platform/ohos/library_loader.cpp b/shell/platform/ohos/library_loader.cpp index 6eddfb8e806f468ed787f93945404f964aba3f91..7f88815b7b7ed605a21148ed09d36c686ad3ec04 100644 --- a/shell/platform/ohos/library_loader.cpp +++ b/shell/platform/ohos/library_loader.cpp @@ -23,7 +23,7 @@ EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { - FML_DLOG(INFO) << "Flutter Init NAPI"; + FML_DLOG(INFO) << "Init NAPI Start."; napi_property_descriptor desc[] = { DECLARE_NAPI_FUNCTION("nativeInit", flutter::OhosMain::NativeInit), DECLARE_NAPI_FUNCTION( @@ -106,7 +106,9 @@ static napi_value Init(napi_env env, napi_value exports) { napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); bool ret = flutter::XComponentAdapter::GetInstance()->Export(env, exports); if (!ret) { - FML_DLOG(INFO) << "Flutter Init Failed"; + LOGE("Init NAPI Failed."); + } else { + FML_DLOG(INFO) << "Init NAPI Succeed."; } return exports; } diff --git a/shell/platform/ohos/ohos_main.cpp b/shell/platform/ohos/ohos_main.cpp index a367e1114d468f5ea57089f34b47568028dff3b6..ddc429e0b4e20da1aa3dfa307cc3b8726c883415 100644 --- a/shell/platform/ohos/ohos_main.cpp +++ b/shell/platform/ohos/ohos_main.cpp @@ -137,7 +137,7 @@ void OhosMain::Init(napi_env env, napi_callback_info info) { }; settings.log_message_callback = [](const std::string& tag, const std::string& message) { - FML_DLOG(INFO) << tag << " " << message; + LOGI("%{public}s %{public}s", tag.c_str(), message.c_str()); }; g_flutter_main.reset(new OhosMain(settings));