From 47147f7ab94d31c24c2d9551a4c7fd6076fae482 Mon Sep 17 00:00:00 2001 From: cjand <1747143535@qq.com> Date: Wed, 24 Apr 2024 10:00:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=A0=E9=99=A4release=E6=8B=B7=E8=B4=9D?= =?UTF-8?q?dat=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cjand <1747143535@qq.com> --- .../embedding/engine/loader/FlutterLoader.ets | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) 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 488a62b784..5941461ae5 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 @@ -53,6 +53,8 @@ const FILE_SEPARATOR = "/"; const TIMESTAMP_PREFIX = "res_timestamp-"; +const OH_ICU_DATA_FILE_PATH = "/system/usr/ohos_icu/" + /** * 定位在hap包中的flutter资源,并且加载flutter native library. */ @@ -87,8 +89,6 @@ export default class FlutterLoader { this.flutterApplicationInfo = ApplicationInfoLoader.load(context); if (this.flutterApplicationInfo!.isDebugMode) { await this.copyResource(context) - } else { - await this.copyICU(context) } this.initResult = new InitResult( `${context.filesDir}/`, @@ -98,29 +98,6 @@ export default class FlutterLoader { Log.d(TAG, "flutterLoader end init") } - private async copyICU(context: common.Context) { - let filePath = context.filesDir + FILE_SEPARATOR + this.flutterApplicationInfo!.flutterAssetsDir - const timestamp = await this.checkTimestamp(filePath); - if (timestamp == null) { - Log.d(TAG, "no need copyICU") - return; - } - if (this.context != null) { - Log.d(TAG, "start copyICU") - if (fs.accessSync(filePath)) { - fs.rmdirSync(filePath); - } - fs.mkdirSync(filePath) - let icudtlBuffer = await this.context.resourceManager.getRawFileContent(this.flutterApplicationInfo!.flutterAssetsDir + "/icudtl.dat") - let icudtlFile = fs.openSync(filePath + FILE_SEPARATOR + "/icudtl.dat", fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE) - fs.writeSync(icudtlFile.fd, icudtlBuffer.buffer) - if (timestamp != null) { - fs.openSync(filePath + FILE_SEPARATOR + timestamp, fs.OpenMode.READ_ONLY | fs.OpenMode.CREATE) - } - Log.d(TAG, "copyICU end") - } - } - private async copyResource(context: common.Context) { let filePath = context.filesDir + FILE_SEPARATOR + this.flutterApplicationInfo!.flutterAssetsDir const timestamp = await this.checkTimestamp(filePath); @@ -201,8 +178,8 @@ export default class FlutterLoader { + this.flutterApplicationInfo!.nativeLibraryDir + FILE_SEPARATOR + this.flutterApplicationInfo!.aotSharedLibraryName); - const snapshotAssetPath = this.initResult!.dataDirPath + FILE_SEPARATOR + this.flutterApplicationInfo!.flutterAssetsDir; - shellArgs.push("--icu-data-file-path=" + snapshotAssetPath + "/icudtl.dat") + const ICUPath = fs.listFileSync(OH_ICU_DATA_FILE_PATH); + shellArgs.push("--icu-data-file-path=" + OH_ICU_DATA_FILE_PATH + ICUPath[0]); if (this.flutterApplicationInfo!.isProfile) { shellArgs.push("--" + AOT_VMSERVICE_SHARED_LIBRARY_NAME + "=" + VMSERVICE_SNAPSHOT_LIBRARY); } -- Gitee From b8096e8db869cd47c67aae1abb8f517ee7a74e43 Mon Sep 17 00:00:00 2001 From: cjand <1747143535@qq.com> Date: Wed, 24 Apr 2024 15:50:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=A0=E9=99=A4release=E6=8B=B7=E8=B4=9D?= =?UTF-8?q?dat=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cjand <1747143535@qq.com> --- .../src/main/ets/embedding/engine/loader/FlutterLoader.ets | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 5941461ae5..3427d98afc 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 @@ -179,7 +179,11 @@ export default class FlutterLoader { + FILE_SEPARATOR + this.flutterApplicationInfo!.aotSharedLibraryName); const ICUPath = fs.listFileSync(OH_ICU_DATA_FILE_PATH); - shellArgs.push("--icu-data-file-path=" + OH_ICU_DATA_FILE_PATH + ICUPath[0]); + if (ICUPath.length == 1) { + shellArgs.push("--icu-data-file-path=" + OH_ICU_DATA_FILE_PATH + ICUPath[0]); + } else { + Log.e(TAG, "Unable to find the 'icudtl. dat' file or the file under " + OH_ICU_DATA_FILE_PATH + " is not unique") + } if (this.flutterApplicationInfo!.isProfile) { shellArgs.push("--" + AOT_VMSERVICE_SHARED_LIBRARY_NAME + "=" + VMSERVICE_SNAPSHOT_LIBRARY); } -- Gitee From 55ac14c6f3904ec0abd462f8042b954a602ccbd2 Mon Sep 17 00:00:00 2001 From: cjand <1747143535@qq.com> Date: Wed, 24 Apr 2024 16:41:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4release=E6=8B=B7=E8=B4=9D?= =?UTF-8?q?dat=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cjand <1747143535@qq.com> --- .../embedding/engine/loader/FlutterLoader.ets | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 3427d98afc..de94979c17 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 @@ -178,12 +178,20 @@ export default class FlutterLoader { + this.flutterApplicationInfo!.nativeLibraryDir + FILE_SEPARATOR + this.flutterApplicationInfo!.aotSharedLibraryName); - const ICUPath = fs.listFileSync(OH_ICU_DATA_FILE_PATH); - if (ICUPath.length == 1) { - shellArgs.push("--icu-data-file-path=" + OH_ICU_DATA_FILE_PATH + ICUPath[0]); + + const fileIsAccess = fs.accessSync(OH_ICU_DATA_FILE_PATH) + + if (fileIsAccess) { + const ICUPath = fs.listFileSync(OH_ICU_DATA_FILE_PATH); + if (ICUPath.length == 1) { + shellArgs.push("--icu-data-file-path=" + OH_ICU_DATA_FILE_PATH + ICUPath[0]); + } else { + Log.e(TAG, "The file in the " + OH_ICU_DATA_FILE_PATH + " directory is not unique") + } } else { - Log.e(TAG, "Unable to find the 'icudtl. dat' file or the file under " + OH_ICU_DATA_FILE_PATH + " is not unique") + Log.e(TAG, "The file " + OH_ICU_DATA_FILE_PATH + " does not exist") } + if (this.flutterApplicationInfo!.isProfile) { shellArgs.push("--" + AOT_VMSERVICE_SHARED_LIBRARY_NAME + "=" + VMSERVICE_SNAPSHOT_LIBRARY); } -- Gitee