1/** 2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import bundleMonitor from '@ohos.bundle.bundleMonitor'; 17import config from '@ohos.accessibility.config'; 18import accessibility from '@ohos.accessibility'; 19import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil'; 20import { ResourceUtils } from '../model/accessibilityImpl/resourceUtils'; 21import ConfigData from '../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData'; 22import ComponentConfig from '../../../../../../common/component/src/main/ets/default/ComponentConfig'; 23import HeadComponent from '../../../../../../common/component/src/main/ets/default/headComponent'; 24import { SubHeader } from '../../../../../../common/component/src/main/ets/default/textComponent'; 25import { AccessibilitySettingModel } from '../model/accessibilityImpl/AccessibilitySettingModel'; 26 27const AUDIO_BALANCE_STEP_VALUE: number = 1; 28const AUDIO_BALANCE_MIN_VALUE: number = -100; 29const AUDIO_BALANCE_MAX_VALUE: number = 100; 30const BASIC_ABILITY_HIGH_CONTRAST_TEXT = 'HIGH_CONTRAST_TEXT'; 31const BASIC_ABILITY_SINGLE_AUDIO = 'AUDIO_MONO'; 32const BASIC_ABILITY_INVERT_COLOR = 'INVERT_COLOR'; 33 34/** 35 * accessibility setting 36 */ 37@Entry 38@Component 39struct AccessibilitySettings { 40 @State shortKeyIsOn: boolean = false; 41 @State shortKeyStatusText: string = ''; 42 @State highContrastTextIsOn: boolean = false; 43 @State invertColorIsOn: boolean = false; 44 @State audioMonoIsOn: boolean = false; 45 @State colorCorrectionStatusText: string = ''; 46 @State inSetValueAudioBalance: number = 0; 47 @State serviceNum: number = 0; 48 @State serviceStateText: Resource = $r('app.string.no_service'); 49 @State isTouched: boolean = false; 50 @State serviceNumChanged: boolean = true; 51 private TAG = ConfigData.TAG + 'AccessibilitySettings '; 52 53 build() { 54 Column() { 55 GridContainer({ gutter: ConfigData.GRID_CONTAINER_GUTTER_24, margin: ConfigData.GRID_CONTAINER_MARGIN_24 }) { 56 Column() { 57 HeadComponent({ headName: $r('app.string.accessibility'), isActive: true }); 58 59 SubHeader({ titleContent: ResourceUtils.getCapitalStringSync($r('app.string.visual_accessibility')) }); 60 61 Column() { 62 Row() { 63 Text($r('app.string.highContrast_text')) 64 .fontSize($r('sys.float.ohos_id_text_size_body1')) 65 .fontColor($r('sys.color.ohos_id_color_text_primary')) 66 .fontWeight(FontWeight.Medium) 67 .textAlign(TextAlign.Start); 68 69 Blank(); 70 71 Toggle({ type: ToggleType.Switch, isOn: this.highContrastTextIsOn }) 72 .width('36vp') 73 .height('20vp') 74 .selectedColor('#007DFF') 75 .onChange((isOn: boolean) => { 76 this.setHighContrastTextState(isOn); 77 }); 78 } 79 .height($r('app.float.wh_value_56')) 80 .width(ConfigData.WH_100_100) 81 .alignItems(VerticalAlign.Center) 82 .padding({ left: $r('app.float.wh_value_12'), right: $r('app.float.wh_value_6') }) 83 .backgroundColor($r("app.color.white_bg_color")) 84 .borderRadius($r('app.float.radius_24')); 85 86 Row() { 87 Column() { 88 Text($r('app.string.invert_color')) 89 .fontSize($r('sys.float.ohos_id_text_size_body1')) 90 .fontColor($r('sys.color.ohos_id_color_text_primary')) 91 .fontWeight(FontWeight.Medium) 92 .textAlign(TextAlign.Start); 93 Text($r('app.string.performance_may_be_affected')) 94 .fontSize($r('sys.float.ohos_id_text_size_sub_title3')) 95 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 96 .fontWeight(FontWeight.Regular) 97 .textAlign(TextAlign.Center); 98 } 99 .width($r('app.float.wh_value_230')) 100 .alignItems(HorizontalAlign.Start) 101 .justifyContent(FlexAlign.Start) 102 103 Blank(); 104 105 Toggle({ type: ToggleType.Switch, isOn: this.invertColorIsOn }) 106 .width('36vp') 107 .height('20vp') 108 .selectedColor('#007DFF') 109 .onChange((isOn: boolean) => { 110 this.setInvertColorState(isOn); 111 }); 112 } 113 .height($r('app.float.wh_value_56')) 114 .width(ConfigData.WH_100_100) 115 .alignItems(VerticalAlign.Center) 116 .padding({ left: $r("app.float.wh_value_12"), right: $r('app.float.wh_value_6') }) 117 .backgroundColor($r("app.color.white_bg_color")) 118 .borderRadius($r('app.float.radius_24')); 119 120 Navigator({ target: 'pages/accessibilityColorCorrection' }) { 121 Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { 122 Row() { 123 Text($r('app.string.color_correction')) 124 .fontSize($r('app.float.font_16')) 125 .lineHeight($r('app.float.wh_value_22')) 126 .fontWeight(FontWeight.Medium) 127 .fontColor($r('app.color.font_color_182431')) 128 .margin({ left: $r('app.float.distance_8') }) 129 .textAlign(TextAlign.Start); 130 } 131 132 Row() { 133 Text(this.colorCorrectionStatusText) 134 .fontSize($r('app.float.font_14')) 135 .lineHeight($r('app.float.wh_value_19')) 136 .fontWeight(FontWeight.Regular) 137 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 138 .margin({ right: $r('app.float.distance_4') }) 139 .textAlign(TextAlign.End); 140 Image('/res/image/ic_settings_arrow.svg') 141 .width($r('app.float.wh_value_12')) 142 .height($r('app.float.wh_value_24')) 143 .margin({ right: $r('app.float.distance_8') }) 144 .fillColor($r('sys.color.ohos_id_color_primary')) 145 .opacity($r('app.float.opacity_0_2')) 146 } 147 } 148 .height(ComponentConfig.WH_100_100) 149 .width(ComponentConfig.WH_100_100) 150 .borderRadius($r('app.float.radius_20')) 151 .onTouch((event?: TouchEvent) => { 152 if (event && event.type === TouchType.Down) { 153 this.isTouched = true; 154 } 155 if (event && event.type === TouchType.Up) { 156 this.isTouched = false; 157 } 158 }); 159 } 160 .padding($r('app.float.distance_4')) 161 .height($r('app.float.wh_value_56')) 162 .borderRadius($r('app.float.radius_24')) 163 .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')); 164 165 } 166 .height($r('app.float.wh_value_160')) 167 .width(ConfigData.WH_100_100) 168 .borderRadius($r('app.float.radius_24')) 169 .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')); 170 171 SubHeader({ titleContent: ResourceUtils.getCapitalStringSync($r('app.string.audio_accessibility')) }); 172 173 Column() { 174 Row() { 175 Text($r('app.string.single_audio')) 176 .fontSize($r('sys.float.ohos_id_text_size_body1')) 177 .fontColor($r('sys.color.ohos_id_color_text_primary')) 178 .fontWeight(FontWeight.Medium) 179 .textAlign(TextAlign.Start); 180 181 Blank(); 182 183 Toggle({ type: ToggleType.Switch, isOn: this.audioMonoIsOn }) 184 .width('36vp') 185 .height('20vp') 186 .selectedColor('#007DFF') 187 .onChange((isOn: boolean) => { 188 this.setAudioMonoState(isOn); 189 }); 190 } 191 .height($r('app.float.wh_value_56')) 192 .width(ConfigData.WH_100_100) 193 .alignItems(VerticalAlign.Center) 194 .padding({ left: $r("app.float.wh_value_12"), right: $r('app.float.wh_value_6') }) 195 .backgroundColor($r("app.color.white_bg_color")) 196 .borderRadius($r('app.float.radius_24')); 197 198 Row() { 199 Text($r('app.string.audio_balance')) 200 .fontSize($r('sys.float.ohos_id_text_size_body1')) 201 .fontColor($r('sys.color.ohos_id_color_text_primary')) 202 .fontWeight(FontWeight.Medium) 203 .textAlign(TextAlign.Start); 204 } 205 .height($r('app.float.wh_value_20')) 206 .width(ConfigData.WH_100_100) 207 .alignItems(VerticalAlign.Center) 208 .padding({ left: $r("app.float.wh_value_12"), right: $r('app.float.wh_value_6') }) 209 .backgroundColor($r("app.color.white_bg_color")); 210 211 Row() { 212 Column() { 213 Slider({ 214 value: this.inSetValueAudioBalance, 215 min: AUDIO_BALANCE_MIN_VALUE, 216 max: AUDIO_BALANCE_MAX_VALUE, 217 step: AUDIO_BALANCE_STEP_VALUE, 218 style: SliderStyle.OutSet, 219 }) 220 .selectedColor($r('app.color.font_color_007DFF')) 221 .blockColor(Color.Blue) 222 .height($r('app.float.wh_value_20')) 223 .borderRadius($r('app.float.radius_24')) 224 .onChange((value: number, mode: SliderChangeMode) => { 225 this.setAudioBalanceValue(value, mode); 226 }); 227 228 Row() { 229 Text($r('app.string.left')) 230 .fontSize($r('app.float.font_14')) 231 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 232 .lineHeight($r("app.float.wh_value_20")) 233 .textAlign(TextAlign.Start); 234 235 Blank(); 236 237 Text($r('app.string.right')) 238 .fontSize($r('app.float.font_14')) 239 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 240 .lineHeight($r("app.float.wh_value_20")) 241 .textAlign(TextAlign.End); 242 } 243 .width(ConfigData.WH_100_100) 244 .alignItems(VerticalAlign.Center) 245 .padding({ left: $r('app.float.wh_value_6'), right: $r('app.float.wh_value_6') }) 246 .backgroundColor($r("app.color.white_bg_color")); 247 } 248 .width(ConfigData.WH_100_100); 249 } 250 .height($r('app.float.wh_value_56')) 251 .width(ConfigData.WH_100_100) 252 .alignItems(VerticalAlign.Center) 253 .padding({ left: $r('app.float.wh_value_6'), right: $r('app.float.wh_value_6') }) 254 .backgroundColor($r("app.color.white_bg_color")) 255 .borderRadius($r('app.float.radius_24')); 256 } 257 .width(ConfigData.WH_100_100) 258 .borderRadius($r('app.float.radius_24')) 259 .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')); 260 261 Text($r('app.string.audio_balance_suggestion')) 262 .width(ConfigData.WH_100_100) 263 .fontSize($r('app.float.font_14')) 264 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 265 .height($r("app.float.wh_value_52")) 266 .lineHeight($r("app.float.wh_value_20")) 267 .padding({ 268 left: $r('app.float.wh_value_12'), 269 top: $r('app.float.distance_4'), 270 bottom: $r('app.float.distance_24'), 271 }); 272 273 SubHeader({ titleContent: ResourceUtils.getCapitalStringSync($r('app.string.operate_accessibility')) }); 274 275 Column() { 276 Navigator({ target: 'pages/accessibilityScreenTouch' }) { 277 Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { 278 Row() { 279 Text($r('app.string.screen_touch')) 280 .fontSize($r('app.float.font_16')) 281 .fontWeight(FontWeight.Medium) 282 .fontColor($r('app.color.font_color_182431')) 283 .lineHeight($r('app.float.wh_value_22')) 284 .margin({ left: $r('app.float.distance_8') }) 285 .textAlign(TextAlign.Start); 286 } 287 288 Row() { 289 Image('/res/image/ic_settings_arrow.svg') 290 .height($r('app.float.wh_value_24')) 291 .width($r('app.float.wh_value_12')) 292 .fillColor($r('sys.color.ohos_id_color_primary')) 293 .margin({ right: $r('app.float.distance_8') }) 294 .opacity($r('app.float.opacity_0_2')); 295 } 296 } 297 .onTouch((event?: TouchEvent) => { 298 if (event && event.type === TouchType.Down) { 299 this.isTouched = true; 300 } 301 if (event && event.type === TouchType.Up) { 302 this.isTouched = false; 303 } 304 }) 305 .height(ComponentConfig.WH_100_100) 306 .width(ComponentConfig.WH_100_100) 307 .borderRadius($r('app.float.radius_20')); 308 } 309 .padding($r('app.float.distance_4')) 310 .height($r('app.float.wh_value_56')) 311 .borderRadius($r('app.float.radius_24')) 312 .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')); 313 314 Navigator({ target: 'pages/accessibilityShortKey' }) { 315 Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { 316 Row() { 317 Text($r('app.string.accessibility_shortcuts')) 318 .fontSize($r('app.float.font_16')) 319 .fontWeight(FontWeight.Medium) 320 .fontColor($r('app.color.font_color_182431')) 321 .lineHeight($r('app.float.wh_value_22')) 322 .margin({ left: $r('app.float.distance_8') }) 323 .textAlign(TextAlign.Start); 324 } 325 326 Row() { 327 Text(this.shortKeyStatusText) 328 .fontSize($r('app.float.font_14')) 329 .lineHeight($r('app.float.wh_value_19')) 330 .fontWeight(FontWeight.Regular) 331 .fontColor($r('sys.color.ohos_id_color_text_secondary')) 332 .textAlign(TextAlign.End) 333 .margin({ right: $r('app.float.distance_4') }); 334 Image('/res/image/ic_settings_arrow.svg') 335 .height($r('app.float.wh_value_24')) 336 .width($r('app.float.wh_value_12')) 337 .fillColor($r('sys.color.ohos_id_color_primary')) 338 .margin({ right: $r('app.float.distance_8') }) 339 .opacity($r('app.float.opacity_0_2')); 340 } 341 } 342 .onTouch((event?: TouchEvent) => { 343 if (event && event.type === TouchType.Down) { 344 this.isTouched = true; 345 } 346 if (event && event.type === TouchType.Up) { 347 this.isTouched = false; 348 } 349 }) 350 .height(ComponentConfig.WH_100_100) 351 .width(ComponentConfig.WH_100_100) 352 .borderRadius($r('app.float.radius_20')); 353 } 354 .padding($r('app.float.distance_4')) 355 .height($r('app.float.wh_value_56')) 356 .borderRadius($r('app.float.radius_24')) 357 .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')); 358 } 359 .height($r('app.float.wh_padding_112')) 360 .width(ConfigData.WH_100_100) 361 .borderRadius($r('app.float.radius_24')) 362 .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')); 363 } 364 .useSizeType({ 365 sm: { span: 4, offset: 0 }, 366 md: { span: 6, offset: 1 }, 367 lg: { span: 8, offset: 2 }, 368 }); 369 } 370 .width(ConfigData.WH_100_100) 371 .height(ConfigData.WH_100_100); 372 } 373 .backgroundColor($r("sys.color.ohos_id_color_sub_background")) 374 .width(ConfigData.WH_100_100) 375 .height(ConfigData.WH_100_100); 376 }; 377 378 setShortKeyText(status: boolean, allList: Array<string>): void { 379 LogUtil.info(`${this.TAG} shortKeyState: status:${JSON.stringify(status)},text:${JSON.stringify(allList)}`); 380 if (allList.length < 1) { 381 this.shortKeyStatusText = ResourceUtils.getStringSync($r('app.string.disabled')); 382 return; 383 } 384 if (status) { 385 let text: string = ''; 386 if (allList[0] === BASIC_ABILITY_HIGH_CONTRAST_TEXT) { 387 text = ResourceUtils.getStringSync($r('app.string.highContrast_text')); 388 } else if (allList[0] === BASIC_ABILITY_SINGLE_AUDIO) { 389 text = ResourceUtils.getStringSync($r('app.string.single_audio')); 390 } else if (allList[0] === BASIC_ABILITY_INVERT_COLOR) { 391 text = ResourceUtils.getStringSync($r('app.string.invert_color')); 392 } else { 393 text = allList[0].split('/')[1]; 394 } 395 if (allList.length > 1) { 396 this.shortKeyStatusText = text + ResourceUtils.getStringSync($r('app.string.wait')); 397 } else { 398 this.shortKeyStatusText = text; 399 } 400 } else { 401 this.shortKeyStatusText = ResourceUtils.getStringSync($r('app.string.disabled')); 402 } 403 LogUtil.info(`${this.TAG} set shortKeyStateText: ${JSON.stringify(this.shortKeyStatusText)}`); 404 } 405 406 setHighContrastTextState(isOn: boolean): void { 407 LogUtil.info(`${this.TAG} setHighContrastTextState ${isOn}`); 408 if (isOn) { 409 this.highContrastTextIsOn = true; 410 AccessibilitySettingModel.accessibilityConfigSetting('highContrastText', true); 411 } else { 412 this.highContrastTextIsOn = false; 413 AccessibilitySettingModel.accessibilityConfigSetting('highContrastText', false); 414 } 415 } 416 417 setInvertColorState(isOn: boolean): void { 418 LogUtil.info(`${this.TAG} setInvertColorState ${isOn}`); 419 if (isOn) { 420 this.invertColorIsOn = true; 421 AccessibilitySettingModel.accessibilityConfigSetting('invertColor', true); 422 } else { 423 this.invertColorIsOn = false; 424 AccessibilitySettingModel.accessibilityConfigSetting('invertColor', false); 425 } 426 } 427 428 setAudioMonoState(isOn: boolean): void { 429 LogUtil.info(`${this.TAG}setAudioMonoState ${isOn}`); 430 if (isOn) { 431 this.audioMonoIsOn = true; 432 AccessibilitySettingModel.accessibilityConfigSetting('audioMono', true); 433 } else { 434 this.audioMonoIsOn = false; 435 AccessibilitySettingModel.accessibilityConfigSetting('audioMono', false); 436 } 437 } 438 439 setAudioBalanceValue(audioBalance: number, mode: SliderChangeMode): void { 440 LogUtil.info(`${this.TAG} setAudioBalanceValue ${audioBalance}${mode}`); 441 if (mode == SliderChangeMode.End || mode == SliderChangeMode.Click) { 442 AccessibilitySettingModel.accessibilityAudioBalanceSetting(audioBalance / 100); 443 } 444 } 445 446 async getAbilityList(): Promise<void> { 447 await accessibility.getAccessibilityExtensionList('all', 'install').then((data) => { 448 LogUtil.info(`${this.TAG} get accessibilityAbilityList success, service length: ${JSON.stringify(data.length)}`); 449 if (data.length > 0) { 450 this.serviceNum = data.length; 451 this.serviceStateText = $r('app.plural.service_number', this.serviceNum, this.serviceNum); 452 LogUtil.info(`${this.TAG} serviceNumber: ${JSON.stringify(this.serviceNum)}`); 453 } else { 454 this.serviceStateText = $r('app.string.no_service'); 455 this.serviceNum = 0; 456 } 457 this.serviceNumChanged = !this.serviceNumChanged; 458 }).catch((err: object) => { 459 LogUtil.error(`${this.TAG} failed to get accessibilityAbilityList, because ${JSON.stringify(err)}`); 460 this.serviceStateText = $r('app.string.no_service'); 461 this.serviceNum = 0; 462 this.serviceNumChanged = !this.serviceNumChanged; 463 }) 464 LogUtil.info(`${this.TAG} aboutToAppear out`); 465 } 466 467 async getColorCorrectionState(): Promise<void> { 468 await config.daltonizationState.get().then((data) => { 469 LogUtil.info(`${this.TAG} get daltonizationState success: ${data}`); 470 if (data) { 471 this.colorCorrectionStatusText = (Object)($r('app.string.enabled')); 472 } else { 473 this.colorCorrectionStatusText = (Object)($r('app.string.disabled')); 474 } 475 }).catch((err: object) => { 476 LogUtil.error(`${this.TAG} failed to get daltonizationState, because ${JSON.stringify(err)}`); 477 }); 478 } 479 480 aboutToAppear(): void { 481 LogUtil.info(`${this.TAG} aboutToAppear in`); 482 config.highContrastText.get().then((data) => { 483 LogUtil.info(`${this.TAG} get highContrastText switch success`); 484 this.highContrastTextIsOn = data; 485 }).catch((err: object) => { 486 LogUtil.error(`${this.TAG} failed to get highContrastText switch, because ${JSON.stringify(err)}`); 487 }); 488 489 config.invertColor.get().then((data) => { 490 LogUtil.info(`${this.TAG} get invertColor switch success`); 491 this.invertColorIsOn = data; 492 }).catch((err: object) => { 493 LogUtil.error(`${this.TAG} failed to get invertColor switch, because ${JSON.stringify(err)}`); 494 }); 495 496 config.audioMono.get().then((data) => { 497 this.audioMonoIsOn = data; 498 LogUtil.info(`${this.TAG} get audioMono success`); 499 }).catch((err: object) => { 500 LogUtil.error(`${this.TAG} failed to get audioMono, because ${JSON.stringify(err)}`); 501 }); 502 503 config.audioBalance.get().then((data) => { 504 this.inSetValueAudioBalance = data * 100; 505 LogUtil.info(`${this.TAG} get audioBalance success`); 506 }).catch((err: object) => { 507 LogUtil.error(`${this.TAG} failed to get audioBalance, because ${JSON.stringify(err)}`); 508 }); 509 this.openStatusListener(); 510 this.getColorCorrectionState(); 511 this.getShortKeyStateAndTargetByStatus(); 512 this.getAbilityList(); 513 LogUtil.info(`${this.TAG} aboutToAppear out`); 514 } 515 516 async getShortKeyStateAndTargetByStatus(): Promise<void> { 517 let allList: Array<string> = []; 518 await config.shortkey.get().then((data) => { 519 this.shortKeyIsOn = data; 520 LogUtil.info(`${this.TAG} get shortKeyIsOn success : ${data}`); 521 }).catch((err: object) => { 522 LogUtil.error(`${this.TAG} failed to get shortKeyIsOn, because ${JSON.stringify(err)}`); 523 }); 524 525 await config.shortkeyMultiTargets.get().then((data) => { 526 allList = JSON.parse(JSON.stringify(data)); 527 LogUtil.info(`${this.TAG} get shortkeyMultiTargets success: ${data}`); 528 }).catch((err: object) => { 529 LogUtil.error(`${this.TAG} failed to get shortkeyMultiTargets, because ${JSON.stringify(err)}`); 530 }); 531 this.setShortKeyText(this.shortKeyIsOn, allList); 532 } 533 534 aboutToDisappear(): void { 535 LogUtil.info(`${this.TAG} aboutToDisappear`); 536 this.closeExtendedServicesListener(); 537 this.closeStatusListener(); 538 } 539 540 onPageShow(): void { 541 LogUtil.info(`${this.TAG} onPageShow in`); 542 this.getShortKeyStateAndTargetByStatus(); 543 this.openExtendedServicesListener(); 544 this.getColorCorrectionState(); 545 this.getAbilityList(); 546 LogUtil.info(`${this.TAG} onPageShow out`); 547 } 548 549 openStatusListener(): void { 550 try { 551 config.highContrastText.on((data: boolean) => { 552 LogUtil.info(`${this.TAG} subscribe highContrastText success, result: ${JSON.stringify(data)}`); 553 this.highContrastTextIsOn = data; 554 }); 555 } catch (exception) { 556 LogUtil.info(`${this.TAG} failed subscribe highContrastText, result: ${JSON.stringify(exception)}`); 557 } 558 try { 559 config.invertColor.on((data: boolean) => { 560 LogUtil.info(`${this.TAG} subscribe invertColor success, result: ${JSON.stringify(data)}`); 561 this.invertColorIsOn = data; 562 }); 563 } catch (exception) { 564 LogUtil.info(`${this.TAG} failed subscribe invertColor, result: ${JSON.stringify(exception)}`); 565 } 566 try { 567 config.audioMono.on((data: boolean) => { 568 LogUtil.info(`${this.TAG} subscribe audioMono success, result: ${JSON.stringify(data)}`); 569 this.audioMonoIsOn = data; 570 }); 571 } catch (exception) { 572 LogUtil.info(`${this.TAG} failed subscribe audioMono, result: ${JSON.stringify(exception)}`); 573 } 574 } 575 576 closeStatusListener(): void { 577 try { 578 config.highContrastText.off((data: boolean) => { 579 LogUtil.info(`${this.TAG} Unsubscribe highContrastText success, result: ${JSON.stringify(data)}`); 580 }); 581 } catch (exception) { 582 LogUtil.info(`${this.TAG} failed subscribe highContrastText , result: ${JSON.stringify(exception)}`); 583 } 584 try { 585 config.invertColor.off((data: boolean) => { 586 LogUtil.info(`${this.TAG} Unsubscribe invertColor success, result: ${JSON.stringify(data)}`); 587 }); 588 } catch (exception) { 589 LogUtil.info(`${this.TAG} failed subscribe invertColor , result: ${JSON.stringify(exception)}`); 590 } 591 try { 592 config.audioMono.off((data: boolean) => { 593 LogUtil.info(`${this.TAG} Unsubscribe audioMono success, result: ${JSON.stringify(data)}`); 594 }); 595 } catch (exception) { 596 LogUtil.info(`${this.TAG} failed subscribe audioMono, result: ${JSON.stringify(exception)}`); 597 } 598 } 599 600 openExtendedServicesListener(): void { 601 try { 602 bundleMonitor.on('add', (bundleChangeInfo) => { 603 LogUtil.info(`${this.TAG} Add bundleName: ${bundleChangeInfo.bundleName} userId: ${bundleChangeInfo.userId}`); 604 this.getAbilityList(); 605 }); 606 } catch (exception) { 607 LogUtil.info(`${this.TAG} failed subscribe bundleMonitor add, result: ${JSON.stringify(exception)}`); 608 } 609 try { 610 bundleMonitor.on('update', (bundleChangeInfo) => { 611 LogUtil.info(`${this.TAG} Update bundleName: ${bundleChangeInfo.bundleName} userId: ${bundleChangeInfo.userId}`); 612 this.getAbilityList(); 613 }); 614 } catch (exception) { 615 LogUtil.info(`${this.TAG} failed subscribe bundleMonitor, result: ${JSON.stringify(exception)}`); 616 } 617 try { 618 bundleMonitor.on('remove', (bundleChangeInfo) => { 619 LogUtil.info(`${this.TAG} Remove bundleName: ${bundleChangeInfo.bundleName} userId: ${bundleChangeInfo.userId}`); 620 this.getAbilityList(); 621 this.getShortKeyStateAndTargetByStatus(); 622 }); 623 } catch (exception) { 624 LogUtil.info(`${this.TAG} failed subscribe bundleMonitor, result: ${JSON.stringify(exception)}`); 625 } 626 } 627 628 closeExtendedServicesListener(): void { 629 try { 630 bundleMonitor.off('add'); 631 bundleMonitor.off('update'); 632 bundleMonitor.off('remove'); 633 } catch (exception) { 634 LogUtil.info(`${this.TAG} failed subscribe bundleMonitor, result: ${JSON.stringify(exception)}`); 635 } 636 } 637}