From 0b9ad6528f5f1f029d02589de000353a3fc08590 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Mon, 8 Sep 2025 21:11:53 +0800 Subject: [PATCH 1/7] add obfuscation Signed-off-by: dengxiaoyu --- application/entry/build-profile.json5 | 15 ++++++++++++ application/entry/obfuscation-rules.txt | 23 +++++++++++++++++++ .../ContinueSwitchAbility.ets | 7 ++++++ 3 files changed, 45 insertions(+) create mode 100644 application/entry/obfuscation-rules.txt diff --git a/application/entry/build-profile.json5 b/application/entry/build-profile.json5 index 12369bde..f55ae85b 100644 --- a/application/entry/build-profile.json5 +++ b/application/entry/build-profile.json5 @@ -17,6 +17,21 @@ "apiType": "stageMode", "buildOption": { }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], "targets": [ { "name": "default", diff --git a/application/entry/obfuscation-rules.txt b/application/entry/obfuscation-rules.txt new file mode 100644 index 00000000..272efb6c --- /dev/null +++ b/application/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/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets index d23a0413..985282cb 100644 --- a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets +++ b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets @@ -46,6 +46,13 @@ export default class ContinueSwitchAbility extends UIExtensionAbility { onSessionCreate(want: Want, session: UIExtensionContentSession) { logger.info(`${TAG} UIExtAbility onSessionCreate.`); + let callerBundleName: string = want?.parameters?.['ohos.aafwk.param.callerBundleName'] as string; + logger.info(`${TAG} parameters: ${JSON.stringify(want?.parameters)}`); + if (callerBundleName != 'com.huawei.hmos.settings') { + logger.error(`${TAG} Caller has no permission. ${callerBundleName}`); + return; + } + let parameters = want.parameters; let pushParams = want.parameters?.pushParams as string | undefined; let startReason = ''; -- Gitee From f91c5cf8c3b82c8941d6eaf482de03d840d18a3a Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Tue, 9 Sep 2025 09:37:24 +0000 Subject: [PATCH 2/7] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20appl?= =?UTF-8?q?ication/entry/src/main/ets/continueswitchability/ContinueSwitch?= =?UTF-8?q?Ability.ets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContinueSwitchAbility.ets | 87 ------------------- 1 file changed, 87 deletions(-) delete mode 100644 application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets diff --git a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets deleted file mode 100644 index 985282cb..00000000 --- a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'; -import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; -import Want from '@ohos.app.ability.Want'; -import { Configuration } from '@ohos.app.ability.Configuration'; -import { logger } from '../utils/Logger'; - -const TAG: string = '[ContinueSwitchAbility]'; - -export default class ContinueSwitchAbility extends UIExtensionAbility { - onCreate() { - logger.info(`${TAG} UIExtAbility onCreate`); - AppStorage.setOrCreate('currentColorMode', this.context.config.colorMode); - AppStorage.setOrCreate('currentFontSizeScale', this.context.config.fontSizeScale); - } - - onConfigurationUpdate(newConfig: Configuration) { - AppStorage.setOrCreate('currentColorMode', this.context.config.colorMode); - AppStorage.setOrCreate('currentFontSizeScale', this.context.config.fontSizeScale); - } - - onForeground() { - logger.info(`${TAG} UIExtAbility onForeground`); - } - - onBackground() { - logger.info(`${TAG} UIExtAbility onBackground`); - } - - onDestroy() { - logger.info(`${TAG} UIExtAbility onDestroy`); - } - - onSessionCreate(want: Want, session: UIExtensionContentSession) { - logger.info(`${TAG} UIExtAbility onSessionCreate.`); - let callerBundleName: string = want?.parameters?.['ohos.aafwk.param.callerBundleName'] as string; - logger.info(`${TAG} parameters: ${JSON.stringify(want?.parameters)}`); - if (callerBundleName != 'com.huawei.hmos.settings') { - logger.error(`${TAG} Caller has no permission. ${callerBundleName}`); - return; - } - - let parameters = want.parameters; - let pushParams = want.parameters?.pushParams as string | undefined; - let startReason = ''; - let isShowBack = - pushParams?.includes('isShowBack') ? (pushParams.includes('isShowBack:false') ? false : true) : true; - let navigationMode = NavigationMode.Auto; - - if (parameters) { - startReason = parameters.startReason as string; - navigationMode = parameters.navigationMode as NavigationMode; - } - - if (startReason === 'from_search' && navigationMode === NavigationMode.Split) { - logger.info(`${TAG} navigationMode: ${navigationMode}`); - isShowBack = false; - } - - AppStorage.setOrCreate('continueSession', session); - AppStorage.setOrCreate('startReason', startReason); - AppStorage.setOrCreate('isShowBack', isShowBack); - let param: Record = { - 'session': session - }; - let storage: LocalStorage = new LocalStorage(param); - session.loadContent('pages/ContinueSwitch', storage); - logger.info(`${TAG} onSessionCreate end. startReason: ${startReason}, isShowBack: ${isShowBack}`); - } - - onSessionDestroy(session: UIExtensionContentSession) { - logger.info(`${TAG} UIExtAbility onSessionDestroy`); - } -} \ No newline at end of file -- Gitee From b4c9715c4b26695503d47536e7a194a5a3b54631 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Tue, 9 Sep 2025 17:39:39 +0800 Subject: [PATCH 3/7] del aafwk Signed-off-by: dengxiaoyu --- .../ets/continueswitchability/ContinueSwitchAbility.ets | 6 ------ 1 file changed, 6 deletions(-) diff --git a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets index 985282cb..b8cd6783 100644 --- a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets +++ b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets @@ -46,12 +46,6 @@ export default class ContinueSwitchAbility extends UIExtensionAbility { onSessionCreate(want: Want, session: UIExtensionContentSession) { logger.info(`${TAG} UIExtAbility onSessionCreate.`); - let callerBundleName: string = want?.parameters?.['ohos.aafwk.param.callerBundleName'] as string; - logger.info(`${TAG} parameters: ${JSON.stringify(want?.parameters)}`); - if (callerBundleName != 'com.huawei.hmos.settings') { - logger.error(`${TAG} Caller has no permission. ${callerBundleName}`); - return; - } let parameters = want.parameters; let pushParams = want.parameters?.pushParams as string | undefined; -- Gitee From f3f7c7fbf9acd33d53a5acc5e32bedd3f530459a Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Tue, 9 Sep 2025 09:43:34 +0000 Subject: [PATCH 4/7] update application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets. Signed-off-by: dengxiaoyu --- .../src/main/ets/continueswitchability/ContinueSwitchAbility.ets | 1 - 1 file changed, 1 deletion(-) diff --git a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets index b8cd6783..d23a0413 100644 --- a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets +++ b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets @@ -46,7 +46,6 @@ export default class ContinueSwitchAbility extends UIExtensionAbility { onSessionCreate(want: Want, session: UIExtensionContentSession) { logger.info(`${TAG} UIExtAbility onSessionCreate.`); - let parameters = want.parameters; let pushParams = want.parameters?.pushParams as string | undefined; let startReason = ''; -- Gitee From 147b78a4b3b0e8bfac577365bdd14c8ce7f584f6 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Tue, 9 Sep 2025 17:46:45 +0800 Subject: [PATCH 5/7] del space Signed-off-by: dengxiaoyu --- .../src/main/ets/continueswitchability/ContinueSwitchAbility.ets | 1 - 1 file changed, 1 deletion(-) diff --git a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets index d23a0413..92e1dc47 100644 --- a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets +++ b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets @@ -57,7 +57,6 @@ export default class ContinueSwitchAbility extends UIExtensionAbility { startReason = parameters.startReason as string; navigationMode = parameters.navigationMode as NavigationMode; } - if (startReason === 'from_search' && navigationMode === NavigationMode.Split) { logger.info(`${TAG} navigationMode: ${navigationMode}`); isShowBack = false; -- Gitee From e77f7449e6712b1742ec8496799115485315ee2b Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Tue, 9 Sep 2025 19:37:43 +0800 Subject: [PATCH 6/7] dels Signed-off-by: dengxiaoyu --- .../src/main/ets/continueswitchability/ContinueSwitchAbility.ets | 1 + 1 file changed, 1 insertion(+) diff --git a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets index 92e1dc47..d23a0413 100644 --- a/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets +++ b/application/entry/src/main/ets/continueswitchability/ContinueSwitchAbility.ets @@ -57,6 +57,7 @@ export default class ContinueSwitchAbility extends UIExtensionAbility { startReason = parameters.startReason as string; navigationMode = parameters.navigationMode as NavigationMode; } + if (startReason === 'from_search' && navigationMode === NavigationMode.Split) { logger.info(`${TAG} navigationMode: ${navigationMode}`); isShowBack = false; -- Gitee From 1eaf5e78862ecff34f0462c07157ce845cff7b99 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Tue, 9 Sep 2025 11:39:17 +0000 Subject: [PATCH 7/7] update application/entry/build-profile.json5. Signed-off-by: dengxiaoyu --- application/entry/build-profile.json5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/entry/build-profile.json5 b/application/entry/build-profile.json5 index f55ae85b..aa9543ad 100644 --- a/application/entry/build-profile.json5 +++ b/application/entry/build-profile.json5 @@ -17,7 +17,7 @@ "apiType": "stageMode", "buildOption": { }, - "buildOptionSet": [ + "buildOptionSet": [4 { "name": "release", "arkOptions": { -- Gitee