1/** 2 * Copyright (c) 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 account_osAccount from '@ohos.account.osAccount'; 17import display from '@ohos.display'; 18import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; 19import PassWord from '../../common/components/PassWord'; 20import SixPassword from '../../common/components/SixPassword'; 21import { DialogType } from '../../common/module/DialogType'; 22import AuthUtils from '../../common/utils/AuthUtils'; 23import FuncUtils from '../../common/utils/FuncUtils'; 24import LogUtils from '../../common/utils/LogUtils'; 25import TimeUtils from '../../common/utils/TimeUtils'; 26import Constants, { 27 CmdData, 28 CmdNotifyEvents, 29 CmdType, 30 FingerPosition, 31 UserAuthTipType, 32 WantParams 33} from '../../common/vm/Constants'; 34import common from '@ohos.app.ability.common'; 35 36const TAG = 'FingerprintAuth'; 37const INTERVAL = 1000; 38let pinAuthManager: account_osAccount.PINAuth; 39let pinData = ''; 40const THOUSANDTH = 1000; 41const BOTTOM_BUTTON = 56; 42const BOTTOM_TEXT = 20; 43const PADDING_8 = 8; 44const PADDING_24 = 24; 45const SINGLE_FINGER = 1; 46const PIN_FINGER = 2; 47const SIX_PIN = 6; 48const MULTI_PIN = 5; 49const RADIUS = 2; 50const PIN_FAIL_TIP = 3; 51const AUTH_LOCK = 0; 52const NOTICE_DELAY = 50; 53const ON_SCREEN = 1; 54const UNDER_SCREEN = 2; 55const FINGER_SENSOR_POSITION_LINE = 0.75; 56const SECOND = 1000; 57 58@Component 59export default struct FingerprintAuth { 60 @Link type: string; 61 @Link pinSubType: string; 62 @Link dialogType: DialogType; 63 @State prompt: string = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 64 .getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp').id); 65 @State @Watch('onTextValueChange') textValue: string = ''; 66 @Link @Watch('onCmdDataChange') cmdData: Array<CmdType>; 67 @State isEdit: boolean = true; 68 @State inputValue: string = ''; 69 @State state: number = this.dialogType === DialogType.PIN_FINGER ? PIN_FINGER : SINGLE_FINGER; 70 @State fingerPositionY: number = 0; 71 @State fingerPosition: FingerPosition = { 72 sensorType: '', 73 udSensorRadiusInPx: 60 74 } 75 @State fingerLock: boolean = false; 76 @StorageLink('SYSTEM_NAVIGATION_BAR_HEIGHT') SYSTEM_NAVIGATION_BAR_HEIGHT: number = 0; 77 @State screen: number[] = []; 78 @StorageLink('IS_LANDSCAPE') IS_LANDSCAPE: boolean = false; 79 @State isOffFinger: boolean = false; 80 @State screenType: number = 0; 81 @Link skipLockedBiometricAuth: boolean; 82 83 aboutToAppear(): void { 84 AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); 85 try { 86 if (this.cmdData && this.cmdData.length > 0) { 87 this.onCmdDataChange('first'); 88 } 89 if (this.fingerPosition.udSensorCenterYInThousandth !== undefined && (this.screenType === ON_SCREEN || 90 this.screenType === UNDER_SCREEN)) { 91 let tempPositionY = px2vp(this.fingerPosition.udSensorCenterYInThousandth * this.screen[1]); 92 FuncUtils.judgmentOverflow(tempPositionY); 93 if (this.screenType === ON_SCREEN) { 94 this.fingerPositionY = px2vp(this.screen[1]) - tempPositionY / THOUSANDTH + BOTTOM_BUTTON + 95 PADDING_8 + BOTTOM_TEXT + PADDING_24; 96 } else if (this.screenType === UNDER_SCREEN) { 97 this.fingerPositionY = px2vp(this.screen[1]) - tempPositionY / THOUSANDTH + PADDING_24; 98 } 99 FuncUtils.judgmentOverflow(this.fingerPositionY); 100 } 101 LogUtils.info(TAG, 'aboutToAppear this.fingerPositionY: ' + this.fingerPositionY); 102 pinAuthManager = new account_osAccount.PINAuth(); 103 pinAuthManager.registerInputer({ 104 onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => { 105 LogUtils.info(TAG, 'aboutToAppear registerInputer onGetData'); 106 let uint8PW = FuncUtils.getUint8PW(pinData); 107 callback.onSetData(authSubType, uint8PW); 108 } 109 }); 110 111 if (((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string)) { 112 if (!this.skipLockedBiometricAuth) { 113 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypeFinger]); 114 } 115 } else { 116 if (!this.fingerLock) { 117 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypeFinger]); 118 } else { 119 if (this.dialogType === DialogType.FINGER) { 120 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypeFinger]); 121 } 122 } 123 } 124 } catch (error) { 125 LogUtils.error(TAG, 'aboutToAppear PINAuth catch error: ' + error?.code); 126 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 127 } 128 } 129 130 aboutToDisappear(): void { 131 LogUtils.info(TAG, 'PINAuth unregisterInputer'); 132 pinAuthManager?.unregisterInputer?.(); 133 } 134 135 onTextValueChange(): void { 136 pinData = this.textValue; 137 } 138 139 onCmdDataChange(num?: string): void { 140 this.cmdData.length > 0 && this.cmdData.map((item) => { 141 const payload: CmdData = item.payload; 142 let lockoutDuration: number = 0; 143 let remainAttempts: number = 0; 144 let authResult: number = -1; 145 if (payload.type === Constants.noticeTypeFinger){ 146 if (item?.event === CmdNotifyEvents.CMD_NOTIFY_AUTH_TIP) { 147 const tipInfo: string = FuncUtils.getStringFromCharCode(payload.tipInfo); 148 if (tipInfo) { 149 lockoutDuration = JSON.parse(tipInfo).lockoutDuration as number; 150 remainAttempts = JSON.parse(tipInfo).authRemainAttempts as number; 151 authResult = JSON.parse(tipInfo).authResult as number; 152 } else { 153 return; 154 } 155 } else { 156 lockoutDuration = payload.lockoutDuration; 157 remainAttempts = payload.remainAttempts; 158 authResult = payload.result; 159 } 160 } else if (payload.type === Constants.noticeTypePin){ 161 lockoutDuration = payload.lockoutDuration; 162 remainAttempts = payload.remainAttempts; 163 authResult = payload.result; 164 } else { 165 return; 166 } 167 LogUtils.info(TAG, 168 `lockoutDuration: ${lockoutDuration} remainAttempts: ${remainAttempts} authResult: ${authResult}`); 169 if (payload.type === Constants.noticeTypePin) { 170 if (authResult === 0) { 171 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); 172 setTimeout(() => { 173 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 174 }, SECOND) 175 } else if (authResult && authResult === Constants.authResultPinExpired) { 176 this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 177 .getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id); 178 this.textValue = ''; 179 return; 180 } else { 181 if (remainAttempts) { 182 this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 183 .getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id); 184 this.textValue = ''; 185 if (num === 'first') { 186 this.inputValue = ''; 187 } 188 if (remainAttempts < PIN_FAIL_TIP) { 189 this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 190 .getStringSync($r('app.string.unified_authwidget_pwd_error_can_try').id) + 191 remainAttempts + (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 192 .getStringSync($r('app.string.unified_authwidget_frequency').id); 193 } 194 } 195 if (remainAttempts === AUTH_LOCK && lockoutDuration) { 196 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 197 AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]); 198 this.countTime(lockoutDuration); 199 this.textValue = ''; 200 this.toPin(); 201 this.isEdit = false; 202 } 203 } 204 } else if (payload.type === Constants.noticeTypeFinger) { 205 if ([MULTI_PIN, SIX_PIN].includes(this.state)) { 206 return; 207 } 208 const displayClass = display.getDefaultDisplaySync(); 209 this.screen = [displayClass.width, displayClass.height]; 210 if (payload.sensorInfo && JSON.stringify(payload.sensorInfo) !== '{}') { 211 this.fingerPosition = JSON.parse(payload.sensorInfo); 212 switch (this.fingerPosition.sensorType) { 213 case 'OUT_OF_SCREEN_SENSOR': { 214 this.isOffFinger = true; 215 break; 216 } 217 default: 218 let tempPositionLine = JSON.parse(payload.sensorInfo).udSensorCenterYInThousandth / displayClass.height; 219 FuncUtils.judgmentOverflow(tempPositionLine); 220 if (tempPositionLine < FINGER_SENSOR_POSITION_LINE) { 221 this.screenType = ON_SCREEN; 222 } else if (tempPositionLine > FINGER_SENSOR_POSITION_LINE) { 223 this.screenType = UNDER_SCREEN; 224 } 225 break; 226 } 227 } 228 if ((remainAttempts && authResult !== 0) || authResult === Constants.authResultPinExpired) { 229 this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 230 .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id); 231 this.fingerLock = false; 232 } 233 if (num === 'first') { 234 this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 235 .getStringSync(this.isOffFinger ? 236 $r('app.string.unified_authwidget_hint_normal_fp_only').id : 237 $r('app.string.unified_authwidget_hint_inscreen_fp').id); 238 } 239 if (remainAttempts === AUTH_LOCK) { 240 this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 241 .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id); 242 this.fingerLock = true; 243 if (payload.tipType === UserAuthTipType.SINGLE_AUTH_RESULT) { 244 if (this.dialogType === DialogType.PIN_FINGER) { 245 if (this.pinSubType !== Constants.pinSix) { 246 this.state = MULTI_PIN; 247 } else { 248 this.state = SIX_PIN; 249 } 250 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 251 AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]); 252 this.toPin(); 253 } 254 if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string && 255 this.skipLockedBiometricAuth) { 256 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 257 AuthUtils.getInstance() 258 .sendNotice(Constants.noticeEventUserNavigation, [Constants.noticeTypeFinger]); 259 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 260 return; 261 } 262 if (this.dialogType === DialogType.FINGER && this.skipLockedBiometricAuth) { 263 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 264 AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]); 265 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 266 return; 267 } 268 } else { 269 if (this.dialogType === DialogType.PIN_FINGER) { 270 if (this.pinSubType !== Constants.pinSix) { 271 this.state = MULTI_PIN; 272 } else { 273 this.state = SIX_PIN; 274 } 275 this.toPin(); 276 } 277 } 278 } 279 if (authResult === 0) { 280 this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 281 .getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success').id); 282 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 283 setTimeout(() => { 284 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 285 }, SECOND); 286 } 287 } else { 288 LogUtils.error(TAG, 'onCmdDataChange default'); 289 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 290 } 291 }) 292 } 293 294 sendFingerEvent(): void { 295 if (!this.fingerLock) { 296 AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); 297 } 298 } 299 300 countTime(freezingTime: number): void { 301 const TRY_AGAIN = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 302 .getStringSync($r('app.string.unified_authwidget_postretry').id); 303 let promptText: string = ''; 304 let freezingMillisecond = freezingTime; 305 // O: freezing FINISH 306 if (freezingMillisecond > 0) { 307 promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond, (AppStorage.get('context') as common.ExtensionContext)); 308 promptText = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 309 .getStringSync($r('app.string.unified_authwidget_many_failures').id) + promptText + TRY_AGAIN; 310 setTimeout((t: number):void => this.countTime(t), INTERVAL, freezingTime - INTERVAL); 311 } else { 312 promptText = ' '; 313 this.isEdit = true; 314 } 315 this.inputValue = promptText; 316 } 317 318 onFingerPrintFontColor(prompt: string, context: Context): Resource { 319 if (prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id) || 320 prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id)) { 321 return $r('sys.color.ohos_id_color_warning'); 322 } else if (prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success').id) || 323 context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp').id) || 324 context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_normal_fp_only').id)) { 325 return $r('sys.color.ohos_id_color_text_secondary'); 326 } else { 327 return $r('sys.color.ohos_id_color_text_secondary'); 328 } 329 } 330 331 getFingerPosition(type: string): Resource { 332 switch (type) { 333 case 'BACK': 334 return $r('app.media.icon_applock_2'); 335 case 'FRONT': 336 return $r('app.media.icon_applock_3'); 337 case 'SIDE': 338 return $r('app.media.icon_applock_4'); 339 default: 340 return $r('app.media.icon_applock_3'); 341 } 342 } 343 344 handleCancel(): void { 345 if (this.state === SIX_PIN || this.state === MULTI_PIN) { 346 AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypePin]); 347 } else { 348 AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, 349 (AppStorage.get('wantParams') as WantParams)?.type as string[]); 350 } 351 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 352 } 353 354 toPin(): void { 355 LogUtils.debug(TAG, 'toPin this.pinSubType: ' + this.pinSubType); 356 AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypePin]); 357 if (this.pinSubType !== Constants.pinSix) { 358 this.state = MULTI_PIN; 359 } else { 360 this.state = SIX_PIN; 361 } 362 } 363 364 build() { 365 Column() { 366 GridRow({ 367 columns: { xs: 4, sm: 4, md: 8, lg: 12 }, 368 gutter: { x: 24, y: 24 }, 369 breakpoints: { value: Constants.deviceDpi, 370 reference: BreakpointsReference.WindowSize }, 371 direction: GridRowDirection.Row 372 }) { 373 GridCol({ 374 span: { xs: 4, sm: 4, md: 4, lg: 6 }, 375 offset: { md: 2, lg: 3 }, 376 }) { 377 if (this.isOffFinger) { 378 Column() { 379 if ([PIN_FINGER, SINGLE_FINGER].includes(this.state) && this.fingerPosition !== undefined) { 380 if (AppStorage.Get('titleLength') as number < (AppStorage.get('wantParams') as WantParams)?.title.length) { 381 Scroll() { 382 Column() { 383 Text((AppStorage.get('wantParams') as WantParams)?.title) 384 .draggable(false) 385 .fontSize($r('sys.float.ohos_id_text_size_body1')) 386 .fontColor($r('sys.color.ohos_id_color_text_primary')) 387 .fontWeight(FontWeight.Medium) 388 Image(this.getFingerPosition(this.fingerPosition.outOfScreenSensorType as string)) 389 .draggable(false) 390 .width($r('app.float.image_big')) 391 .height($r('app.float.image_big')) 392 .margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') }) 393 .id('outFingerImage') 394 Text(this.prompt) 395 .draggable(false) 396 .fontColor(this.onFingerPrintFontColor(this.prompt, (AppStorage.get('context') as common.ExtensionContext))) 397 .fontSize($r('sys.float.ohos_id_text_size_body2')) 398 }.margin({left: $r('app.float.size_24'), right: $r('app.float.size_24')}) 399 } 400 .width('100%') 401 .height($r('app.float.scroll_height_220')) 402 .margin({ top: $r('app.float.title_padding_top') }) 403 .scrollable(ScrollDirection.Vertical) 404 .scrollBarColor(Color.Gray) 405 } else { 406 Text((AppStorage.get('wantParams') as WantParams)?.title) 407 .draggable(false) 408 .margin({ top: $r('app.float.title_padding_top') }) 409 .fontSize($r('sys.float.ohos_id_text_size_body1')) 410 .fontColor($r('sys.color.ohos_id_color_text_primary')) 411 .height($r('app.float.size_24')) 412 .fontWeight(FontWeight.Medium) 413 Image(this.getFingerPosition(this.fingerPosition.outOfScreenSensorType as string)) 414 .draggable(false) 415 .width($r('app.float.image_big')) 416 .height($r('app.float.image_big')) 417 .margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') }) 418 .id('outFingerImage') 419 Text(this.prompt) 420 .draggable(false) 421 .fontColor(this.onFingerPrintFontColor(this.prompt, (AppStorage.get('context') as common.ExtensionContext))) 422 .fontSize($r('sys.float.ohos_id_text_size_body2')) 423 } 424 } 425 426 if (this.state === PIN_FINGER) { 427 Row() { 428 Column() { 429 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 430 .id('cancelBthState3FingerprintAuth') 431 .margin({ left: $r('app.float.content_padding') }) 432 .width(Constants.ninetyPercentWidth) 433 .height($r('app.float.btn_height')) 434 .fontSize($r('sys.float.ohos_id_text_size_button1')) 435 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 436 .fontWeight(FontWeight.Medium) 437 .backgroundColor(Color.Transparent) 438 .onClick(() => { 439 AuthUtils.getInstance() 440 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 441 this.handleCancel(); 442 this.textValue = ''; 443 }) 444 }.width(Constants.halfContainerWidth) 445 446 Divider() 447 .vertical(true) 448 .height($r('app.float.digital_password_mask_height')) 449 .color($r('sys.color.ohos_id_color_list_separator')) 450 .width($r('app.float.divider_width')) 451 Column() { 452 Button($r('app.string.unified_authwidget_usepwd')) 453 .id('usePwdBtnState3FingerprintAuth') 454 .margin({ right: $r('app.float.content_padding') }) 455 .width(Constants.ninetyPercentWidth) 456 .height($r('app.float.btn_height')) 457 .fontSize($r('sys.float.ohos_id_text_size_button1')) 458 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 459 .fontWeight(FontWeight.Medium) 460 .backgroundColor(Color.Transparent) 461 .onClick(() => { 462 this.inputValue = ' '; 463 AuthUtils.getInstance() 464 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 465 this.toPin(); 466 }) 467 }.width(Constants.halfContainerWidth) 468 } 469 .height($r('app.float.btn_height')) 470 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 471 } else if (this.state === SINGLE_FINGER) { 472 if (!((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string)) { 473 Row() { 474 Column() { 475 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 476 .id('cancelDefBtnState3FingerprintAuth') 477 .onClick(() => { 478 AuthUtils.getInstance() 479 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 480 this.handleCancel(); 481 }) 482 .backgroundColor(Color.Transparent) 483 .height($r('app.float.btn_height')) 484 .width(Constants.halfContainerWidth) 485 .fontSize($r('sys.float.ohos_id_text_size_button1')) 486 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 487 .fontWeight(FontWeight.Medium) 488 }.width(Constants.fullContainerHeight) 489 } 490 .height($r('app.float.btn_height')) 491 .padding({ left: $r('app.float.content_padding'), right: $r('app.float.content_padding') }) 492 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 493 } else { 494 Row() { 495 Column() { 496 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 497 .id('cancelBtnState3FingerprintAuth') 498 .margin({ left: $r('app.float.content_padding') }) 499 .width(Constants.ninetyPercentWidth) 500 .height($r('app.float.btn_height')) 501 .fontSize($r('sys.float.ohos_id_text_size_button1')) 502 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 503 .fontWeight(FontWeight.Medium) 504 .backgroundColor(Color.Transparent) 505 .onClick(() => { 506 AuthUtils.getInstance() 507 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 508 this.handleCancel(); 509 }) 510 }.width(Constants.halfContainerWidth) 511 512 Divider() 513 .vertical(true) 514 .height($r('app.float.digital_password_mask_height')) 515 .color($r('sys.color.ohos_id_color_list_separator')) 516 .width($r('app.float.divider_width')) 517 Column() { 518 Button((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) 519 .onClick(() => { 520 AuthUtils.getInstance() 521 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 522 AuthUtils.getInstance() 523 .sendNotice(Constants.noticeEventUserNavigation, [Constants.noticeTypeFinger]); 524 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 525 }) 526 .margin({ right: $r('app.float.content_padding') }) 527 .width(Constants.ninetyPercentWidth) 528 .height($r('app.float.btn_height')) 529 .fontSize($r('sys.float.ohos_id_text_size_button1')) 530 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 531 .fontWeight(FontWeight.Medium) 532 .backgroundColor(Color.Transparent) 533 }.width(Constants.halfContainerWidth) 534 } 535 .height($r('app.float.btn_height')) 536 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 537 } 538 } else if (this.state === MULTI_PIN) { 539 // Password 32-bit 540 Column() { 541 PassWord({ 542 textValue: $textValue, 543 inputValue: $inputValue, 544 isEdit: $isEdit, 545 pinSubType: $pinSubType 546 }) 547 Row() { 548 Column() { 549 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 550 .id('cancelStateMultiFingerprintAuth') 551 .margin({ left: $r('app.float.content_padding') }) 552 .width(Constants.ninetyPercentWidth) 553 .height($r('app.float.btn_height')) 554 .fontSize($r('sys.float.ohos_id_text_size_button1')) 555 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 556 .fontWeight(FontWeight.Medium) 557 .backgroundColor(Color.Transparent) 558 .onClick(() => { 559 AuthUtils.getInstance() 560 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); 561 this.handleCancel(); 562 this.textValue = ''; 563 }) 564 }.width(Constants.halfContainerWidth) 565 566 Divider() 567 .vertical(true) 568 .height($r('app.float.digital_password_mask_height')) 569 .color($r('sys.color.ohos_id_color_list_separator')) 570 .width($r('app.float.divider_width')) 571 Column() { 572 Button($r('app.string.unified_authwidget_confirm')) 573 .margin({ right: $r('app.float.content_padding') }) 574 .width(Constants.ninetyPercentWidth) 575 .height($r('app.float.btn_height')) 576 .fontSize($r('sys.float.ohos_id_text_size_button1')) 577 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 578 .fontWeight(FontWeight.Medium) 579 .backgroundColor(Color.Transparent) 580 .onClick(async (e) => { 581 AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); 582 }) 583 }.width(Constants.halfContainerWidth) 584 } 585 .height($r('app.float.btn_height')) 586 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 587 } 588 } else if (this.state === SIX_PIN) { 589 // Password 6-bit 590 Column() { 591 SixPassword({ 592 textValue: $textValue, 593 inputValue: $inputValue, 594 isEdit: $isEdit 595 }) 596 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 597 .id('cancelState6FingerprintAuth') 598 .onClick(() => { 599 AuthUtils.getInstance() 600 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); 601 this.handleCancel(); 602 this.textValue = ''; 603 }) 604 .backgroundColor(Color.Transparent) 605 .height($r('app.float.btn_height')) 606 .width(Constants.halfContainerWidth) 607 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 608 .fontSize($r('sys.float.ohos_id_text_size_button1')) 609 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 610 .fontWeight(FontWeight.Medium) 611 } 612 } 613 } 614 .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) 615 .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) 616 .margin({ 617 left: ($r('sys.float.ohos_id_dialog_margin_start')), 618 right: ($r('sys.float.ohos_id_dialog_margin_end')), 619 bottom: this.IS_LANDSCAPE ? '0' : ($r('sys.float.ohos_id_dialog_margin_bottom')) 620 }) 621 } else { 622 if (this.state === MULTI_PIN) { 623 Column() { 624 // Password 32-bit 625 Column() { 626 PassWord({ 627 textValue: $textValue, 628 inputValue: $inputValue, 629 isEdit: $isEdit, 630 pinSubType: $pinSubType 631 }) 632 Row() { 633 Column() { 634 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 635 .id('cancelBtnState5FingerprintAuth') 636 .margin({ left: $r('app.float.content_padding') }) 637 .width(Constants.ninetyPercentWidth) 638 .height($r('app.float.btn_height')) 639 .fontSize($r('sys.float.ohos_id_text_size_button1')) 640 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 641 .fontWeight(FontWeight.Medium) 642 .backgroundColor(Color.Transparent) 643 .onClick(() => { 644 AuthUtils.getInstance() 645 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); 646 this.handleCancel(); 647 this.textValue = ''; 648 }) 649 }.width(Constants.halfContainerWidth) 650 651 Divider() 652 .vertical(true) 653 .height($r('app.float.digital_password_mask_height')) 654 .color($r('sys.color.ohos_id_color_list_separator')) 655 .width($r('app.float.divider_width')) 656 Column() { 657 Button($r('app.string.unified_authwidget_confirm')) 658 .id('okBthState5FingerprintAuth') 659 .margin({ right: $r('app.float.content_padding') }) 660 .width(Constants.ninetyPercentWidth) 661 .height($r('app.float.btn_height')) 662 .fontSize($r('sys.float.ohos_id_text_size_button1')) 663 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 664 .fontWeight(FontWeight.Medium) 665 .backgroundColor(Color.Transparent) 666 .onClick(async (e) => { 667 AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); 668 }) 669 }.width(Constants.halfContainerWidth) 670 } 671 .height($r('app.float.btn_height')) 672 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 673 } 674 } 675 .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) 676 .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) 677 .margin({ 678 left: ($r('sys.float.ohos_id_dialog_margin_start')), 679 right: ($r('sys.float.ohos_id_dialog_margin_end')), 680 bottom: this.IS_LANDSCAPE ? '0' : ($r('sys.float.ohos_id_dialog_margin_bottom')) 681 }) 682 } else if (this.state === SIX_PIN) { 683 Column() { 684 // Password 6-bit 685 Column() { 686 SixPassword({ 687 textValue: $textValue, 688 inputValue: $inputValue, 689 isEdit: $isEdit 690 }) 691 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 692 .id('sixPassCancel') 693 .onClick(() => { 694 AuthUtils.getInstance() 695 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); 696 this.handleCancel(); 697 this.textValue = ''; 698 }) 699 .backgroundColor(Color.Transparent) 700 .height($r('app.float.btn_height')) 701 .width(Constants.halfContainerWidth) 702 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 703 .fontSize($r('sys.float.ohos_id_text_size_button1')) 704 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 705 .fontWeight(FontWeight.Medium) 706 } 707 } 708 .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) 709 .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) 710 .margin({ 711 left: ($r('sys.float.ohos_id_dialog_margin_start')), 712 right: ($r('sys.float.ohos_id_dialog_margin_end')), 713 bottom: this.IS_LANDSCAPE ? '0' : ($r('sys.float.ohos_id_dialog_margin_bottom')) 714 }) 715 } else if (this.state === PIN_FINGER && this.fingerPosition.udSensorRadiusInPx !== undefined ) { 716 Column() { 717 if (this.screenType === ON_SCREEN) { 718 if (AppStorage.Get('titleLength') as number < (AppStorage.get('wantParams') as WantParams)?.title.length) { 719 Scroll() { 720 Text((AppStorage.get('wantParams') as WantParams)?.title) 721 .draggable(false) 722 .fontSize($r('sys.float.ohos_id_text_size_body1')) 723 .fontColor($r('sys.color.ohos_id_color_text_primary')) 724 .fontWeight(FontWeight.Medium) 725 .margin({left: $r('app.float.size_24'), right: $r('app.float.size_24')}) 726 } 727 .width('100%') 728 .height($r('app.float.textArea_height')) 729 .margin({ top: $r('app.float.title_padding_top') }) 730 .scrollable(ScrollDirection.Vertical) 731 .scrollBarColor(Color.Gray) 732 } else { 733 Text((AppStorage.get('wantParams') as WantParams)?.title) 734 .draggable(false) 735 .margin({ top: $r('app.float.title_padding_top') }) 736 .fontSize($r('sys.float.ohos_id_text_size_body1')) 737 .fontColor($r('sys.color.ohos_id_color_text_primary')) 738 .height($r('app.float.size_24')) 739 .fontWeight(FontWeight.Medium) 740 } 741 Image(this.prompt === (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 742 .getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success').id) 743 ? $r('app.media.right_faceID') : $r('app.media.ic_blue_fingerprint')) 744 .draggable(false) 745 .margin({ 746 top: $r('app.float.digital_password_mask_height'), 747 bottom: $r('app.float.digital_password_mask_height') 748 }) 749 .id('blueFingerprintImgState2FingerprintAuth') 750 .width(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS)) 751 .height(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS)) 752 .colorBlend($r('sys.color.ohos_id_color_activated')) 753 .onClick(() => { 754 this.sendFingerEvent(); 755 }) 756 Text(this.prompt) 757 .draggable(false) 758 .fontColor(this.onFingerPrintFontColor(this.prompt, (AppStorage.get('context') as common.ExtensionContext))) 759 .fontSize($r('sys.float.ohos_id_text_size_body2')) 760 Row() { 761 Column() { 762 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 763 .id('cancelBtnState2FingerprintAuth') 764 .margin({ left: $r('app.float.content_padding') }) 765 .width(Constants.ninetyPercentWidth) 766 .height($r('app.float.btn_height')) 767 .fontSize($r('sys.float.ohos_id_text_size_button1')) 768 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 769 .fontWeight(FontWeight.Medium) 770 .backgroundColor(Color.Transparent) 771 .onClick(() => { 772 AuthUtils.getInstance() 773 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 774 this.handleCancel(); 775 this.textValue = ''; 776 }) 777 }.width(Constants.halfContainerWidth) 778 779 Divider() 780 .vertical(true) 781 .height($r('app.float.digital_password_mask_height')) 782 .color($r('sys.color.ohos_id_color_list_separator')) 783 .width($r('app.float.divider_width')) 784 Column() { 785 Button($r('app.string.unified_authwidget_usepwd')) 786 .id('usePwdBtnState2FingerprintAuth') 787 .margin({ right: $r('app.float.content_padding') }) 788 .width(Constants.ninetyPercentWidth) 789 .height($r('app.float.btn_height')) 790 .fontSize($r('sys.float.ohos_id_text_size_button1')) 791 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 792 .fontWeight(FontWeight.Medium) 793 .backgroundColor(Color.Transparent) 794 .onClick(() => { 795 this.inputValue = ' '; 796 AuthUtils.getInstance() 797 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 798 this.toPin(); 799 }) 800 }.width(Constants.halfContainerWidth) 801 } 802 .height($r('app.float.btn_height')) 803 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 804 } else if (this.screenType === UNDER_SCREEN) { 805 Flex({ justifyContent: FlexAlign.SpaceBetween }) { 806 Image($r('app.media.ic_public_cancel')) 807 .draggable(false) 808 .id('cancelBtnState4FingerprintAuth') 809 .width($r('app.float.digital_password_mask_height')) 810 .height($r('app.float.digital_password_mask_height')) 811 .margin({ 812 top: $r('app.float.digital_password_mask_height'), 813 left: $r('app.float.digital_password_mask_height') 814 }) 815 .onClick(() => { 816 this.handleCancel(); 817 this.textValue = ''; 818 }) 819 Button($r('app.string.unified_authwidget_usepwd')) 820 .backgroundColor(Color.White) 821 .height($r('app.float.digital_password_mask_height')) 822 .padding(0) 823 .margin({ 824 top: $r('app.float.digital_password_mask_height'), 825 right: $r('app.float.digital_password_mask_height') 826 }) 827 .fontColor($r('sys.color.ohos_id_color_activated')) 828 .fontSize($r('sys.float.ohos_id_text_size_body1')) 829 .fontWeight(FontWeight.Medium) 830 .onClick(() => { 831 this.inputValue = ' '; 832 AuthUtils.getInstance() 833 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 834 this.toPin(); 835 }) 836 } 837 838 if (AppStorage.Get('titleLength') as number < (AppStorage.get('wantParams') as WantParams)?.title.length) { 839 Scroll() { 840 Column() { 841 Text((AppStorage.get('wantParams') as WantParams)?.title) 842 .draggable(false) 843 .fontSize($r('sys.float.ohos_id_text_size_body1')) 844 .fontColor($r('sys.color.ohos_id_color_text_primary')) 845 .fontWeight(FontWeight.Medium) 846 Text(this.prompt) 847 .draggable(false) 848 .margin({ top: $r('app.float.element_margin') }) 849 .height($r('app.float.size_24')) 850 .fontSize($r('sys.float.ohos_id_text_size_body2')) 851 .fontColor(this.onFingerPrintFontColor(this.prompt, (AppStorage.get('context') as common.ExtensionContext))) 852 }.margin({left: $r('app.float.size_24'), right: $r('app.float.size_24')}) 853 } 854 .width('100%') 855 .height($r('app.float.scroll_height_76')) 856 .scrollable(ScrollDirection.Vertical) 857 .scrollBarColor(Color.Gray) 858 } else { 859 Text((AppStorage.get('wantParams') as WantParams)?.title) 860 .draggable(false) 861 .fontSize($r('sys.float.ohos_id_text_size_body1')) 862 .fontColor($r('sys.color.ohos_id_color_text_primary')) 863 .height($r('app.float.size_24')) 864 .fontWeight(FontWeight.Medium) 865 Text(this.prompt) 866 .draggable(false) 867 .margin({ top: $r('app.float.element_margin') }) 868 .height($r('app.float.size_24')) 869 .fontSize($r('sys.float.ohos_id_text_size_body2')) 870 .fontColor(this.onFingerPrintFontColor(this.prompt, (AppStorage.get('context') as common.ExtensionContext))) 871 } 872 Image(this.prompt === (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 873 .getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success').id) 874 ? $r('app.media.right_faceID') : $r('app.media.ic_blue_fingerprint')) 875 .draggable(false) 876 .width(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS)) 877 .height(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS)) 878 .margin({ 879 top: $r('app.float.digital_password_mask_height'), 880 bottom: $r('app.float.digital_password_mask_height') 881 }) 882 .colorBlend($r('sys.color.ohos_id_color_activated')) 883 .onClick(() => { 884 this.sendFingerEvent(); 885 }) 886 } 887 } 888 .position({ y: -Math.ceil(this.fingerPositionY) }) 889 .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) 890 .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) 891 .margin({ 892 left: ($r('sys.float.ohos_id_dialog_margin_start')), 893 right: ($r('sys.float.ohos_id_dialog_margin_end')), 894 bottom: ($r('sys.float.ohos_id_dialog_margin_bottom')) 895 }) 896 } else if (this.state === SINGLE_FINGER) { 897 Column() { 898 if (this.screenType === ON_SCREEN && this.fingerPosition.udSensorRadiusInPx !== undefined) { 899 if (AppStorage.Get('titleLength') as number < (AppStorage.get('wantParams') as WantParams)?.title.length) { 900 Scroll() { 901 Text((AppStorage.get('wantParams') as WantParams)?.title) 902 .draggable(false) 903 .fontSize($r('sys.float.ohos_id_text_size_body1')) 904 .fontColor($r('sys.color.ohos_id_color_text_primary')) 905 .fontWeight(FontWeight.Medium) 906 .margin({left: $r('app.float.size_24'), right: $r('app.float.size_24')}) 907 } 908 .width('100%') 909 .height($r('app.float.textArea_height')) 910 .margin({ top: $r('app.float.title_padding_top') }) 911 .scrollable(ScrollDirection.Vertical) 912 .scrollBarColor(Color.Gray) 913 } else { 914 Text((AppStorage.get('wantParams') as WantParams)?.title) 915 .draggable(false) 916 .margin({ top: $r('app.float.title_padding_top') }) 917 .fontSize($r('sys.float.ohos_id_text_size_body1')) 918 .fontColor($r('sys.color.ohos_id_color_text_primary')) 919 .height($r('app.float.size_24')) 920 .fontWeight(FontWeight.Medium) 921 } 922 Image(this.prompt === (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 923 .getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success').id) 924 ? $r('app.media.right_faceID') : $r('app.media.ic_blue_fingerprint')) 925 .draggable(false) 926 .margin({ 927 top: $r('app.float.digital_password_mask_height'), 928 bottom: $r('app.float.digital_password_mask_height') 929 }) 930 .id('blueFingerprintState1FingerprintAuth') 931 .width(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS)) 932 .height(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS)) 933 .colorBlend($r('sys.color.ohos_id_color_activated')) 934 .onClick(() => { 935 this.sendFingerEvent(); 936 }) 937 Text(this.prompt) 938 .draggable(false) 939 .fontColor(this.onFingerPrintFontColor(this.prompt, (AppStorage.get('context') as common.ExtensionContext))) 940 .fontSize($r('sys.float.ohos_id_text_size_body2')) 941 if (!((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string)) { 942 Row() { 943 Column() { 944 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 945 .id('cancelDefBtnState1FingerprintAuth') 946 .onClick(() => { 947 AuthUtils.getInstance() 948 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 949 this.handleCancel(); 950 }) 951 .backgroundColor(Color.Transparent) 952 .height($r('app.float.btn_height')) 953 .width(Constants.halfContainerWidth) 954 .fontSize($r('sys.float.ohos_id_text_size_button1')) 955 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 956 .fontWeight(FontWeight.Medium) 957 }.width(Constants.fullContainerHeight) 958 } 959 .height($r('app.float.btn_height')) 960 .padding({ left: $r('app.float.content_padding'), right: $r('app.float.content_padding') }) 961 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 962 } else { 963 Row() { 964 Column() { 965 Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) 966 .id('cancelBtnState1FingerprintAuth') 967 .margin({ left: $r('app.float.content_padding') }) 968 .width(Constants.ninetyPercentWidth) 969 .height($r('app.float.btn_height')) 970 .fontSize($r('sys.float.ohos_id_text_size_button1')) 971 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 972 .fontWeight(FontWeight.Medium) 973 .backgroundColor(Color.Transparent) 974 .onClick(() => { 975 AuthUtils.getInstance() 976 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 977 this.handleCancel(); 978 }) 979 }.width(Constants.halfContainerWidth) 980 981 Divider() 982 .vertical(true) 983 .height($r('app.float.digital_password_mask_height')) 984 .color($r('sys.color.ohos_id_color_list_separator')) 985 .width($r('app.float.divider_width')) 986 Column() { 987 Button(((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string)) 988 .onClick(() => { 989 AuthUtils.getInstance() 990 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 991 AuthUtils.getInstance() 992 .sendNotice(Constants.noticeEventUserNavigation, [Constants.noticeTypeFinger]); 993 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 994 }) 995 .id('navigationButtonTextFingerprintAuth') 996 .margin({ right: $r('app.float.content_padding') }) 997 .width(Constants.ninetyPercentWidth) 998 .height($r('app.float.btn_height')) 999 .fontSize($r('sys.float.ohos_id_text_size_button1')) 1000 .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) 1001 .fontWeight(FontWeight.Medium) 1002 .backgroundColor(Color.Transparent) 1003 }.width(Constants.halfContainerWidth) 1004 } 1005 .height($r('app.float.btn_height')) 1006 .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) 1007 } 1008 } else if (this.screenType === UNDER_SCREEN && this.fingerPosition.udSensorRadiusInPx !== undefined) { 1009 Flex({ justifyContent: FlexAlign.SpaceBetween }) { 1010 Image($r('app.media.ic_public_cancel')) 1011 .draggable(false) 1012 .id('fingerUnderImage') 1013 .width($r('app.float.digital_password_mask_height')) 1014 .height($r('app.float.digital_password_mask_height')) 1015 .margin({ 1016 top: $r('app.float.digital_password_mask_height'), 1017 left: $r('app.float.digital_password_mask_height') 1018 }) 1019 .onClick(() => { 1020 this.handleCancel(); 1021 this.textValue = ''; 1022 }) 1023 if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) { 1024 Button((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) 1025 .id('fingerUnderButton') 1026 .backgroundColor(Color.White) 1027 .height($r('app.float.digital_password_mask_height')) 1028 .padding(0) 1029 .margin({ 1030 top: $r('app.float.digital_password_mask_height'), 1031 right: $r('app.float.digital_password_mask_height') 1032 }) 1033 .fontColor($r('sys.color.ohos_id_color_activated')) 1034 .fontSize($r('sys.float.ohos_id_text_size_body1')) 1035 .fontWeight(FontWeight.Medium) 1036 .onClick(() => { 1037 AuthUtils.getInstance() 1038 .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); 1039 AuthUtils.getInstance() 1040 .sendNotice(Constants.noticeEventUserNavigation, [Constants.noticeTypeFinger]); 1041 (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); 1042 }) 1043 } 1044 } 1045 1046 if (AppStorage.Get('titleLength') as number < (AppStorage.get('wantParams') as WantParams)?.title.length) { 1047 Scroll() { 1048 Column() { 1049 Text((AppStorage.get('wantParams') as WantParams)?.title) 1050 .draggable(false) 1051 .fontSize($r('sys.float.ohos_id_text_size_body1')) 1052 .fontColor($r('sys.color.ohos_id_color_text_primary')) 1053 .fontWeight(FontWeight.Medium) 1054 Text(this.prompt) 1055 .draggable(false) 1056 .margin({ top: $r('app.float.element_margin') }) 1057 .height($r('app.float.size_24')) 1058 .fontSize($r('sys.float.ohos_id_text_size_body2')) 1059 .fontColor(this.onFingerPrintFontColor(this.prompt, (AppStorage.get('context') as common.ExtensionContext))) 1060 }.margin({left: $r('app.float.size_24'), right: $r('app.float.size_24')}) 1061 } 1062 .width('100%') 1063 .height($r('app.float.scroll_height_76')) 1064 .scrollable(ScrollDirection.Vertical) 1065 .scrollBarColor(Color.Gray) 1066 } else { 1067 Text((AppStorage.get('wantParams') as WantParams)?.title) 1068 .draggable(false) 1069 .fontSize($r('sys.float.ohos_id_text_size_body1')) 1070 .fontColor($r('sys.color.ohos_id_color_text_primary')) 1071 .height($r('app.float.size_24')) 1072 .fontWeight(FontWeight.Medium) 1073 Text(this.prompt) 1074 .draggable(false) 1075 .margin({ top: $r('app.float.element_margin') }) 1076 .height($r('app.float.size_24')) 1077 .fontSize($r('sys.float.ohos_id_text_size_body2')) 1078 .fontColor(this.onFingerPrintFontColor(this.prompt, (AppStorage.get('context') as common.ExtensionContext))) 1079 } 1080 Image(this.prompt === (AppStorage.get('context') as common.ExtensionContext)?.resourceManager 1081 .getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success').id) 1082 ? $r('app.media.right_faceID') : $r('app.media.ic_blue_fingerprint')) 1083 .draggable(false) 1084 .width(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS)) 1085 .height(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS)) 1086 .margin({ 1087 top: $r('app.float.digital_password_mask_height'), 1088 bottom: $r('app.float.digital_password_mask_height') 1089 }) 1090 .colorBlend($r('sys.color.ohos_id_color_activated')) 1091 .onClick(() => { 1092 this.sendFingerEvent(); 1093 }) 1094 } 1095 } 1096 .position({ y: -Math.ceil(this.fingerPositionY) }) 1097 .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) 1098 .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) 1099 .margin({ 1100 left: ($r('sys.float.ohos_id_dialog_margin_start')), 1101 right: ($r('sys.float.ohos_id_dialog_margin_end')), 1102 bottom: ($r('sys.float.ohos_id_dialog_margin_bottom')) 1103 }) 1104 } 1105 } 1106 } 1107 } 1108 } 1109 .margin(this.IS_LANDSCAPE ? '0' : { bottom: this.SYSTEM_NAVIGATION_BAR_HEIGHT }) 1110 .height(Constants.fullContainerHeight) 1111 .justifyContent(this.IS_LANDSCAPE ? FlexAlign.Center : FlexAlign.End) 1112 .backgroundColor(Color.Transparent) 1113 .id('fingerprintAuth') 1114 } 1115} 1116 1117