From 45f0baba4c8b95a7b336b1e51ff7880144301cd9 Mon Sep 17 00:00:00 2001 From: CodingGorit Date: Wed, 30 Apr 2025 14:43:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7=20api=E5=88=B016?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=BA=9F=E5=BC=83api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 2 +- entry/obfuscation-rules.txt | 23 +++++++++++++++++++ entry/src/main/ets/common/utils/Camera.ets | 6 ++--- .../main/ets/common/utils/PermissionUtils.ets | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 entry/obfuscation-rules.txt diff --git a/build-profile.json5 b/build-profile.json5 index d209fee..7ec402c 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -5,7 +5,7 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", + "compatibleSdkVersion": "5.0.4(16)", "runtimeOS": "HarmonyOS" } ], diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# 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/Camera.ets b/entry/src/main/ets/common/utils/Camera.ets index a588ab0..d9e771f 100644 --- a/entry/src/main/ets/common/utils/Camera.ets +++ b/entry/src/main/ets/common/utils/Camera.ets @@ -21,7 +21,7 @@ import Logger from './Logger'; import CommonConstants from '../constants/CommonConstants'; const TAG: string = '[CameraModel]'; - +const context: common.UIAbilityContext = AppStorage.get("context") as common.UIAbilityContext; export default class Camera { private cameraMgr: camera.CameraManager | undefined = undefined; private cameraDevice: camera.CameraDevice | undefined = undefined; @@ -35,7 +35,7 @@ export default class Camera { private imgReceive: Function | undefined = undefined; async initCamera(surfaceId: string): Promise { - this.cameraMgr = camera.getCameraManager(getContext(this) as common.UIAbilityContext); + this.cameraMgr = camera.getCameraManager(context); let cameraArray = this.getCameraDevices(this.cameraMgr); this.cameraDevice = cameraArray[CommonConstants.INPUT_DEVICE_INDEX]; this.cameraInput = this.getCameraInput(this.cameraDevice, this.cameraMgr) as camera.CameraInput; @@ -81,7 +81,6 @@ export default class Camera { if (canIUse('SystemCapability.AI.OCR.TextRecognition')) { await textRecognition.recognizeText(visionInfo, textConfiguration).then((TextRecognitionResult) => { if (TextRecognitionResult.value === '') { - let context = getContext(this) as common.UIAbilityContext recognitionString = context.resourceManager.getStringSync($r('app.string.unrecognizable').id); } else { recognitionString = TextRecognitionResult.value; @@ -90,7 +89,6 @@ export default class Camera { pixelMapInstance.release(); imageResource.release(); } else { - let context = getContext(this) as common.UIAbilityContext recognitionString = context.resourceManager.getStringSync($r('app.string.Device_not_support').id); Logger.error(TAG, `device not support`); } diff --git a/entry/src/main/ets/common/utils/PermissionUtils.ets b/entry/src/main/ets/common/utils/PermissionUtils.ets index 37c7e76..b181247 100644 --- a/entry/src/main/ets/common/utils/PermissionUtils.ets +++ b/entry/src/main/ets/common/utils/PermissionUtils.ets @@ -21,7 +21,7 @@ const PERMISSIONS: Array = [ 'ohos.permission.CAMERA' ]; -const context = getContext(this) as common.UIAbilityContext; +const context: common.UIAbilityContext = AppStorage.get("context") as common.UIAbilityContext; export default async function grantPermission(): Promise { try { -- Gitee From 8376c26dcdaa8d37330f75785dbe5d26906db6c8 Mon Sep 17 00:00:00 2001 From: CodingGorit Date: Wed, 30 Apr 2025 14:43:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7=20api=E5=88=B016?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=BA=9F=E5=BC=83api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/obfuscation-rules.txt | 23 +++++++++++++++++++ entry/src/main/ets/common/utils/Camera.ets | 6 ++--- .../main/ets/common/utils/PermissionUtils.ets | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 entry/obfuscation-rules.txt diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# 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/Camera.ets b/entry/src/main/ets/common/utils/Camera.ets index a588ab0..d9e771f 100644 --- a/entry/src/main/ets/common/utils/Camera.ets +++ b/entry/src/main/ets/common/utils/Camera.ets @@ -21,7 +21,7 @@ import Logger from './Logger'; import CommonConstants from '../constants/CommonConstants'; const TAG: string = '[CameraModel]'; - +const context: common.UIAbilityContext = AppStorage.get("context") as common.UIAbilityContext; export default class Camera { private cameraMgr: camera.CameraManager | undefined = undefined; private cameraDevice: camera.CameraDevice | undefined = undefined; @@ -35,7 +35,7 @@ export default class Camera { private imgReceive: Function | undefined = undefined; async initCamera(surfaceId: string): Promise { - this.cameraMgr = camera.getCameraManager(getContext(this) as common.UIAbilityContext); + this.cameraMgr = camera.getCameraManager(context); let cameraArray = this.getCameraDevices(this.cameraMgr); this.cameraDevice = cameraArray[CommonConstants.INPUT_DEVICE_INDEX]; this.cameraInput = this.getCameraInput(this.cameraDevice, this.cameraMgr) as camera.CameraInput; @@ -81,7 +81,6 @@ export default class Camera { if (canIUse('SystemCapability.AI.OCR.TextRecognition')) { await textRecognition.recognizeText(visionInfo, textConfiguration).then((TextRecognitionResult) => { if (TextRecognitionResult.value === '') { - let context = getContext(this) as common.UIAbilityContext recognitionString = context.resourceManager.getStringSync($r('app.string.unrecognizable').id); } else { recognitionString = TextRecognitionResult.value; @@ -90,7 +89,6 @@ export default class Camera { pixelMapInstance.release(); imageResource.release(); } else { - let context = getContext(this) as common.UIAbilityContext recognitionString = context.resourceManager.getStringSync($r('app.string.Device_not_support').id); Logger.error(TAG, `device not support`); } diff --git a/entry/src/main/ets/common/utils/PermissionUtils.ets b/entry/src/main/ets/common/utils/PermissionUtils.ets index 37c7e76..b181247 100644 --- a/entry/src/main/ets/common/utils/PermissionUtils.ets +++ b/entry/src/main/ets/common/utils/PermissionUtils.ets @@ -21,7 +21,7 @@ const PERMISSIONS: Array = [ 'ohos.permission.CAMERA' ]; -const context = getContext(this) as common.UIAbilityContext; +const context: common.UIAbilityContext = AppStorage.get("context") as common.UIAbilityContext; export default async function grantPermission(): Promise { try { -- Gitee From c1af4e88263b24a7ff31be1d7b4166c23b493718 Mon Sep 17 00:00:00 2001 From: Gorit Date: Tue, 6 May 2025 08:38:06 +0000 Subject: [PATCH 3/3] Revert "Merge remote-tracking branch 'origin/master'" This reverts commit 7fe0ed23e7bb85f2a73a7fbee7b68197fb947485. --- build-profile.json5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-profile.json5 b/build-profile.json5 index 7ec402c..d209fee 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -5,7 +5,7 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.4(16)", + "compatibleSdkVersion": "5.0.0(12)", "runtimeOS": "HarmonyOS" } ], -- Gitee