!102 告警处理

Merge pull request !102 from xuanzhuo/master
This commit is contained in:
openharmony_ci
2025-08-26 13:04:49 +00:00
committed by Gitee
4 changed files with 418 additions and 357 deletions
@@ -98,121 +98,133 @@ export default struct FullScreen {
@StorageLink('IS_LANDSCAPE') IS_LANDSCAPE: boolean = false;
@Consume underFingerPrint: boolean;
handleNoticeTypePin(payload: CmdData, num?: string): void {
this.clearPassword();
if (payload.remainAttempts) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id);
if (num === 'first' && this.prompt !== (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_recognition').id)) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_use_pwd').id);
}
// 3: pin Residual number
if (payload.remainAttempts < 3 && num !== 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_pwd_error_can_try').id) +
payload.remainAttempts + (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_frequency').id);
}
}
if (payload.remainAttempts === 0 && payload.lockoutDuration) {
// 1: pin lock
this.pinLock = 1;
this.countdown(payload.lockoutDuration);
}
if (!payload.remainAttempts && !payload.lockoutDuration) {
// 1: pin lock
this.pinLock = 1;
}
if (payload.result === 0) {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}
}
handleNoticeTypeFace(payload: CmdData, num?: string): void {
if (payload.remainAttempts < 5 && payload.remainAttempts > 0) {
if (this.pinLock !== 1) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1').id);
this.faceFingerLockArr[0] = false;
}
}
if (num === 'first') {
if (payload.remainAttempts === 0) {
this.controlType.isShowFace = false;
} else {
if (this.pinLock !== 1) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_recognition').id);
}
}
}
if (payload.remainAttempts === 0) {
if (num !== 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden').id);
}
this.faceFingerLockArr[0] = true;
}
if (payload.result === 0) {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}
}
handleNoticeTypeFinger(payload: CmdData, num?: string): void {
let sensor: FingerPosition = { sensorType: '' };
if (payload.sensorInfo && JSON.stringify(payload.sensorInfo) !== '{}') {
sensor = JSON.parse(payload.sensorInfo);
this.fingerPosition = sensor || { sensorType: '' };
}
if (payload.remainAttempts && payload.result !== 0) {
if (this.controlType.jumpFinger) {
this.fingerText = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id);
}
if (sensor && this.fingerPosition.udSensorCenterYInThousandth !== undefined &&
this.fingerPosition.udSensorRadiusInPx !== undefined) {
if (sensor.sensorType === 'UNDER_SCREEN_SENSOR' ||
sensor.sensorType === 'BOTH_SENSOR' ||
sensor.sensorType === 'SensorType1') {
if (num !== 'first' && payload.remainAttempts > 0 && payload.result != 0) {
setTimeout(() => {
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
}, NOTICE_DELAY);
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id);
}
this.fingerButtonPositionY =
px2vp(this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH * this.screen[1]);
FuncUtils.judgmentOverflow(this.fingerButtonPositionY);
this.fingerPositionY = this.fingerButtonPositionY - this.SYSTEM_STATUS_BAR_HEIGHT -
this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) - PADDING_8;
this.fingerPositionLine = this.fingerPositionY / px2vp(this.screen[1]);
FuncUtils.judgmentOverflow(this.fingerPositionLine);
if (num === 'first' && this.fingerPositionLine > FINGER_SENSOR_POSITION_LINE && payload.result != 0) {
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
}
}
}
}
if (payload.remainAttempts === 0) {
if (num === 'first') {
this.controlType.isShowFinger = false;
} else {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id);
this.fingerText = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id);
}
this.faceFingerLockArr[1] = true;
this.controlType.jumpFinger = false;
this.cancelImage = false;
}
if (payload.result === 0) {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}
}
onCmdDataChange(num?: string): void {
this.cmdData.length > 0 && this.cmdData.map((item) => {
const payload: CmdData = item.payload;
if (payload.type === Constants.noticeTypePin) {
this.clearPassword();
if (payload.remainAttempts) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id);
if (num === 'first' && this.prompt !== (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_recognition').id)) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_use_pwd').id);
}
// 3: pin Residual number
if (payload.remainAttempts < 3 && num !== 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_pwd_error_can_try').id) +
payload.remainAttempts + (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_frequency').id);
}
}
if (payload.remainAttempts === 0 && payload.lockoutDuration) {
// 1: pin lock
this.pinLock = 1;
this.countdown(payload.lockoutDuration);
}
if (!payload.remainAttempts && !payload.lockoutDuration) {
// 1: pin lock
this.pinLock = 1;
}
if (payload.result === 0) {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}
this.handleNoticeTypePin(payload, num);
} else if (payload.type === Constants.noticeTypeFace) {
if (payload.remainAttempts < 5 && payload.remainAttempts > 0) {
if (this.pinLock !== 1) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1').id);
this.faceFingerLockArr[0] = false;
}
}
if (num === 'first') {
if (payload.remainAttempts === 0) {
this.controlType.isShowFace = false;
} else {
if (this.pinLock !== 1) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_recognition').id);
}
}
}
if (payload.remainAttempts === 0) {
if (num !== 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden').id);
}
this.faceFingerLockArr[0] = true;
}
if (payload.result === 0) {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}
this.handleNoticeTypeFace(payload, num);
} else if (payload.type === Constants.noticeTypeFinger) {
let sensor: FingerPosition = { sensorType: '' };
if (payload.sensorInfo && JSON.stringify(payload.sensorInfo) !== '{}') {
sensor = JSON.parse(payload.sensorInfo);
this.fingerPosition = sensor || { sensorType: '' };
}
if (payload.remainAttempts && payload.result !== 0) {
if (this.controlType.jumpFinger) {
this.fingerText = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id);
}
if (sensor && this.fingerPosition.udSensorCenterYInThousandth !== undefined &&
this.fingerPosition.udSensorRadiusInPx !== undefined) {
if (sensor.sensorType === 'UNDER_SCREEN_SENSOR' ||
sensor.sensorType === 'BOTH_SENSOR' ||
sensor.sensorType === 'SensorType1') {
if (num !== 'first' && payload.remainAttempts > 0 && payload.result != 0) {
setTimeout(() => {
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
}, NOTICE_DELAY);
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id);
}
this.fingerButtonPositionY =
px2vp(this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH * this.screen[1]);
FuncUtils.judgmentOverflow(this.fingerButtonPositionY);
this.fingerPositionY = this.fingerButtonPositionY - this.SYSTEM_STATUS_BAR_HEIGHT -
this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) - PADDING_8;
this.fingerPositionLine = this.fingerPositionY / px2vp(this.screen[1]);
FuncUtils.judgmentOverflow(this.fingerPositionLine);
if (num === 'first' && this.fingerPositionLine > FINGER_SENSOR_POSITION_LINE && payload.result != 0) {
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
}
}
}
}
if (payload.remainAttempts === 0) {
if (num === 'first') {
this.controlType.isShowFinger = false;
} else {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id);
this.fingerText = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id);
}
this.faceFingerLockArr[1] = true;
this.controlType.jumpFinger = false;
this.cancelImage = false;
}
if (payload.result === 0) {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}
this.handleNoticeTypeFinger(payload, num)
} else {
LogUtils.error(TAG, 'type: ' + payload.type);
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
@@ -237,15 +249,15 @@ export default struct FullScreen {
this.fingerButtonPositionY = tempPosition / THOUSANDTH;
FuncUtils.judgmentOverflow(this.fingerButtonPositionY);
this.fingerPositionY = this.fingerButtonPositionY - this.SYSTEM_STATUS_BAR_HEIGHT -
this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) - PADDING_8;
this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) - PADDING_8;
FuncUtils.judgmentOverflow(this.fingerPositionY);
this.fingerTipsPositionY = this.fingerButtonPositionY - px2vp(FINGER_Y_POSITION) - FINGER_HIGH -
this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) - PADDING_8;
this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) - PADDING_8;
FuncUtils.judgmentOverflow(this.fingerTipsPositionY);
this.fingerTextPositionY = this.fingerButtonPositionY - px2vp(FINGER_Y_POSITION) - FINGER_TEXT_POSITION -
this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) - PADDING_8;
this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) - PADDING_8;
FuncUtils.judgmentOverflow(this.fingerTextPositionY);
}
@@ -584,7 +596,7 @@ export default struct FullScreen {
this.clearPassword();
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [] ||
(AppStorage.get('wantParams') as WantParams)?.type as string[]);
(AppStorage.get('wantParams') as WantParams)?.type as string[]);
} else if (keyValue === CALL_PHONE) {
if (this.passwordArray.join('').length < PASSWORD_ARRAY_LENGTH) {
return;
@@ -601,8 +613,8 @@ export default struct FullScreen {
.height('37%')
.position({ y: px2vp(this.screen[1] * NUM_KEY_BOTTOM) -
CANCEL_HIGH - MARGIN - px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) -
px2vp((THOUSANDTH - this.fingerPosition.udSensorCenterYInThousandth) / THOUSANDTH * this.screen[1]) -
this.SYSTEM_STATUS_BAR_HEIGHT })
px2vp((THOUSANDTH - this.fingerPosition.udSensorCenterYInThousandth) / THOUSANDTH * this.screen[1]) -
this.SYSTEM_STATUS_BAR_HEIGHT })
} else {
Column() {
NumKeyBoard({
@@ -659,7 +671,7 @@ export default struct FullScreen {
.width(Constants.fullContainerWidth)
.height('37%')
.position({ y: px2vp(this.screen[1] * NUM_KEY_BOTTOM) - CANCEL_HIGH - BOTTOM -
this.SYSTEM_STATUS_BAR_HEIGHT - this.SYSTEM_NAVIGATION_BAR_HEIGHT })
this.SYSTEM_STATUS_BAR_HEIGHT - this.SYSTEM_NAVIGATION_BAR_HEIGHT })
}
} else {
Column() {
@@ -718,17 +730,17 @@ export default struct FullScreen {
.width(Constants.fullContainerWidth)
.height('37%')
.position({ y: px2vp(this.screen[1] * NUM_KEY_POSITION) - CANCEL_HIGH -
this.SYSTEM_STATUS_BAR_HEIGHT })
this.SYSTEM_STATUS_BAR_HEIGHT })
}
}
// 1: pin lock
if (this.controlType.isShowFinger && this.pinLock !== 1 && !this.faceFingerLockArr[1]) {
if (this.fingerPosition.sensorType !== 'OUT_OF_SCREEN_SENSOR' &&
this.fingerPosition.sensorType !== 'NON_SENSOR') {
this.fingerPosition.sensorType !== 'NON_SENSOR') {
if (this.fingerPosition.sensorType === 'UNDER_SCREEN_SENSOR' ||
this.fingerPosition.sensorType === 'BOTH_SENSOR' ||
this.fingerPosition.sensorType === 'SensorType1') {
this.fingerPosition.sensorType === 'BOTH_SENSOR' ||
this.fingerPosition.sensorType === 'SensorType1') {
if (this.fingerPositionLine > FINGER_SENSOR_POSITION_LINE && !this.IS_LANDSCAPE &&
this.fingerPosition.udSensorRadiusInPx !== undefined &&
this.fingerPosition.udSensorCenterYInThousandth !== undefined) {
@@ -745,7 +757,7 @@ export default struct FullScreen {
})
}
.position({ y: px2vp(this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH * this.screen[1]) -
px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) -
px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS) -
CANCEL_HIGH - this.SYSTEM_STATUS_BAR_HEIGHT })
.width(Constants.fullContainerWidth)
.height(this.controlType.isShowFinger ? $r('app.float.finger_high') : '9%')
@@ -774,7 +786,7 @@ export default struct FullScreen {
.justifyContent(FlexAlign.Start)
.alignItems(HorizontalAlign.Center)
.position({ y: px2vp(this.screen[1]) - CANCEL_HIGH - BOTTOM -
this.SYSTEM_STATUS_BAR_HEIGHT - this.SYSTEM_NAVIGATION_BAR_HEIGHT })
this.SYSTEM_STATUS_BAR_HEIGHT - this.SYSTEM_NAVIGATION_BAR_HEIGHT })
}
}
}
@@ -789,18 +801,18 @@ export default struct FullScreen {
Scroll() {
Column() {
Text((AppStorage.get('wantParams') as WantParams)?.title)
.draggable(false)
.fontColor($r('sys.color.ohos_id_color_text_primary_contrary'))
.fontSize($r('sys.float.ohos_id_text_size_sub_title2'))
.fontWeight(FontWeight.Medium)
.draggable(false)
.fontColor($r('sys.color.ohos_id_color_text_primary_contrary'))
.fontSize($r('sys.float.ohos_id_text_size_sub_title2'))
.fontWeight(FontWeight.Medium)
Text(this.fingerText)
.draggable(false)
.height($r('app.float.text_high'))
.fontColor($r('sys.color.ohos_id_color_text_primary_contrary'))
.fontSize($r('sys.float.ohos_id_text_size_body2'))
.fontWeight(FontWeight.Regular)
.textAlign(TextAlign.Center)
.margin({ top: $r('app.float.padding_8') })
.draggable(false)
.height($r('app.float.text_high'))
.fontColor($r('sys.color.ohos_id_color_text_primary_contrary'))
.fontSize($r('sys.float.ohos_id_text_size_body2'))
.fontWeight(FontWeight.Regular)
.textAlign(TextAlign.Center)
.margin({ top: $r('app.float.padding_8') })
}.margin({left: $r('app.float.margin_36'), right: $r('app.float.size_24')})
}
.width('96%')
@@ -842,7 +854,7 @@ export default struct FullScreen {
Image($r('app.media.ic_unlock_fingerprint'))
.draggable(false)
.id('unlockFingerprintImgCustomPwd')
// radius
// radius
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS))
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS))
}.width('100%')
+38 -26
View File
@@ -89,6 +89,41 @@ struct Index {
}
}
handleFaceLocked(): void {
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace]);
if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventUserNavigation, [Constants.noticeTypeFace]);
} else {
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFace]);
}
AppStorage.get<UIExtensionContentSession>('session')?.terminateSelf();
}
handleFingerprintLocked(): void {
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]);
if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventUserNavigation, [Constants.noticeTypeFinger]);
} else {
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]);
}
AppStorage.get<UIExtensionContentSession>('session')?.terminateSelf();
}
handleFaceAndFingerprintLocked(): void {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventWidgetReleased,
[Constants.noticeTypeFinger, Constants.noticeTypeFace]);
if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventUserNavigation,
[Constants.noticeTypeFinger, Constants.noticeTypeFace]);
} else {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger, Constants.noticeTypeFace]);
}
AppStorage.get<UIExtensionContentSession>('session')?.terminateSelf();
}
handleAuthStart(): void {
LogUtils.info(TAG, 'handleAuthStart');
try {
@@ -111,40 +146,17 @@ struct Index {
})
if (that.skipLockedBiometricAuth) {
if (that.authType.length == 1 && that.authType.includes(userAuth.UserAuthType.FACE) && that.isFaceLocked) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace]);
if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventUserNavigation, [Constants.noticeTypeFace]);
} else {
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFace]);
}
AppStorage.get<UIExtensionContentSession>('session')?.terminateSelf();
that.handleFaceLocked();
return;
}
if (that.authType.length == 1 && that.authType.includes(userAuth.UserAuthType.FINGERPRINT) &&
that.isFingerprintLocked) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]);
if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventUserNavigation, [Constants.noticeTypeFinger]);
} else {
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]);
}
AppStorage.get<UIExtensionContentSession>('session')?.terminateSelf();
that.handleFingerprintLocked()
return;
}
if (that.authType.length == 2 && that.authType.includes(userAuth.UserAuthType.FACE) && that.isFaceLocked &&
that.authType.includes(userAuth.UserAuthType.FINGERPRINT) && that.isFingerprintLocked) {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventWidgetReleased,
[Constants.noticeTypeFinger, Constants.noticeTypeFace]);
if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string) {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventUserNavigation,
[Constants.noticeTypeFinger, Constants.noticeTypeFace]);
} else {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger, Constants.noticeTypeFace]);
}
AppStorage.get<UIExtensionContentSession>('session')?.terminateSelf();
that.handleFaceAndFingerprintLocked();
return;
}
}
+146 -126
View File
@@ -227,21 +227,155 @@ export default struct FaceAuth {
pinData = this.textValue;
}
onFontColor(prompt: string, context: Context): Resource {
if (prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id) ||
isColorWarning(prompt: string, context: Context): boolean {
return prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id) ||
prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1').id) ||
prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden').id) ||
prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id)) {
return $r('sys.color.ohos_id_color_warning');
} else if (prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_recognition').id) ||
prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id)
}
isColorTextSecondary(prompt: string, context: Context): boolean {
return prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_recognition').id) ||
prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_recognize_success').id) ||
prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp').id)) {
prompt === context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp').id)
}
onFontColor(prompt: string, context: Context): Resource {
if (this.isColorWarning(prompt,context)) {
return $r('sys.color.ohos_id_color_warning');
} else if (this.isColorTextSecondary(prompt,context)) {
return $r('sys.color.ohos_id_color_text_secondary');
} else {
return $r('sys.color.ohos_id_color_text_secondary');
}
}
handleOtherResult(payload: CmdData,num?: string): void {
if (payload.remainAttempts) {
this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id);
this.textValue = '';
if (num === 'first') {
this.inputValue = '';
}
if (payload.remainAttempts < HINT_TIMES_BY_FAIL_LESS) {
this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_pwd_error_can_try').id) +
payload.remainAttempts + (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_frequency').id);
}
}
if (payload.remainAttempts === 0 && payload.lockoutDuration) {
this.countTime(payload.lockoutDuration);
this.textValue = '';
this.toPin();
this.isEdit = false;
}
}
handleNoticeTypePinExcludesDialogTypeFlag(payload: CmdData,num?: string): void {
if (payload.remainAttempts && payload.result !== 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1').id);
this.faceLock = false;
}
if (num === 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_recognition').id);
}
if (payload.remainAttempts === 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden').id);
this.faceLock = true;
if (this.dialogType === DialogType.ALL || this.dialogType === DialogType.FACE_FINGER_NAVIGATION) {
if (this.skipLockedBiometricAuth || this.fingerLock) {
this.toPin();
}
} else {
if (this.skipLockedBiometricAuth || this.dialogType === DialogType.PIN_FACE) {
this.toPin();
}
}
}
if (payload.result === 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_recognize_success').id);
if (this.dialogType === DialogType.ALL || this.dialogType === DialogType.FACE_FINGER_NAVIGATION) {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace, Constants.noticeTypeFinger]);
} else {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace]);
}
setTimeout(() => {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}, SECOND);
}
}
handleNoticeTypeFingerFlag(payload: CmdData, remainAttempts: number, authResult: number, num?: string): void {
if (payload.sensorInfo && JSON.stringify(payload.sensorInfo) !== '{}') {
this.fingerPosition = JSON.parse(payload.sensorInfo);
const displayClass = display.getDefaultDisplaySync();
this.screen = [displayClass.width, displayClass.height];
switch (JSON.parse(payload.sensorInfo)?.sensorType as string) {
case 'NON_SENSOR':
case 'OUT_OF_SCREEN_SENSOR': {
this.dialogTypeFlag = PIN_FACE;
break;
}
default:
if (this.dialogType !== DialogType.FACE_FINGER_NAVIGATION) {
this.isPinFaceFinger = true;
}
let tempPositionLine = JSON.parse(payload.sensorInfo).udSensorCenterYInThousandth / displayClass.height;
FuncUtils.judgmentOverflow(tempPositionLine);
if (tempPositionLine < FINGER_SENSOR_POSITION_LINE) {
if (!this.IS_LANDSCAPE && ![SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
this.screenType = SCREEN_LAND;
}
} else if (tempPositionLine > FINGER_SENSOR_POSITION_LINE) {
if (!this.IS_LANDSCAPE && ![SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
this.screenType = SCREEN_PORTRAIT;
}
}
break;
}
}
if ((remainAttempts && authResult !== 0) || authResult === Constants.authResultPinExpired) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id);
this.fingerLock = false;
}
if (num === 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_normal_fp_only').id);
}
if (remainAttempts === 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id);
this.fingerLock = true;
if (this.dialogType === DialogType.ALL || this.dialogType === DialogType.FACE_FINGER_NAVIGATION) {
if (this.skipLockedBiometricAuth || this.faceLock) {
this.toPin();
}
} else {
this.toPin();
}
}
if (authResult === 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success').id)
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace, Constants.noticeTypeFinger]);
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFace, Constants.noticeTypeFinger]);
setTimeout(() => {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}, SECOND);
}
}
onCmdDataChange(num?: string): void {
LogUtils.info(TAG, 'onCmdDataChange');
this.cmdData.length > 0 && this.cmdData.map(async (item) => {
@@ -258,26 +392,7 @@ export default struct FaceAuth {
this.textValue = '';
return;
} else {
if (payload.remainAttempts) {
this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id);
this.textValue = '';
if (num === 'first') {
this.inputValue = '';
}
if (payload.remainAttempts < HINT_TIMES_BY_FAIL_LESS) {
this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_pwd_error_can_try').id) +
payload.remainAttempts + (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_frequency').id);
}
}
if (payload.remainAttempts === 0 && payload.lockoutDuration) {
this.countTime(payload.lockoutDuration);
this.textValue = '';
this.toPin();
this.isEdit = false;
}
this.handleOtherResult(payload,num)
}
} else if (payload.type === Constants.noticeTypeFace) {
if ([SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
@@ -289,43 +404,7 @@ export default struct FaceAuth {
this.faceLock = false;
return;
}
if (payload.remainAttempts && payload.result !== 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1').id);
this.faceLock = false;
}
if (num === 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_recognition').id);
}
if (payload.remainAttempts === 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden').id);
this.faceLock = true;
if (this.dialogType === DialogType.ALL || this.dialogType === DialogType.FACE_FINGER_NAVIGATION) {
if (this.skipLockedBiometricAuth || this.fingerLock) {
this.toPin();
}
} else {
if (this.skipLockedBiometricAuth || this.dialogType === DialogType.PIN_FACE) {
this.toPin();
}
}
}
if (payload.result === 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_recognize_success').id);
if (this.dialogType === DialogType.ALL || this.dialogType === DialogType.FACE_FINGER_NAVIGATION) {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace, Constants.noticeTypeFinger]);
} else {
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace]);
}
setTimeout(() => {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}, SECOND);
}
this.handleNoticeTypePinExcludesDialogTypeFlag(payload,num);
} else if (payload.type === Constants.noticeTypeFinger) {
const payload: CmdData = item.payload;
let lockoutDuration: number = 0;
@@ -355,66 +434,7 @@ export default struct FaceAuth {
if ([SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
return;
}
if (payload.sensorInfo && JSON.stringify(payload.sensorInfo) !== '{}') {
this.fingerPosition = JSON.parse(payload.sensorInfo);
const displayClass = display.getDefaultDisplaySync();
this.screen = [displayClass.width, displayClass.height];
switch (JSON.parse(payload.sensorInfo)?.sensorType as string) {
case 'NON_SENSOR':
case 'OUT_OF_SCREEN_SENSOR': {
this.dialogTypeFlag = PIN_FACE;
break;
}
default:
if (this.dialogType !== DialogType.FACE_FINGER_NAVIGATION) {
this.isPinFaceFinger = true;
}
let tempPositionLine = JSON.parse(payload.sensorInfo).udSensorCenterYInThousandth / displayClass.height;
FuncUtils.judgmentOverflow(tempPositionLine);
if (tempPositionLine < FINGER_SENSOR_POSITION_LINE) {
if (!this.IS_LANDSCAPE && ![SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
this.screenType = SCREEN_LAND;
}
} else if (tempPositionLine > FINGER_SENSOR_POSITION_LINE) {
if (!this.IS_LANDSCAPE && ![SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
this.screenType = SCREEN_PORTRAIT;
}
}
break;
}
}
if ((remainAttempts && authResult !== 0) || authResult === Constants.authResultPinExpired) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id);
this.fingerLock = false;
}
if (num === 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_normal_fp_only').id);
}
if (remainAttempts === 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id);
this.fingerLock = true;
if (this.dialogType === DialogType.ALL || this.dialogType === DialogType.FACE_FINGER_NAVIGATION) {
if (this.skipLockedBiometricAuth || this.faceLock) {
this.toPin();
}
} else {
this.toPin();
}
}
if (authResult === 0) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success').id)
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFace, Constants.noticeTypeFinger]);
AuthUtils.getInstance()
.sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFace, Constants.noticeTypeFinger]);
setTimeout(() => {
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
}, SECOND);
}
this.handleNoticeTypeFingerFlag(payload,remainAttempts,authResult,num);
} else {
LogUtils.error(TAG, 'onCmdDataChange default');
(AppStorage.get('session') as UIExtensionContentSession)?.terminateSelf();
@@ -635,7 +655,7 @@ export default struct FaceAuth {
Image($r('app.media.ic_blue_fingerprint'))
.draggable(false)
.id('blueFingerprintImgAllFaceAuth')
// radius
// radius
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
.margin({
@@ -706,7 +726,7 @@ export default struct FaceAuth {
Image($r('app.media.ic_blue_fingerprint'))
.draggable(false)
.id('blueFingerprintImgFaceAuth')
// radius
// radius
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
.margin({ top: $r('app.float.content_padding') })
@@ -832,7 +852,7 @@ export default struct FaceAuth {
Image($r('app.media.ic_blue_fingerprint'))
.draggable(false)
.id('blueFingerprintImgFaceAuth')
// radius
// radius
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
.margin({ top: $r('app.float.content_padding') })
@@ -136,6 +136,89 @@ export default struct FingerprintAuth {
pinData = this.textValue;
}
handleNoticeTypePinOtherAuthResult(lockoutDuration: number, remainAttempts: number, num?: string): void {
if (remainAttempts) {
this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id);
this.textValue = '';
if (num === 'first') {
this.inputValue = '';
}
if (remainAttempts < PIN_FAIL_TIP) {
this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_pwd_error_can_try').id) +
remainAttempts + (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_frequency').id);
}
}
if (remainAttempts === AUTH_LOCK && lockoutDuration) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]);
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]);
this.countTime(lockoutDuration);
this.textValue = '';
this.toPin();
this.isEdit = false;
}
}
handlePinFingerDialogType(): void {
if (this.dialogType === DialogType.PIN_FINGER) {
if (this.pinSubType !== Constants.pinSix) {
this.state = MULTI_PIN;
} else {
this.state = SIX_PIN;
}
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]);
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]);
this.toPin();
}
}
handleOtherSingleAuthResult(): void {
if (this.dialogType === DialogType.PIN_FINGER) {
if (this.pinSubType !== Constants.pinSix) {
this.state = MULTI_PIN;
} else {
this.state = SIX_PIN;
}
this.toPin();
}
}
handleNoticeTypeFingerFirst(payload: CmdData,remainAttempts: number,authResult: number, num?: string): void {
const displayClass = display.getDefaultDisplaySync();
this.screen = [displayClass.width, displayClass.height];
if (payload.sensorInfo && JSON.stringify(payload.sensorInfo) !== '{}') {
this.fingerPosition = JSON.parse(payload.sensorInfo);
switch (this.fingerPosition.sensorType) {
case 'OUT_OF_SCREEN_SENSOR': {
this.isOffFinger = true;
break;
}
default:
let tempPositionLine = JSON.parse(payload.sensorInfo).udSensorCenterYInThousandth / displayClass.height;
FuncUtils.judgmentOverflow(tempPositionLine);
if (tempPositionLine < FINGER_SENSOR_POSITION_LINE) {
this.screenType = ON_SCREEN;
} else if (tempPositionLine > FINGER_SENSOR_POSITION_LINE) {
this.screenType = UNDER_SCREEN;
}
break;
}
}
if ((remainAttempts && authResult !== 0) || authResult === Constants.authResultPinExpired) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id);
this.fingerLock = false;
}
if (num === 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync(this.isOffFinger ?
$r('app.string.unified_authwidget_hint_normal_fp_only').id :
$r('app.string.unified_authwidget_hint_inscreen_fp').id);
}
}
onCmdDataChange(num?: string): void {
this.cmdData.length > 0 && this.cmdData.map((item) => {
const payload: CmdData = item.payload;
@@ -178,79 +261,20 @@ export default struct FingerprintAuth {
this.textValue = '';
return;
} else {
if (remainAttempts) {
this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id);
this.textValue = '';
if (num === 'first') {
this.inputValue = '';
}
if (remainAttempts < PIN_FAIL_TIP) {
this.inputValue = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_pwd_error_can_try').id) +
remainAttempts + (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_frequency').id);
}
}
if (remainAttempts === AUTH_LOCK && lockoutDuration) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]);
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]);
this.countTime(lockoutDuration);
this.textValue = '';
this.toPin();
this.isEdit = false;
}
this.handleNoticeTypePinOtherAuthResult(lockoutDuration, remainAttempts, num);
}
} else if (payload.type === Constants.noticeTypeFinger) {
if ([MULTI_PIN, SIX_PIN].includes(this.state)) {
return;
}
const displayClass = display.getDefaultDisplaySync();
this.screen = [displayClass.width, displayClass.height];
if (payload.sensorInfo && JSON.stringify(payload.sensorInfo) !== '{}') {
this.fingerPosition = JSON.parse(payload.sensorInfo);
switch (this.fingerPosition.sensorType) {
case 'OUT_OF_SCREEN_SENSOR': {
this.isOffFinger = true;
break;
}
default:
let tempPositionLine = JSON.parse(payload.sensorInfo).udSensorCenterYInThousandth / displayClass.height;
FuncUtils.judgmentOverflow(tempPositionLine);
if (tempPositionLine < FINGER_SENSOR_POSITION_LINE) {
this.screenType = ON_SCREEN;
} else if (tempPositionLine > FINGER_SENSOR_POSITION_LINE) {
this.screenType = UNDER_SCREEN;
}
break;
}
}
if ((remainAttempts && authResult !== 0) || authResult === Constants.authResultPinExpired) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id);
this.fingerLock = false;
}
if (num === 'first') {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync(this.isOffFinger ?
$r('app.string.unified_authwidget_hint_normal_fp_only').id :
$r('app.string.unified_authwidget_hint_inscreen_fp').id);
}
this.handleNoticeTypeFingerFirst(payload, remainAttempts, authResult, num);
if (remainAttempts === AUTH_LOCK) {
this.prompt = (AppStorage.get('context') as common.ExtensionContext)?.resourceManager
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden').id);
this.fingerLock = true;
if (payload.tipType === UserAuthTipType.SINGLE_AUTH_RESULT) {
if (this.dialogType === DialogType.PIN_FINGER) {
if (this.pinSubType !== Constants.pinSix) {
this.state = MULTI_PIN;
} else {
this.state = SIX_PIN;
}
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]);
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, [Constants.noticeTypeFinger]);
this.toPin();
}
this.handlePinFingerDialogType();
if ((AppStorage.get('wantParams') as WantParams)?.navigationButtonText as string &&
this.skipLockedBiometricAuth) {
AuthUtils.getInstance().sendNotice(Constants.noticeEventWidgetReleased, [Constants.noticeTypeFinger]);
@@ -266,14 +290,7 @@ export default struct FingerprintAuth {
return;
}
} else {
if (this.dialogType === DialogType.PIN_FINGER) {
if (this.pinSubType !== Constants.pinSix) {
this.state = MULTI_PIN;
} else {
this.state = SIX_PIN;
}
this.toPin();
}
this.handleOtherSingleAuthResult();
}
}
if (authResult === 0) {