diff --git a/build-profile.json5 b/build-profile.json5 index 651fcffa5504b758f2eb563d664329b3dff364cd..1f6fb0541d841670d9364ab844373bba118ede4b 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -21,6 +21,7 @@ "name": "default", "signingConfig": "default", "compatibleSdkVersion": "5.0.0(12)", + "targetSdkVersion": "5.0.0(12)", "runtimeOS": "HarmonyOS", "buildOption": { "strictMode": { diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index 10a64b039257d1bbcaccf290124641c74d93f87d..27fd249f565c2f08b0d71f8e170e23c985eae3d2 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -23,33 +23,9 @@ "abiFilters": ["arm64-v8a","x86_64"] } }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - }, - ], "targets": [ { "name": "default" - }, - { - "name": "ohosTest", } ] } \ No newline at end of file diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt deleted file mode 100644 index 272efb6ca3f240859091bbbfc7c5802d52793b0b..0000000000000000000000000000000000000000 --- a/entry/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Define project specific obfuscation rules here. -# You can include the obfuscation configuration files in the current module's build-profile.json5. -# -# For more details, see -# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 - -# Obfuscation options: -# -disable-obfuscation: disable all obfuscations -# -enable-property-obfuscation: obfuscate the property names -# -enable-toplevel-obfuscation: obfuscate the names in the global scope -# -compact: remove unnecessary blank spaces and all line feeds -# -remove-log: remove all console.* statements -# -print-namecache: print the name cache that contains the mapping from the old names to new names -# -apply-namecache: reuse the given cache file - -# Keep options: -# -keep-property-name: specifies property names that you want to keep -# -keep-global-name: specifies names that you want to keep in the global scope - --enable-property-obfuscation --enable-toplevel-obfuscation --enable-filename-obfuscation --enable-export-obfuscation \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/ReadFile.ets b/entry/src/main/ets/common/utils/ReadFile.ets index 90d00814c3796c5d5c530264220bfc3952830eea..1439fed398d75f2060ce51654bff659a99dcb512 100644 --- a/entry/src/main/ets/common/utils/ReadFile.ets +++ b/entry/src/main/ets/common/utils/ReadFile.ets @@ -15,15 +15,21 @@ import { fileIo } from '@kit.CoreFileKit'; import { buffer } from '@kit.ArkTS'; +import { hilog } from '@kit.PerformanceAnalysisKit'; function readFile(filePath: string): string { - let stat = fileIo.statSync(filePath); - let buf = new ArrayBuffer(stat.size); - let fileStream = fileIo.createStreamSync(filePath, 'r+'); - fileStream.readSync(buf); - let res = buffer.from(buf, 0).toString(); - fileStream.close(); - return res; + try { + let stat = fileIo.statSync(filePath); + let buf = new ArrayBuffer(stat.size); + let fileStream = fileIo.createStreamSync(filePath, 'r+'); + fileStream.readSync(buf); + let res = buffer.from(buf, 0).toString(); + fileStream.close(); + return res; + } catch (error) { + hilog.error(0x0000, 'ReadFile', `readFile catch error, code: ${error.code}, message: ${error.message}`); + return 'error readFile'; + } } export default readFile; \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 971cdd3644e53a0df9fca73f7f6f591f517c63a2..9fe8df1273dc95e016c2bada740f1b533cef5bec 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -68,7 +68,7 @@ struct Index { .customButtonStyle() .onClick(() => { let content = this.getUIContext().getHostContext()!.resourceManager - .getStringSync($r('app.string.file_content_sandbox')); + .getStringByNameSync('file_content_sandbox'); // [Start trans_box_path] FileAccess.transferSandboxPath(this.sandboxFilesDir, content); // [End trans_box_path] @@ -79,7 +79,7 @@ struct Index { .customButtonStyle() .onClick(() => { let content = this.getUIContext().getHostContext()!.resourceManager - .getStringSync($r('app.string.file_content_splice')); + .getStringByNameSync('file_content_splice'); // [Start file_path] FileAccess.splicePath(content); // [End file_path] @@ -105,7 +105,7 @@ struct Index { .customButtonStyle() .onClick(async () => { let content = this.getUIContext().getHostContext()!.resourceManager - .getStringSync($r('app.string.file_content_picker')); + .getStringByNameSync('file_content_picker'); await WriteFileByPicker(content).then((value: string) => { setTimeout(() => { this.customToast(value);