From 37fd050135d7c5b51733bb302d62037a2798e762 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Fri, 17 Jan 2025 14:20:57 +0800 Subject: [PATCH 1/4] fix codecheck alarm Signed-off-by: dengxiaoyu --- .../src/main/ets/pages/ContinueSwitch.ets | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/application/entry/src/main/ets/pages/ContinueSwitch.ets b/application/entry/src/main/ets/pages/ContinueSwitch.ets index c5663710..9aea8b80 100644 --- a/application/entry/src/main/ets/pages/ContinueSwitch.ets +++ b/application/entry/src/main/ets/pages/ContinueSwitch.ets @@ -203,6 +203,27 @@ struct ContinueSwitch { } } + initSwitchStatus(): void { + logger.info(`${TAG} initSwitchStatus in`); + try { + let value = settings.getValueSync(context, CommonConstants.CONTINUE_SWITCH_KEY, switchState.open, + settings.domainName.USER_SECURITY); + this.isSwitchOn = value != switchState.close ? true : false; + logger.info(`${TAG} this.isSwitchOn : ${this.isSwitchOn}; value: ${value}`); + + AppStorage.setOrCreate('isSwitchOn', this.isSwitchOn); + logger.info(`${TAG} AppStorage.get(isSwitchOn) : ${AppStorage.get('isSwitchOn')}`); + + if (this.isSwitchOn) { + let status: boolean = settings.setValueSync(context, CommonConstants.CONTINUE_SWITCH_KEY, switchState.open, + settings.domainName.USER_SECURITY); + logger.info(`${TAG} set value success :${status}; set:Continue_Switch_Status is 1`); + } + } catch (error) { + logger.error(`${TAG} settings set or get failed. error.message: ${error.message}`); + } + } + onPageShow() { logger.info(`${TAG} onPageShow in`); this.getGapLength(); @@ -217,21 +238,7 @@ struct ContinueSwitch { aboutToAppear() { logger.info(`${TAG} aboutToAppear in`); - // Switch State Initialization - let value = settings.getValueSync(context, CommonConstants.CONTINUE_SWITCH_KEY, switchState.open, - settings.domainName.USER_SECURITY); - this.isSwitchOn = value != switchState.close ? true : false; - logger.info(`${TAG} this.isSwitchOn : ${this.isSwitchOn}; value: ${value}`); - - AppStorage.setOrCreate('isSwitchOn', this.isSwitchOn); - logger.info(`${TAG} AppStorage.get(isSwitchOn) : ${AppStorage.get('isSwitchOn')}`); - - if (this.isSwitchOn) { - let status: boolean = settings.setValueSync(context, CommonConstants.CONTINUE_SWITCH_KEY, switchState.open, - settings.domainName.USER_SECURITY); - logger.info(`${TAG} set value success :${status}; set:Continue_Switch_Status is 1`); - } - + this.initSwitchStatus(); this.getStringSync(); this.getImageArray(); this.getForegroundOsAccountLocalId(); @@ -374,14 +381,18 @@ struct ContinueSwitch { logger.info(`${TAG} isOn: ${isOn}`); this.isSwitchOn = isOn; AppStorage.setAndLink('isSwitchOn', isOn); - if (isOn) { - let status: boolean = settings.setValueSync(context, CommonConstants.CONTINUE_SWITCH_KEY, - switchState.open, settings.domainName.USER_SECURITY); - logger.info(`${TAG} is set success :${status}; set:Continue_Switch_Status is open`); - } else { - let status: boolean = settings.setValueSync(context, CommonConstants.CONTINUE_SWITCH_KEY, - switchState.close, settings.domainName.USER_SECURITY); - logger.info(`${TAG} is set success :${status}; set:Continue_Switch_Status is close`); + try { + if (isOn) { + let status: boolean = settings.setValueSync(context, CommonConstants.CONTINUE_SWITCH_KEY, + switchState.open, settings.domainName.USER_SECURITY); + logger.info(`${TAG} is set success :${status}; set:Continue_Switch_Status is open`); + } else { + let status: boolean = settings.setValueSync(context, CommonConstants.CONTINUE_SWITCH_KEY, + switchState.close, settings.domainName.USER_SECURITY); + logger.info(`${TAG} is set success :${status}; set:Continue_Switch_Status is close`); + } + } catch (error) { + logger.error(`${TAG} settings.setValueSync failed. error.message: ${error.message}`); } }) } @@ -547,8 +558,8 @@ struct ContinueSwitch { private checkFoldBackButton(): void { logger.info(`${TAG} checkFoldBackButton in`); - if (display.isFoldable()) { - try { + try { + if (display.isFoldable()) { display.on('foldStatusChange', (foldStatus: display.FoldStatus) => { let foldStatusValue = foldStatus.valueOf(); logger.info(`${TAG} checkFoldBackButton: foldStatusValue is ${foldStatusValue}`); @@ -556,9 +567,9 @@ struct ContinueSwitch { }) let data: display.FoldStatus = display.getFoldStatus(); this.refreshFoldStatus(data); - } catch (err) { - logger.error(`${TAG} Register failed. exception: ${err.message}`); } + } catch (err) { + logger.error(`${TAG} display.isFoldable,on failed. exception: ${err.message}`); } } -- Gitee From 702bd61e41dd97fd61282d91e99e9d47893a2e97 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Fri, 17 Jan 2025 14:35:56 +0800 Subject: [PATCH 2/4] change versioncode Signed-off-by: dengxiaoyu --- application/AppScope/app.json | 4 ++-- application/AppScope/app.json5 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/AppScope/app.json b/application/AppScope/app.json index d4da5707..5b309b11 100644 --- a/application/AppScope/app.json +++ b/application/AppScope/app.json @@ -2,8 +2,8 @@ "app": { "bundleName": "com.ohos.dhardwareui", "vendor": "example", - "versionCode": 10000031, - "versionName": "1.0.31", + "versionCode": 10000032, + "versionName": "1.0.32", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 12, diff --git a/application/AppScope/app.json5 b/application/AppScope/app.json5 index 0d683326..a5588d85 100644 --- a/application/AppScope/app.json5 +++ b/application/AppScope/app.json5 @@ -16,8 +16,8 @@ "app": { "bundleName": "com.ohos.dhardwareui", "vendor": "example", - "versionCode": 10000031, - "versionName": "1.0.31", + "versionCode": 10000032, + "versionName": "1.0.32", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 12, -- Gitee From 2680feb953117eda95bff191be7eb66b649dafee Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Fri, 17 Jan 2025 07:14:46 +0000 Subject: [PATCH 3/4] update application/AppScope/app.json. Signed-off-by: dengxiaoyu --- application/AppScope/app.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/AppScope/app.json b/application/AppScope/app.json index 5b309b11..0865a2a6 100644 --- a/application/AppScope/app.json +++ b/application/AppScope/app.json @@ -2,8 +2,8 @@ "app": { "bundleName": "com.ohos.dhardwareui", "vendor": "example", - "versionCode": 10000032, - "versionName": "1.0.32", + "versionCode": 10000033, + "versionName": "1.0.33", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 12, -- Gitee From 24d75e7a290d30050b7d528798fa843d0d83d634 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Fri, 17 Jan 2025 07:15:37 +0000 Subject: [PATCH 4/4] update application/AppScope/app.json5. Signed-off-by: dengxiaoyu --- application/AppScope/app.json5 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/AppScope/app.json5 b/application/AppScope/app.json5 index a5588d85..a186be39 100644 --- a/application/AppScope/app.json5 +++ b/application/AppScope/app.json5 @@ -16,8 +16,8 @@ "app": { "bundleName": "com.ohos.dhardwareui", "vendor": "example", - "versionCode": 10000032, - "versionName": "1.0.32", + "versionCode": 10000033, + "versionName": "1.0.33", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 12, -- Gitee