From 4bbb574769c125f9732142733ee5e436f418b133 Mon Sep 17 00:00:00 2001 From: WangLin305 Date: Tue, 5 Aug 2025 11:40:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 1 + entry/build-profile.json5 | 24 ------------------------ entry/obfuscation-rules.txt | 23 ----------------------- entry/src/main/ets/pages/Index.ets | 6 +++--- 4 files changed, 4 insertions(+), 50 deletions(-) delete mode 100644 entry/obfuscation-rules.txt diff --git a/build-profile.json5 b/build-profile.json5 index 651fcff..1f6fb05 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 10a64b0..27fd249 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 272efb6..0000000 --- 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/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 971cdd3..9fe8df1 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); -- Gitee From 26db1effd9e4e42da39214f89af5706bbef53a3c Mon Sep 17 00:00:00 2001 From: WangLin305 Date: Wed, 6 Aug 2025 11:20:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/ReadFile.ets | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/entry/src/main/ets/common/utils/ReadFile.ets b/entry/src/main/ets/common/utils/ReadFile.ets index 90d0081..ee54f0e 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', `lockAsync catch error, code: ${error.code}, message: ${error.message}`); + return 'error readFile'; + } } export default readFile; \ No newline at end of file -- Gitee From 2c2edca3ee8ee884f3132e5d8e1607e843337bcf Mon Sep 17 00:00:00 2001 From: WangLin305 Date: Wed, 6 Aug 2025 11:29:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/ReadFile.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry/src/main/ets/common/utils/ReadFile.ets b/entry/src/main/ets/common/utils/ReadFile.ets index ee54f0e..1439fed 100644 --- a/entry/src/main/ets/common/utils/ReadFile.ets +++ b/entry/src/main/ets/common/utils/ReadFile.ets @@ -27,7 +27,7 @@ function readFile(filePath: string): string { fileStream.close(); return res; } catch (error) { - hilog.error(0x0000, 'ReadFile', `lockAsync catch error, code: ${error.code}, message: ${error.message}`); + hilog.error(0x0000, 'ReadFile', `readFile catch error, code: ${error.code}, message: ${error.message}`); return 'error readFile'; } } -- Gitee