diff --git a/packages/flutter_tools/lib/src/ohos/hvigor.dart b/packages/flutter_tools/lib/src/ohos/hvigor.dart index cb07a97e40bda968ee0689359aaf687162247b77..804746becede21d68353ebc0bb6e5faec4dd2a63 100644 --- a/packages/flutter_tools/lib/src/ohos/hvigor.dart +++ b/packages/flutter_tools/lib/src/ohos/hvigor.dart @@ -47,6 +47,8 @@ const String FLUTTER_ASSETS_PATH = 'flutter_assets'; const String FLUTTER_ENGINE_SO = 'libflutter.so'; +const String VMSERVICE_SNAPSHOT_SO = 'libvmservice_snapshot.so'; + const String APP_SO_ORIGIN = 'app.so'; const String APP_SO = 'libapp.so'; @@ -95,6 +97,14 @@ String getEngineSoPath(String ohosRootPath, TargetPlatform targetPlatform, FLUTTER_ENGINE_SO); } +/// eg:entry/libs/arm64-v8a/libvmservice_snapshot.so +String getVmServiceSoDest(String ohosRootPath, TargetPlatform targetPlatform, + OhosProject ohosProject) { + return globals.fs.path.join( + getProjectArchPath(ohosRootPath, targetPlatform, ohosProject), + VMSERVICE_SNAPSHOT_SO); +} + /// eg:entry/libs/arm64-v8a/libapp.so String getAppSoPath(String ohosRootPath, TargetPlatform targetPlatform, OhosProject ohosProject) { @@ -518,32 +528,36 @@ void cleanAndCopyFlutterRuntime( originHarFile.copySync(desHarPath); //copy ohos engine so - if (isWindows) { - final String originEnginePath = globals.fs.path - .join(ohosRootPath, 'har', 'har_product', '$FLUTTER_ENGINE_SO.$suffix'); - final String desEnginePath = globals.fs.path.join( - ohosProject.flutterModuleDirectory.path, - 'libs', - 'arm64-v8a', - FLUTTER_ENGINE_SO); - final File flutterEngineSoFile = - globals.localFileSystem.file(originEnginePath); - flutterEngineSoFile.copySync(desEnginePath); + final String? originEngineSoPath = isWindows + ? globals.fs.path.join(ohosRootPath, 'har', 'har_product', '$FLUTTER_ENGINE_SO.$suffix') + : globals.artifacts?.getArtifactPath(Artifact.flutterEngineSo); + if (originEngineSoPath == null) { + throwToolExit("flutter engine runtime file 'libflutter.so' no found"); + } + logger?.printStatus('flutterEngineSoPath: $originEngineSoPath'); + + final String destEngineSoPath = getEngineSoPath(ohosRootPath, targetPlatform, ohosProject); + ensureParentExists(destEngineSoPath); + final File flutterEngineSoFile = globals.localFileSystem.file(originEngineSoPath); + flutterEngineSoFile.copySync(destEngineSoPath); + + final String vmServiceSoDest = getVmServiceSoDest(ohosRootPath, targetPlatform, ohosProject); + final File vmServiceSoDestFile = globals.localFileSystem.file(vmServiceSoDest); + if (buildInfo.isProfile) { + // copy libvmservice_snapshot.so + final String vmserviceSoSrc = isWindows + ? globals.fs.path.join(ohosRootPath, 'har', 'har_product', '$VMSERVICE_SNAPSHOT_SO.$suffix') + : globals.fs.path.join(flutterEngineSoFile.parent.path, + 'gen/flutter/shell/vmservice/ohos/libs', + VMSERVICE_SNAPSHOT_SO); + final File vmserviceSoSrcFile = globals.localFileSystem.file(vmserviceSoSrc); + vmserviceSoSrcFile.copySync(vmServiceSoDest); } else { - final String? flutterEngineSoPath = - globals.artifacts?.getArtifactPath(Artifact.flutterEngineSo); - if (flutterEngineSoPath == null) { - throwToolExit("flutter engine runtime file 'libflutter.so' no found"); + if (vmServiceSoDestFile.existsSync()) { + vmServiceSoDestFile.deleteSync(); } - logger?.printStatus('flutterEngineSoPath:$flutterEngineSoPath'); - final File flutterEngineSoFile = - globals.localFileSystem.file(flutterEngineSoPath); - - final String enginCopyDes = - getEngineSoPath(ohosRootPath, targetPlatform, ohosProject); - ensureParentExists(enginCopyDes); - flutterEngineSoFile.copySync(enginCopyDes); } + logger?.printStatus('copy flutter runtime to project end'); } diff --git a/packages/flutter_tools/lib/src/ohos/ohos_device.dart b/packages/flutter_tools/lib/src/ohos/ohos_device.dart index b00c6aef2ebb449e484fdf62b7bfbf61844d8dde..7a3d2f2e1344376cf60d31ae3459ed456ae83711 100644 --- a/packages/flutter_tools/lib/src/ohos/ohos_device.dart +++ b/packages/flutter_tools/lib/src/ohos/ohos_device.dart @@ -735,7 +735,7 @@ class HdcLogReader extends DeviceLogReader { static final RegExp _logFormat = RegExp(r'^[\d-:. ]{30,40}[VDIWEF][^:]+:'); static final List _allowedTags = [ - RegExp(r'^[\d-:. ]{30,40}[VDIWEF][^:]flutter[^:]+:', caseSensitive: false), + RegExp(r'^[\d-:. ]{30,40}[VDIWEF]\s[^:]+Flutter[^:]+:\sflutter\s'), RegExp(r'^[\d-:. ]{30,40}[IE].*Dart VM\s+'), RegExp(r'^[WEF]\/System\.err:\s+'), RegExp(r'^[F]\/[\S^:]+:\s+'), diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 5bd5fe1f9f323765296f48ffb671ffb10968af83..c744b0315b9e66d8314a4cfcea8e0bd3183ddad6 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -251,7 +251,7 @@ class FlutterDevice { // when on hdc server mode,the host is not local,change to hdc server final String? hdcServerHost = getHdcServerHost(); if(hdcServerHost!=null){ - const String localHost = '0.0.0.0'; + const String localHost = '127.0.0.1'; observatoryUri = Uri.parse(observatoryUri?.toString()?.replaceAll(localHost, hdcServerHost)??localHost); } diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index b1035b704b0c36d4a5713ac278ab8266afad3a1a..01bce347f94e6306812f09b8bbe2edbb4fbf55a2 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -152,7 +152,7 @@ Future _defaultOpenChannel(String url, { final String? hdcServerHost = getHdcServerHost(); // when on hdc server mode,the host is not local,change to hdc server if(hdcServerHost!=null){ - url = url.replaceAll('0.0.0.0', hdcServerHost); + url = url.replaceAll('127.0.0.1', hdcServerHost); logger.printStatus('io.WebSocket.connect change url to $url'); } socket = await constructor(url, compression: compression, logger: logger); diff --git a/packages/flutter_tools/templates/app_shared/ohos.tmpl/.gitignore b/packages/flutter_tools/templates/app_shared/ohos.tmpl/.gitignore index c6da0806e7b770953be804991bc28a2894a1e4b6..11784662aacd838dd06d8d80504c161b73904865 100644 --- a/packages/flutter_tools/templates/app_shared/ohos.tmpl/.gitignore +++ b/packages/flutter_tools/templates/app_shared/ohos.tmpl/.gitignore @@ -11,5 +11,6 @@ **/.test entry/libs/arm64-v8a/libapp.so entry/libs/arm64-v8a/libflutter.so +entry/libs/arm64-v8a/libvmservice_snapshot.so entry/src/main/resources/rawfile/flutter_assets/ har/flutter_embedding.har diff --git a/packages/flutter_tools/templates/app_shared/ohos.tmpl/har/har_product.tmpl/libvmservice_snapshot.so.profile.10 b/packages/flutter_tools/templates/app_shared/ohos.tmpl/har/har_product.tmpl/libvmservice_snapshot.so.profile.10 new file mode 100644 index 0000000000000000000000000000000000000000..5029cd23b3afaae3c61b194ab61a677031830586 Binary files /dev/null and b/packages/flutter_tools/templates/app_shared/ohos.tmpl/har/har_product.tmpl/libvmservice_snapshot.so.profile.10 differ diff --git a/packages/flutter_tools/templates/template_manifest.json b/packages/flutter_tools/templates/template_manifest.json index 01731c1345a7452651d31449b9ad2671c496fd36..09a574f9f51f92f811bfb42e3c9d80ab5a54590b 100644 --- a/packages/flutter_tools/templates/template_manifest.json +++ b/packages/flutter_tools/templates/template_manifest.json @@ -182,6 +182,7 @@ "templates/app_shared/ohos.tmpl/har/har_product.tmpl/libflutter.so.debug.10", "templates/app_shared/ohos.tmpl/har/har_product.tmpl/libflutter.so.profile.10", "templates/app_shared/ohos.tmpl/har/har_product.tmpl/libflutter.so.release.10", + "templates/app_shared/ohos.tmpl/har/har_product.tmpl/libvmservice_snapshot.so.profile.10", "templates/app_shared/ohos.tmpl/local.properties.tmpl", "templates/app_shared/ohos.tmpl/dta/icudtl.dat", "templates/app_shared/ohos.tmpl/entry/libs/arm64-v8a/libc++_shared.so",