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 aaeb579a61b3b2415babfe5eeae14c7dd218616f..6ee6566ca582406dfa7b017f66a294d21e68fba7 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 @@ -96,7 +96,7 @@ export default class FlutterLoader { this.flutterApplicationInfo = ApplicationInfoLoader.load(context); await prefetchDefaultFontManager(); if (this.flutterApplicationInfo!.isDebugMode) { - await this.copyResource(context) + this.copyResource(context) } this.initResult = new InitResult( `${context.filesDir}/`, @@ -107,9 +107,9 @@ export default class FlutterLoader { } - private async copyResource(context: common.Context) { + private copyResource(context: common.Context) { let filePath = context.filesDir + FILE_SEPARATOR + this.flutterApplicationInfo!.flutterAssetsDir - const timestamp = await this.checkTimestamp(filePath); + const timestamp = this.checkTimestamp(filePath); if (timestamp == null) { Log.d(TAG, "no need copyResource") return; @@ -125,19 +125,19 @@ export default class FlutterLoader { fs.mkdirSync(filePath) } - let icudtlBuffer = await this.context.resourceManager.getRawFileContent(this.flutterApplicationInfo!.flutterAssetsDir + "/icudtl.dat") + let icudtlBuffer = this.context.resourceManager.getRawFileContentSync(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) - let kernelBuffer = await this.context.resourceManager.getRawFileContent(this.flutterApplicationInfo!.flutterAssetsDir + FILE_SEPARATOR + DEFAULT_KERNEL_BLOB) + let kernelBuffer = this.context.resourceManager.getRawFileContentSync(this.flutterApplicationInfo!.flutterAssetsDir + FILE_SEPARATOR + DEFAULT_KERNEL_BLOB) let kernelFile = fs.openSync(filePath + FILE_SEPARATOR + DEFAULT_KERNEL_BLOB, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE) fs.writeSync(kernelFile.fd, kernelBuffer.buffer) - let vmBuffer = await this.context.resourceManager.getRawFileContent(this.flutterApplicationInfo!.flutterAssetsDir + FILE_SEPARATOR + this.flutterApplicationInfo!.vmSnapshotData) + let vmBuffer = this.context.resourceManager.getRawFileContentSync(this.flutterApplicationInfo!.flutterAssetsDir + FILE_SEPARATOR + this.flutterApplicationInfo!.vmSnapshotData) let vmFile = fs.openSync(filePath + FILE_SEPARATOR + this.flutterApplicationInfo!.vmSnapshotData, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE) fs.writeSync(vmFile.fd, vmBuffer.buffer) - let isolateBuffer = await this.context.resourceManager.getRawFileContent(this.flutterApplicationInfo!.flutterAssetsDir + FILE_SEPARATOR + this.flutterApplicationInfo!.isolateSnapshotData) + let isolateBuffer = this.context.resourceManager.getRawFileContentSync(this.flutterApplicationInfo!.flutterAssetsDir + FILE_SEPARATOR + this.flutterApplicationInfo!.isolateSnapshotData) let isolateFile = fs.openSync(filePath + FILE_SEPARATOR + this.flutterApplicationInfo!.isolateSnapshotData, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE) fs.writeSync(isolateFile.fd, isolateBuffer.buffer) @@ -191,7 +191,7 @@ export default class FlutterLoader { + this.flutterApplicationInfo!.nativeLibraryDir + FILE_SEPARATOR + this.flutterApplicationInfo!.aotSharedLibraryName); - + const fileIsAccess = fs.accessSync(OH_ICU_DATA_FILE_PATH) if (fileIsAccess) { @@ -247,8 +247,8 @@ export default class FlutterLoader { return this.flutterApplicationInfo == null ? "" : this.flutterApplicationInfo!.flutterAssetsDir + "/" + filePath; } - private async checkTimestamp(dataDir: string) : Promise { - let bundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT); + private checkTimestamp(dataDir: string) { + let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT); const expectedTimestamp = TIMESTAMP_PREFIX + bundleInfo.versionCode + "-" + bundleInfo.updateTime; const existingTimestamps = this.getExistingTimestamps(dataDir); if (existingTimestamps == null) { @@ -288,8 +288,8 @@ class InitResult { dataDirPath: string; constructor(appStoragePath: string, - engineCachesPath: string, - dataDirPath: string) { + engineCachesPath: string, + dataDirPath: string) { this.appStoragePath = appStoragePath; this.engineCachesPath = engineCachesPath; this.dataDirPath = dataDirPath; 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 8ba4463178e5737bd4e4e4d4f27aa6457c67ef83..3c26873bd426f1b2261085359f36028f16eee9f2 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 @@ -103,11 +103,6 @@ export class FlutterAbility extends UIAbility implements Host { } this.errorManagerId = errorManager.on('error', observer); - let flutterApplicationInfo = ApplicationInfoLoader.load(this.context); - - if (flutterApplicationInfo.isDebugMode) { - this.delegate?.initWindow(); - } } onDestroy() { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets index 480371d80703aafa8be51b208ed052bb921375bc..af06d40f3aef2963ba071ffce98f04c27bb8b2b0 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterAbilityAndEntryDelegate.ets @@ -178,9 +178,9 @@ class FlutterAbilityAndEntryDelegate implements ExclusiveAppComponent this.isFlutterEngineFromHostOrCache = true; if (this.flutterEngine == null) { throw new Error( - "The requested cached FlutterEngine did not exist in the FlutterEngineCache: '" - + cachedEngineId - + "'"); + "The requested cached FlutterEngine did not exist in the FlutterEngineCache: '" + + cachedEngineId + + "'"); } return; } @@ -202,9 +202,9 @@ class FlutterAbilityAndEntryDelegate implements ExclusiveAppComponent const flutterEngineGroup = FlutterEngineGroupCache.instance.get(cachedEngineGroupId); if (flutterEngineGroup == null) { throw new Error( - "The requested cached FlutterEngineGroup did not exist in the FlutterEngineGroupCache: '" - + cachedEngineGroupId - + "'"); + "The requested cached FlutterEngineGroup did not exist in the FlutterEngineGroupCache: '" + + cachedEngineGroupId + + "'"); } if (this.context != null) { @@ -218,8 +218,8 @@ class FlutterAbilityAndEntryDelegate implements ExclusiveAppComponent // Our host did not provide a custom FlutterEngine. Create a FlutterEngine to back our // FlutterView. Log.d( - TAG, - "No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterAbility."); + TAG, + "No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterAbility."); let group = this.engineGroup; if (group == null && this.context != null) {