diff --git a/entry/src/main/ets/common/vm/Constants.ts b/entry/src/main/ets/common/vm/Constants.ts index a8e13e51b21db3861e0756c8debd7ac7d714fe71..0f24dba2c2c8c4d3cae6cc311b9010e8c70a140e 100644 --- a/entry/src/main/ets/common/vm/Constants.ts +++ b/entry/src/main/ets/common/vm/Constants.ts @@ -45,6 +45,8 @@ export default class Constants { // event cancel static noticeEventCancel = 'EVENT_AUTH_USER_CANCEL'; static noticeEventInvalidParam = 'EVENT_AUTH_WIDGET_PARA_INVALID'; + static noticeEventWidgetLoaded = 'EVENT_AUTH_WIDGET_LOADED'; + static noticeEventWidgetReleased = 'EVENT_AUTH_WIDGET_RELEASED'; static numKeyBoard : NumKeyBoardItem[] = [ { diff --git a/entry/src/main/ets/pages/components/CustomPassword.ets b/entry/src/main/ets/pages/components/CustomPassword.ets index 619f4beadbb51ae7c6ca42d9a48914ef802d0acd..236c253547b83971bb2f89089c9780b20d4cc31a 100644 --- a/entry/src/main/ets/pages/components/CustomPassword.ets +++ b/entry/src/main/ets/pages/components/CustomPassword.ets @@ -59,6 +59,7 @@ export default struct CustomPassword { callback.onSetData(authSubType, uint8PW); } }); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypePin]); } catch (error) { LogUtils.error(TAG, 'aboutToAppear PINAuth catch error: ' + error?.code); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); @@ -67,6 +68,7 @@ export default struct CustomPassword { aboutToDisappear(): void { LogUtils.info(TAG, 'aboutToDisappear PINAuth unregisterInputer'); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); pinAuthManager?.unregisterInputer?.(); } diff --git a/entry/src/main/ets/pages/components/FaceAuth.ets b/entry/src/main/ets/pages/components/FaceAuth.ets index 743dcc126ee3c9e52e00d029228a7306924b8375..9e1f80d322296cc5ef0ebe956bb3d1779c50a64d 100644 --- a/entry/src/main/ets/pages/components/FaceAuth.ets +++ b/entry/src/main/ets/pages/components/FaceAuth.ets @@ -22,7 +22,7 @@ import AuthUtils from '../../common/utils/AuthUtils'; import FuncUtils from '../../common/utils/FuncUtils'; import LogUtils from '../../common/utils/LogUtils'; import TimeUtils from '../../common/utils/TimeUtils'; -import Constants, { CmdData, CmdType, FingerPosition, WantParams } from '../../common/vm/Constants'; +import Constants, { CmdData, CmdType, FingerPosition, WantParams, CmdType } from '../../common/vm/Constants'; import common from '@ohos.app.ability.common'; const TAG = 'FaceAuth'; @@ -103,24 +103,35 @@ export default struct FaceAuth { aboutToAppear(): void { LogUtils.debug(TAG, 'aboutToAppear'); try { + if (this.cmdData && this.cmdData.length > 0) { + this.onCmdDataChange('first'); + } + if (this.dialogType === DialogType.PIN_FACE || this.dialogType === DialogType.FACE) { this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_recognition') .id); AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]); + if (!this.faceLock) { + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypeFace]); + } } else if (this.dialogType === DialogType.ALL || this.dialogType === DialogType.FACE_FINGER_NAVIGATION) { AuthUtils.getInstance() .sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger, Constants.noticeTypeFace]); + if (!this.fingerLock && !this.faceLock) { + AuthUtils.getInstance() + .sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypeFinger, Constants.noticeTypeFace]); + } else if (!this.faceLock) { + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypeFinger]); + } else if (!this.fingerLock) { + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypeFace]); + } } else { LogUtils.error(TAG, 'aboutToAppear not support type'); AuthUtils.getInstance().sendNotice(Constants.noticeEventInvalidParam, [Constants.noticeTypePin]); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); } - if (this.cmdData && this.cmdData.length > 0) { - this.onCmdDataChange('first'); - } - if ((this.isPinFaceFinger || this.dialogType === DialogType.FACE_FINGER_NAVIGATION) && this.fingerPosition.udSensorCenterYInThousandth !== undefined && this.fingerPosition.udSensorRadiusInPx !== undefined) { @@ -159,6 +170,7 @@ export default struct FaceAuth { toPin(): void { if ([DialogType.PIN_FACE, DialogType.ALL].includes(this.dialogType)) { LogUtils.debug(TAG, 'toPin this.dialogType: ' + this.dialogType); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypePin]); if (this.dialogType === DialogType.ALL) { AuthUtils.getInstance() .sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFace, Constants.noticeTypeFinger]); @@ -264,6 +276,7 @@ export default struct FaceAuth { this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager .getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden').id); this.faceLock = true; + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace]); if (this.dialogType === DialogType.ALL) { if (this.fingerLock) { this.toPin(); @@ -324,6 +337,7 @@ export default struct FaceAuth { this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id); this.fingerLock = true; + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); if (this.dialogType === DialogType.ALL) { if (this.faceLock) { this.toPin(); @@ -349,6 +363,7 @@ export default struct FaceAuth { handleCancel(): void { if (this.dialogTypeFlag === SIX_PIN || this.dialogTypeFlag === MULTI_PIN) { AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypePin]); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); } else { AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [] || (AppStorage.get('wantParams') as WantParams)?.type as string[]); @@ -805,6 +820,9 @@ export default struct FaceAuth { AuthUtils.getInstance() .sendNotice('EVENT_AUTH_USER_NAVIGATION', [Constants.noticeTypeFace, Constants.noticeTypeFinger]); + AuthUtils.getInstance() + .sendNotice(Constants.noticeEventWidgetReleased, + [Constants.noticeTypeFace, Constants.noticeTypeFinger]); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); }) @@ -1127,6 +1145,8 @@ export default struct FaceAuth { Button((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) .onClick(() => { AuthUtils.getInstance().sendNotice('EVENT_AUTH_USER_NAVIGATION', [Constants.noticeTypeFace]); + AuthUtils.getInstance() + .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace]); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); }) .margin({ right: $r('app.float.content_padding') }) diff --git a/entry/src/main/ets/pages/components/FingerprintAuth.ets b/entry/src/main/ets/pages/components/FingerprintAuth.ets index 489290d5604697908e77d8558b03bcf1fd474393..29f561bb568e1a69f9866fae4b75164e7993acbb 100644 --- a/entry/src/main/ets/pages/components/FingerprintAuth.ets +++ b/entry/src/main/ets/pages/components/FingerprintAuth.ets @@ -99,6 +99,9 @@ export default struct FingerprintAuth { callback.onSetData(authSubType, uint8PW); } }); + if (!this.fingerLock) { + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypeFinger]); + } } catch (error) { LogUtils.error(TAG, 'aboutToAppear PINAuth catch error: ' + error?.code); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); @@ -188,6 +191,7 @@ export default struct FingerprintAuth { this.fingerLock = true; if (this.dialogType === DialogType.PIN_FINGER) { AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); if (this.pinSubType !== Constants.pinSix) { this.state = MULTI_PIN; } else { @@ -262,6 +266,7 @@ export default struct FingerprintAuth { handleCancel(): void { if (this.state === SIX_PIN || this.state === MULTI_PIN) { AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypePin]); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); } else { AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [] || (AppStorage.get('wantParams') as WantParams)?.type as string[]); @@ -271,6 +276,7 @@ export default struct FingerprintAuth { toPin(): void { LogUtils.debug(TAG, 'toPin this.pinSubType: ' + this.pinSubType); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypePin]); AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]); if (this.pinSubType !== Constants.pinSix) { this.state = MULTI_PIN; @@ -429,6 +435,8 @@ export default struct FingerprintAuth { .onClick(() => { AuthUtils.getInstance() .sendNotice('EVENT_AUTH_USER_NAVIGATION', [Constants.noticeTypeFinger]); + AuthUtils.getInstance() + .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); }) .margin({ right: $r('app.float.content_padding') }) @@ -878,6 +886,8 @@ export default struct FingerprintAuth { .onClick(() => { AuthUtils.getInstance() .sendNotice('EVENT_AUTH_USER_NAVIGATION', [Constants.noticeTypeFinger]); + AuthUtils.getInstance() + .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); }) .id('navigationButtonTextFingerprintAuth') @@ -924,6 +934,8 @@ export default struct FingerprintAuth { .onClick(() => { AuthUtils.getInstance() .sendNotice('EVENT_AUTH_USER_NAVIGATION', [Constants.noticeTypeFinger]); + AuthUtils.getInstance() + .sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); }) } diff --git a/entry/src/main/ets/pages/components/PasswordAuth.ets b/entry/src/main/ets/pages/components/PasswordAuth.ets index 1b37272a46724b124589ec32a112f2857755e4b2..fb3673ef3331d1b36ad19dc91736f1577c63ee29 100644 --- a/entry/src/main/ets/pages/components/PasswordAuth.ets +++ b/entry/src/main/ets/pages/components/PasswordAuth.ets @@ -107,6 +107,7 @@ export default struct PasswordAuth { callback.onSetData(authSubType, uint8PW); } }); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetLoaded, [Constants.noticeTypePin]); } catch (error) { LogUtils.error(TAG, 'aboutToAppear PINAuth catch error: ' + error?.code); (AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf(); @@ -115,6 +116,7 @@ export default struct PasswordAuth { aboutToDisappear(): void { LogUtils.info(TAG, 'aboutToAppear pinAuthManager unregisterInputer'); + AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypePin]); pinAuthManager?.unregisterInputer?.(); }