From 09eec1e2088cd9c8b269001236e4d5a7934728ef Mon Sep 17 00:00:00 2001 From: zhangwenbo <1291179520@qq.com> Date: Thu, 4 Sep 2025 16:04:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Revert=20"=E4=BF=AE=E6=94=B9context?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=BC=82=E5=B8=B8--=E5=88=A0?= =?UTF-8?q?=E9=99=A4=20=20static=20getContextName"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit afbbf010418880577b9c0afcfafe7192e1ec3cb7. --- .../src/main/ets/default/brightnessManager.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/features/brightnesscomponent/src/main/ets/default/brightnessManager.ts b/features/brightnesscomponent/src/main/ets/default/brightnessManager.ts index ef66d3e8..6e879ae3 100644 --- a/features/brightnesscomponent/src/main/ets/default/brightnessManager.ts +++ b/features/brightnesscomponent/src/main/ets/default/brightnessManager.ts @@ -38,7 +38,7 @@ export class brightnessManager { constructor() { this.uri = Constants.getUriSync(Constants.KEY_BRIGHTNESS_STATUS); Log.showInfo(TAG, 'settings geturi of brightness is ' + Constants.URI_VAR); - this.context = AbilityManager.getContext(AbilityManager.ABILITY_NAME_CONTROL_PANEL); + this.context = AbilityManager.getContext(AbilityManager.getContextName(AbilityManager.ABILITY_NAME_CONTROL_PANEL)); this.init(); } @@ -49,11 +49,6 @@ export class brightnessManager { } public createDataShare() { - if (this.context == undefined || this.context == null) { - Log.showInfo(TAG, `constructor, this.context is null`); - return; - } - Log.showInfo(TAG, `createDataShare, this.context ${this.context}`); const UPDATE_INTERVAL = 500; const timer = setInterval(() => { dataShare.createDataShareHelper(this.context, this.uri) -- Gitee From 09c1f48806f0326437452cd8b49e82c3c5ba9806 Mon Sep 17 00:00:00 2001 From: zhangwenbo <1291179520@qq.com> Date: Thu, 4 Sep 2025 16:29:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9brightnessManager-context?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangwenbo <1291179520@qq.com> --- .../src/main/ets/default/brightnessManager.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/features/brightnesscomponent/src/main/ets/default/brightnessManager.ts b/features/brightnesscomponent/src/main/ets/default/brightnessManager.ts index 6e879ae3..17527aee 100644 --- a/features/brightnesscomponent/src/main/ets/default/brightnessManager.ts +++ b/features/brightnesscomponent/src/main/ets/default/brightnessManager.ts @@ -49,20 +49,19 @@ export class brightnessManager { } public createDataShare() { - const UPDATE_INTERVAL = 500; - const timer = setInterval(() => { + if (this.context == null || this.context == undefined) { + this.context = AbilityManager.getContext(AbilityManager.getContextName(AbilityManager.ABILITY_NAME_CONTROL_PANEL)); + } dataShare.createDataShareHelper(this.context, this.uri) .then((dataHelper) => { Log.showInfo(TAG, `createDataShareHelper success.`); this.helper = dataHelper; this.registerBrightness(); this.getValue(); - clearInterval(timer); }) .catch((err: BusinessError) => { Log.showError(TAG, `createDataShare fail. ${JSON.stringify(err)}`); }); - }, UPDATE_INTERVAL); } registerBrightness() { -- Gitee