From 7a7de9d76c3405a6124eebf230cf0c289b7476b9 Mon Sep 17 00:00:00 2001 From: dengjiewen Date: Tue, 11 Jul 2023 10:15:44 +0800 Subject: [PATCH] update auth_widget code Signed-off-by: dengjiewen --- .gitignore | 9 + OAT.xml | 62 +- build-profile.json5 | 16 +- .../main/ets/common/components/CustomPSD.ets | 741 +++++++----------- .../ets/common/components/NumkeyBoard.ets | 67 +- entry/src/main/ets/common/components/Pwd.ets | 21 +- .../src/main/ets/common/components/SixPwd.ets | 72 +- .../src/main/ets/common/module/DialogType.ts | 29 + entry/src/main/ets/common/utils/AuthUtils.ts | 24 +- entry/src/main/ets/common/utils/FuncUtils.ts | 53 ++ entry/src/main/ets/common/utils/LogUtils.ts | 29 +- entry/src/main/ets/common/utils/TimeUtils.ts | 17 +- entry/src/main/ets/common/vm/Constants.ts | 145 +--- .../ets/extensionability/UserAuthAbility.ts | 29 +- entry/src/main/ets/mainability/MainAbility.ts | 16 +- entry/src/main/ets/pages/Index.ets | 290 ++++--- .../ets/pages/components/CustomPassword.ets | 128 +-- .../main/ets/pages/components/FaceAuth.ets | 662 +++++++++------- .../ets/pages/components/FingerprintAuth.ets | 626 ++++++++------- .../ets/pages/components/PasswordAuth.ets | 184 ++--- entry/src/main/module.json5 | 25 +- .../main/resources/base/element/float.json | 12 + .../main/resources/base/element/string.json | 242 ++---- .../main/resources/en_US/element/string.json | 242 ++---- .../main/resources/zh_CN/element/string.json | 242 ++---- .../ets/extensionability/UserAuthAbility.ts | 49 ++ entry/src/ohosTest/ets/test/Ability.test.ets | 10 +- entry/src/ohosTest/ets/test/Index.test.ets | 122 +++ entry/src/ohosTest/ets/test/List.test.ets | 32 +- .../jsunit/commonUtilsTest/FuncUtils.test.ets | 74 ++ .../jsunit/constantsTest/Constants.test.ets | 31 + .../jsunit/widgetTest/CustomPassword.test.ets | 66 ++ .../widgetTest/CustomPasswordFace.test.ets | 48 ++ .../widgetTest/CustomPasswordFinger.test.ets | 72 ++ .../test/jsunit/widgetTest/FaceAuth.test.ets | 182 +++++ .../widgetTest/FingerprintAuth.test.ets | 155 ++++ .../test/jsunit/widgetTest/PageCom.test.ets | 76 ++ .../jsunit/widgetTest/PasswordAuth.test.ets | 57 ++ .../widgetTest/PasswordAuthSix.test.ets | 54 ++ .../ets/test/uitest/CustomPassword.test.ets | 66 ++ .../ets/test/uitest/FaceAuth.test.ets | 77 ++ .../ets/test/uitest/FingerprintAuth.test.ets | 99 +++ .../ets/test/uitest/PasswordAuth.test.ets | 144 ++++ .../ohosTest/ets/testability/TestAbility.ets | 2 + .../ohosTest/ets/testability/pages/Index.ets | 198 ++++- .../ets/testrunner/OpenHarmonyTestRunner.ts | 2 +- entry/src/ohosTest/module.json5 | 34 +- .../resources/base/element/float.json | 344 ++++++++ .../resources/base/element/image.json | 8 + .../resources/base/element/string.json | 192 ++++- .../resources/base/media/error_faceID.svg | 54 ++ .../resources/base/media/finger_guide.svg | 48 ++ .../resources/base/media/finger_white.svg | 48 ++ .../base/media/ic_blue_fingerprint.svg | 31 + .../resources/base/media/ic_public_cancel.svg | 30 + .../media/ic_public_password_unvisible.svg | 46 ++ .../base/media/ic_public_password_visible.svg | 46 ++ .../resources/base/media/ic_solid_dot.svg | 35 + .../base/media/ic_unlock_fingerprint.svg | 31 + .../resources/base/media/ic_white_cancel.svg | 30 + .../resources/base/media/icon_applock_2.png | Bin 0 -> 11422 bytes .../resources/base/media/icon_applock_3.png | Bin 0 -> 5768 bytes .../resources/base/media/icon_applock_4.png | Bin 0 -> 8717 bytes .../resources/base/media/right_faceID.svg | 30 + .../resources/base/media/white_faceID.svg | 54 ++ .../resources/en_US/element/string.json | 144 ++++ .../resources/zh_CN/element/string.json | 144 ++++ hvigorfile.js | 2 + package.json | 24 +- 69 files changed, 4783 insertions(+), 2191 deletions(-) create mode 100644 .gitignore create mode 100644 entry/src/main/ets/common/module/DialogType.ts create mode 100644 entry/src/main/ets/common/utils/FuncUtils.ts create mode 100644 entry/src/ohosTest/ets/extensionability/UserAuthAbility.ts create mode 100644 entry/src/ohosTest/ets/test/Index.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/commonUtilsTest/FuncUtils.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/constantsTest/Constants.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPassword.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPasswordFace.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPasswordFinger.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/widgetTest/FaceAuth.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/widgetTest/FingerprintAuth.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/widgetTest/PageCom.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/widgetTest/PasswordAuth.test.ets create mode 100644 entry/src/ohosTest/ets/test/jsunit/widgetTest/PasswordAuthSix.test.ets create mode 100644 entry/src/ohosTest/ets/test/uitest/CustomPassword.test.ets create mode 100644 entry/src/ohosTest/ets/test/uitest/FaceAuth.test.ets create mode 100644 entry/src/ohosTest/ets/test/uitest/FingerprintAuth.test.ets create mode 100644 entry/src/ohosTest/ets/test/uitest/PasswordAuth.test.ets create mode 100644 entry/src/ohosTest/resources/base/element/float.json create mode 100644 entry/src/ohosTest/resources/base/element/image.json create mode 100644 entry/src/ohosTest/resources/base/media/error_faceID.svg create mode 100644 entry/src/ohosTest/resources/base/media/finger_guide.svg create mode 100644 entry/src/ohosTest/resources/base/media/finger_white.svg create mode 100644 entry/src/ohosTest/resources/base/media/ic_blue_fingerprint.svg create mode 100644 entry/src/ohosTest/resources/base/media/ic_public_cancel.svg create mode 100644 entry/src/ohosTest/resources/base/media/ic_public_password_unvisible.svg create mode 100644 entry/src/ohosTest/resources/base/media/ic_public_password_visible.svg create mode 100644 entry/src/ohosTest/resources/base/media/ic_solid_dot.svg create mode 100644 entry/src/ohosTest/resources/base/media/ic_unlock_fingerprint.svg create mode 100644 entry/src/ohosTest/resources/base/media/ic_white_cancel.svg create mode 100644 entry/src/ohosTest/resources/base/media/icon_applock_2.png create mode 100644 entry/src/ohosTest/resources/base/media/icon_applock_3.png create mode 100644 entry/src/ohosTest/resources/base/media/icon_applock_4.png create mode 100644 entry/src/ohosTest/resources/base/media/right_faceID.svg create mode 100644 entry/src/ohosTest/resources/base/media/white_faceID.svg create mode 100644 entry/src/ohosTest/resources/en_US/element/string.json create mode 100644 entry/src/ohosTest/resources/zh_CN/element/string.json create mode 100644 hvigorfile.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f8ce57b --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/node_modules +/local.properties +**/local.properties +/.idea +**/build +/.hvigor +.preview +*/.preview +**/package-lock.json \ No newline at end of file diff --git a/OAT.xml b/OAT.xml index d25d866..c88ab41 100644 --- a/OAT.xml +++ b/OAT.xml @@ -1,5 +1,5 @@ - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + diff --git a/build-profile.json5 b/build-profile.json5 index 2edb231..b520fc0 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -15,22 +15,8 @@ { "app": { - "signingConfigs": [ - { - "name": "default", - "material": { - "certpath": "C:\\Users\\ts\\.ohos\\config\\openharmony\\auto_ohos_default_test_com.ohos.useriam.authwidget.cer", - "storePassword": "0000001B95C3BFF9FC66AF4788B56350F08D1C09A84E93313B4122E02C2F546342F0D02159856F3C270AC2", - "keyAlias": "debugKey", - "keyPassword": "0000001BF70E01A0D166CD6A6F57519ED203AF9C7CDFFEDD663346CCA33525440E7427F96EF86592C5961D", - "profile": "C:\\Users\\ts\\.ohos\\config\\openharmony\\auto_ohos_default_test_com.ohos.useriam.authwidget.p7b", - "signAlg": "SHA256withECDSA", - "storeFile": "C:\\Users\\ts\\.ohos\\config\\openharmony\\auto_ohos_default_test_com.ohos.useriam.authwidget.p12" - } - } - ], "compileSdkVersion": 10, - "compatibleSdkVersion": 9, + "compatibleSdkVersion": 10, "products": [ { "name": "default", diff --git a/entry/src/main/ets/common/components/CustomPSD.ets b/entry/src/main/ets/common/components/CustomPSD.ets index ff255cd..1cd070f 100644 --- a/entry/src/main/ets/common/components/CustomPSD.ets +++ b/entry/src/main/ets/common/components/CustomPSD.ets @@ -13,65 +13,79 @@ * limitations under the License. */ +import display from '@ohos.display'; import screen from '@ohos.screen'; import userAuth from '@ohos.userIAM.userAuth'; -import Constants from '../../common/vm/Constants'; +import Constants, { CmdType, FingerPosition } from '../../common/vm/Constants'; +import AuthUtils from '../utils/AuthUtils'; import LogUtils from '../utils/LogUtils'; import TimeUtils from '../utils/TimeUtils'; -import NumKeyBoard from './NumkeyBoard' - -const TAG = "CustomPSD"; - -const CONTROL_TYPE_SIX_NUMBER = 1; -const CONTROL_TYPE_ARBITRARY_NUMBER = 2; +import NumKeyBoard from './NumkeyBoard'; + +const TAG = 'CustomPSD'; +const INTERVAL = 1000; +const DIGITALPSD_IC_DIAMETER = 12; +const THOUSANDTH = 1000; +const TITLE_POSITION = 200; +const FINGER_TEXT_POSITION = 260; +const FINGER_IMG_POSITION = 150; +const THEME_WHITE = 1; +const THEME_BLUR = 2; +const DEL_PWD = -2; +const CALL_PHONE = -1; +const GO_BACK = -3; interface ControlType { isSixPassword?: boolean, isLandscape: boolean, jumpFinger: boolean, - type: number // 1:six number 2:arbitrary number 3:arbitrary character isShowFace: boolean, isShowFinger: boolean, } interface KeyboardType { - index: number - row1: string | Resource - row2?: string - value?: number - bkg?: boolean + index: number, + row1: string | Resource, + row2?: string, + value?: number, + bkg?: boolean, } @Component export default struct CustomPSD { - @Link textValue: string - @Link themeType: number - @Link type: number - @Link controllerFlag: boolean + @Link pinSubType: string; + @Link textValue: string; + @Link themeType: number; @Link authType: Array; - @State lock: number = 0 - @State screenClass: object = {} - @StorageLink('cueWord') cueWord: string = Constants.INPUT_PASSWORD - @StorageLink('passwordArr') passwordArr: string[] = ['', '', '', '', '', ''] - @StorageLink('passwordArrNumber') passwordArrNumber: string[] = [] - @State passwordObj: string = '' - numKeyboard: KeyboardType[] = Constants.NUM_KEY_BOARD; - @State prompt: string = Constants.INPUT_PASSWORD; - @State fingerText: string = Constants.INPUT_FINGER; - @StorageLink('screenLockDirection') screenLockDirection: number = 1 + @Link @Watch('onCmdDataChange') cmdData: Array; + @State lock: number = 0; + @State screenClass: object = {}; + @StorageLink('cueWord') cueWord: string = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_use_pwd')); + @StorageLink('passwordArr') passwordArr: string[] = ['', '', '', '', '', '']; + @StorageLink('passwordArrNumber') passwordArrNumber: string[] = []; + @State passwordObj: string = ''; + numKeyboard: KeyboardType[] = Constants.numKeyBoard; + @State prompt: string = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_use_pwd')); + @State fingerText: string = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp')); + @StorageLink('screenLockDirection') screenLockDirection: number = 1; @State controlType: ControlType = { - type: CONTROL_TYPE_SIX_NUMBER, // 1:six number 2:arbitrary number 3:arbitrary character jumpFinger: false, isLandscape: false, isSixPassword: true, isShowFace: this.authType.includes(2), isShowFinger: this.authType.includes(4) } - controller: CustomDialogController - cancel: () => void - confirm: () => void + @State fingerPosition: FingerPosition = { + sensorType: '' + } + @State screen: number[] = []; + @Consume isLandscape: boolean; + @Consume underFingerPrint: boolean; - queryScreenInfo() { + queryScreenInfo(): void { try { screen.getAllScreens((err, data) => { if (err.code) { @@ -79,371 +93,128 @@ export default struct CustomPSD { return; } this.screenClass = data[0]; - LogUtils.d(TAG, 'success to get all screens. Data: ' + JSON.stringify(this.screenClass)); }); } catch (exception) { LogUtils.e(TAG, 'getAllScreens catch exception: ' + exception); } } - // face or finger - checkPassword(type: String) { - // check callback - let userAuthWidgetMgr; - - try { - let that = this; - userAuthWidgetMgr = userAuth.getUserAuthWidgetMgr(1); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success'); - userAuthWidgetMgr.on('command', { - callback: function (result) { - - LogUtils.d(TAG, 'getUserAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); - const cmdData = JSON.parse(result?.cmdData); - const authType = cmdData?.cmd?.[0]?.payload?.type; - switch (authType) { - case 'pin': - if (cmdData?.cmd?.[0]?.payload?.result !== Constants.USER_AUTH_WIDGET_MGR_SUCCESS) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - that.clearPassword() - if (frequency) { - that.prompt = Constants.ERROR_PASSWORD; - if (frequency < 4) { - that.prompt = `密码错误,还可尝试${frequency}次`; - } - } - // countdown - const time = cmdData?.cmd?.[0]?.payload?.lockoutDuration; - if (frequency === 0 && time) { - that.lock = 1; - that.countdown(time); - } - - if (!frequency && !time) { - that.lock = 1; - } - } else { - // check success - that.lock = 0; - globalThis.session?.terminateSelf(); - } - break; - case 'face': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.RESET_AGAIN; - } - // countdown - if (frequency === 0) { - that.prompt = Constants.FACE_LOCK; - } - } else { - globalThis.session?.terminateSelf(); - } - break; - case 'fingerprint': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.AGAIN_FINGER; - that.fingerText = Constants.AGAIN_FINGER; - } - if (frequency === 0) { - that.prompt = Constants.FINGER_LOCK; - that.fingerText = Constants.FINGER_LOCK; - } - // countdown - - } else { - // check success - that.lock = 0; - globalThis.session?.terminateSelf(); - } - default: - break; + onCmdDataChange(num?: string): void { + this.cmdData.length > 0 && this.cmdData.map((item) => { + const { type,remainAttempts, lockoutDuration,sensorInfo} = item.payload; + switch (type) { + case Constants.noticeTypePin: + this.clearPassword(); + if (remainAttempts) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error')); + if (num === 'first') { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_use_pwd')); + } + if (remainAttempts < 3) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_pwd_error_can_try')) + + remainAttempts + globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_frequency')); + } } - } - }); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success: ' + JSON.stringify(userAuthWidgetMgr)); - } catch (error) { - LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); - } - // check - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'EVENT_AUTH_TYPE_READY', - version: '1', - payload: { - type: [type] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'sendNotice start eventData: ' + jsonEventData); - userAuth.sendNotice(1, jsonEventData); - LogUtils.d(TAG, 'sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); - } - } - - // pin - pinPassword() { - // check callback - let userAuthWidgetMgr; - try { - let that = this; - userAuthWidgetMgr = userAuth.getUserAuthWidgetMgr(1); - LogUtils.d(TAG, 'pinPassword getUserAuthWidgetMgr success'); - userAuthWidgetMgr.on('command', { - callback: function (result) { - - LogUtils.d(TAG, 'pinPassword getUserAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); - const cmdData = JSON.parse(result?.cmdData); - const authType = cmdData?.cmd?.[0]?.payload?.type; - switch (authType) { - case 'pin': - if (cmdData?.cmd?.[0]?.payload?.result !== Constants.USER_AUTH_WIDGET_MGR_SUCCESS) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - that.clearPassword() - if (frequency) { - that.prompt = Constants.ERROR_PASSWORD; - if (frequency < 4) { - that.prompt = `密码错误,还可尝试${frequency}次`; - } - } - // countdown - const time = cmdData?.cmd?.[0]?.payload?.lockoutDuration; - if (frequency === 0 && time) { - that.lock = 1; - that.countdown(time); - } - - if (!frequency && !time) { - that.lock = 1; - } - } else { - // check success - that.lock = 0; - globalThis.session?.terminateSelf(); - } - break; - case 'face': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.RESET_AGAIN; - } - // countdown - if (frequency === 0) { - that.prompt = Constants.FACE_LOCK; - } - } else { - globalThis.session?.terminateSelf(); - } - break; - case 'fingerprint': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.AGAIN_FINGER; - } - if (frequency === 0) { - that.prompt = Constants.FINGER_LOCK; - } - // countdown - - } else { - // check success - that.lock = 0; - globalThis.session?.terminateSelf(); - } - default: - break; + if (remainAttempts === 0 && lockoutDuration) { + this.lock = 1; + this.countdown(lockoutDuration); } - } - }); - LogUtils.d(TAG, 'pinPassword getUserAuthWidgetMgr success: ' + JSON.stringify(userAuthWidgetMgr)); - } catch (error) { - LogUtils.e(TAG, 'pinPassword getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); - } - - // check - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'EVENT_AUTH_TYPE_READY', - version: '1', - payload: { - type: [Constants.NOTICE_TYPE_PIN] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'sendNotice start eventData: ' + jsonEventData); - userAuth.sendNotice(1, jsonEventData); - LogUtils.d(TAG, 'sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); - } - } - - // start - getPosition() { - - // check callback - let userAuthWidgetMgr; - try { - let that = this; - userAuthWidgetMgr = userAuth.getUserAuthWidgetMgr(1); - LogUtils.d(TAG, 'pinPassword getUserAuthWidgetMgr success'); - userAuthWidgetMgr.on('command', { - callback: function (result) { - - LogUtils.d(TAG, 'pinPassword getUserAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); - const cmdData = JSON.parse(result?.cmdData); - const authType = cmdData?.cmd?.[0]?.payload?.type; - switch (authType) { - case 'pin': - if (cmdData?.cmd?.[0]?.payload?.result !== Constants.USER_AUTH_WIDGET_MGR_SUCCESS) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - that.clearPassword() - if (frequency) { - that.prompt = Constants.ERROR_PASSWORD; - if (frequency < 4) { - that.prompt = `密码错误,还可尝试${frequency}次`; - } - } - // countdown - const time = cmdData?.cmd?.[0]?.payload?.lockoutDuration; - if (frequency === 0 && time) { - that.lock = 1; - that.countdown(time); - } - if (!frequency && !time) { - that.lock = 1; - } - } else { - // check success - that.lock = 0; - globalThis.session?.terminateSelf(); - } - break; - case 'face': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.RESET_AGAIN; - } - // countdown - if (frequency === 0) { - that.prompt = Constants.FACE_LOCK; - } - } else { - globalThis.session?.terminateSelf(); - } - break; - case 'fingerprint': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.AGAIN_FINGER; - } - if (frequency === 0) { - that.prompt = Constants.FINGER_LOCK; - } - // countdown - - } else { - // check success - that.lock = 0; - globalThis.session?.terminateSelf(); - } - default: - break; + if (!remainAttempts && !lockoutDuration) { + this.lock = 1; } - } - }); - LogUtils.d(TAG, 'pinPassword getUserAuthWidgetMgr success: ' + JSON.stringify(userAuthWidgetMgr)); - } catch (error) { - LogUtils.e(TAG, 'pinPassword getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); - } - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'CMD_NOTIFY_AUTH_START', - version: Constants.NOTICE_VERSION, - payload: { - type: [Constants.NOTICE_TYPE_FINGER] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'getPosition sendNotice start eventData: ' + jsonEventData); - userAuth.sendNotice(userAuth.NoticeType.WIDGET_NOTICE, jsonEventData); - LogUtils.d(TAG, 'getPosition sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'getPosition sendNotice catch error: ' + JSON.stringify(error)); - } + break; + case Constants.noticeTypeFace: + if (remainAttempts) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1')); + } + if (num === 'first') { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')); + } + if (remainAttempts === 0) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden')); + } + break; + case Constants.noticeTypeFinger: + if (sensorInfo && JSON.stringify(sensorInfo) !== '{}') { + this.fingerPosition = JSON.parse(sensorInfo); + const displayClass = display.getDefaultDisplaySync(); + this.screen = [displayClass.width, displayClass.height]; + } + if (remainAttempts) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2')); + this.fingerText = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2')); + } + if (num === 'first') { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_use_pwd')); + } + if (remainAttempts === 0) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden')); + this.fingerText = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden')); + } + default: + break; + } + }) } - aboutToAppear() { + aboutToAppear(): void { AppStorage.SetOrCreate('passwordArr', ['', '', '', '', '', '']); - this.queryScreenInfo() - this.getPosition() + this.queryScreenInfo(); + AuthUtils.getInstance().sendNotice('CMD_NOTIFY_AUTH_START', [Constants.noticeTypePin]); + if (this.cmdData && this.cmdData.length > 0) { + this.onCmdDataChange('first'); + } if (this.controlType.isShowFace) { - this.checkPassword(Constants.NOTICE_TYPE_FACE) + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]); } } - clearPassword() { + clearPassword(): void { this.passwordArr = []; this.passwordArrNumber = []; this.passwordArr = ['', '', '', '', '', '']; - this.numKeyboard[11].value = Constants.GO_BACK; + this.numKeyboard[11].value = GO_BACK; this.updateStorage(() => { }) } - aboutToDisappear() { - this.clearPassword() - } - - onPageShow() { + aboutToDisappear(): void { + this.clearPassword(); } - countdown(freezingTime) { - const TRY_AGAIN = "后重试" + countdown(freezingTime): void { + const TRY_AGAIN = globalThis.context.resourceManager.getStringSync($r('app.string.unified_authwidget_postretry')); let promptText: string = ''; let freezingMillisecond = freezingTime; if (freezingMillisecond > 0) { - promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond); + promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond, globalThis.context); promptText += TRY_AGAIN; - setTimeout(this.countdown.bind(this), Constants.INTERVAL, freezingTime - 1000) + setTimeout(this.countdown.bind(this), INTERVAL, freezingTime - INTERVAL); } else { - promptText = Constants.INPUT_PASSWORD; - this.clearPassword() + promptText = globalThis.context.resourceManager.getStringSync($r('app.string.unified_authwidget_use_pwd')); + this.clearPassword(); this.lock = 0; } this.prompt = promptText; } - updateStorage(callback) { + updateStorage(callback): void { AppStorage.SetOrCreate('passwordArr', this.passwordArr); AppStorage.SetOrCreate('numKeyboard', this.numKeyboard); - callback() + callback(); } build() { @@ -453,26 +224,30 @@ export default struct CustomPSD { if (this.lock === 1) { Text($r('app.string.unified_authwidget_locked')) .margin({ bottom: '16vp' }) - .fontColor(this.themeType === Constants.THEME_TYPE_WHITE + .fontColor(this.themeType === THEME_WHITE ? $r('sys.color.ohos_id_color_text_primary') : $r('sys.color.ohos_id_color_text_primary_contrary')) .fontSize($r('sys.float.ohos_id_text_size_headline6')) .fontWeight(FontWeight.Medium) } if (this.controlType.isShowFace) { - if (this.themeType === Constants.THEME_TYPE_GAUSSIAN_BLUR) { - Image($r("app.media.white_faceID")) + if (this.themeType === THEME_BLUR) { + Image($r('app.media.white_faceID')) + .id('faceImgCustomPwd') .width('30vp') .height('30vp') .margin({ bottom: '16vp' }) .onClick(() => { - if (this.prompt !== Constants.FACE_LOCK && this.prompt !== Constants.FINGER_LOCK) { - this.checkPassword(Constants.NOTICE_TYPE_FACE) + if (this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden')) && + this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]); } }) } - if (this.themeType === Constants.THEME_TYPE_WHITE) { - Image($r("app.media.error_faceID")) + if (this.themeType === THEME_WHITE) { + Image($r('app.media.error_faceID')) .width('30vp') .height('30vp') .margin({ bottom: '16vp' }) @@ -481,39 +256,44 @@ export default struct CustomPSD { } } Text(this.prompt) - .fontSize(this.cueWord === Constants.INPUT_PASSWORD + .id('cancelIconCustomPSD') + .fontSize(this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_use_pwd')) ? $r('sys.float.ohos_id_text_size_body1') : $r('sys.float.ohos_id_text_size_body2')) .fontWeight(FontWeight.Medium) - .fontColor(this.themeType === Constants.THEME_TYPE_WHITE + .fontColor(this.themeType === THEME_WHITE ? $r('sys.color.ohos_id_color_text_primary') : $r('sys.color.ohos_id_color_text_secondary_contrary')) - .margin({ bottom: "8vp" }) + .margin({ bottom: '8vp' }) .textAlign(TextAlign.Center) .textOverflow({ overflow: TextOverflow.None }) .height('20vp') .onClick(() => { - if (this.prompt === Constants.RESET_AGAIN) { - this.checkPassword(Constants.NOTICE_TYPE_FACE) + if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1'))) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')); + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]); } }) Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { if (this.lock === 0) { - if (this.controlType.type === CONTROL_TYPE_SIX_NUMBER) { - List({ space: Constants.DIGITALPSD_IC_DIAMETER }) { + if (this.pinSubType === Constants.pinSix) { + List({ space: DIGITALPSD_IC_DIAMETER }) { ForEach(this.passwordArr, (item) => { if ((!item || item === '') && item !== 0) { ListItem() { Button() .border({ - color: this.themeType === Constants.THEME_TYPE_WHITE ? Color.Black : Color.White, + color: this.themeType === THEME_WHITE ? Color.Black : Color.White, style: BorderStyle.Solid, width: 1 }) .borderRadius('12vp') - .width("12vp") - .height("12vp") + .width('12vp') + .height('12vp') .type(ButtonType.Circle) .backgroundColor(Color.Transparent) @@ -523,36 +303,36 @@ export default struct CustomPSD { ListItem() { Button() .borderRadius('12vp') - .width("12vp") - .height("12vp") + .width('12vp') + .height('12vp') .type(ButtonType.Circle) - .backgroundColor(this.themeType === Constants.THEME_TYPE_WHITE ? Color.Black : Color.White) + .backgroundColor(this.themeType === THEME_WHITE ? Color.Black : Color.White) } .margin({ left: '5vp', right: '5vp' }) } }) } .listDirection(Axis.Horizontal) - .height("12vp") + .height('12vp') - } else if (this.controlType.type === CONTROL_TYPE_ARBITRARY_NUMBER || this.type === Constants.TYPE_SCREEN_ARBITRARY_NUMBER) { + } else if (this.pinSubType === Constants.pinNumber) { Stack() { TextInput({ placeholder: '', text: this.passwordArrNumber.join('') }) .width('100%') .onChange(async (value: string) => { this.passwordArrNumber = value.replace(/[^\d]/g, '').split(''); }) + .id('pinInputNumber') .onSubmit(async (enterKey: EnterKeyType) => { - let str = this.passwordArrNumber.toString() - this.textValue = str.replace(/,/g, '') + let str = this.passwordArrNumber.toString(); + this.textValue = str.replace(/,/g, ''); if (this.passwordArrNumber.length < 4) { return; } - const strData = this.passwordArrNumber.toString() - this.textValue = strData.replace(/,/g, '') - this.pinPassword() - + const strData = this.passwordArrNumber.toString(); + this.textValue = strData.replace(/,/g, ''); + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); }) .type(InputType.Password) .backgroundImageSize(ImageSize.Auto) @@ -561,7 +341,7 @@ export default struct CustomPSD { .maxLength(32) } - } else if (this.type === Constants.TYPE_SCREEN_ARBITRARY_CHAR) { + } else if (this.pinSubType === Constants.pinMixed) { TextInput({ text: this.passwordObj }) .height('40vp') .type(InputType.Password) @@ -573,12 +353,13 @@ export default struct CustomPSD { if (this.passwordObj.length < 4) { return; } - this.textValue = this.passwordObj - this.pinPassword() + this.textValue = this.passwordObj; + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); }) .onChange((value: string) => { - this.passwordObj = value + this.passwordObj = value; }) + .id('pinInput') } } } @@ -587,12 +368,12 @@ export default struct CustomPSD { .height('40vp') Button(($r('app.string.unified_authwidget_forgotpwd')), { - type: ButtonType.Normal, stateEffect: true }) + .id('forgotBtnCustomPwd') .height('40vp') .backgroundColor(Color.Transparent) - .fontColor(this.themeType === Constants.THEME_TYPE_WHITE + .fontColor(this.themeType === THEME_WHITE ? $r('sys.color.ohos_id_color_text_primary_activated') : $r('sys.color.ohos_id_color_text_primary_contrary')) .fontSize($r('sys.float.ohos_id_text_size_button1')) @@ -604,7 +385,7 @@ export default struct CustomPSD { } Column() { - if (this.lock === 0) { + if (this.lock === 0 && this.pinSubType === Constants.pinSix) { NumKeyBoard({ themeType: $themeType, onKeyPress: (index, callback) => { @@ -614,71 +395,123 @@ export default struct CustomPSD { if (index > -1) { this.passwordArr[index] = keyValue + ''; this.numKeyboard[11].row1 = $r('app.string.unified_authwidget_delete'); - this.numKeyboard[11].value = Constants.DEL_PWD; + this.numKeyboard[11].value = DEL_PWD; if (index === 5) { this.passwordArr[index] = keyValue + ''; if (this.passwordArr.join('').length < 6) { return; } - let str = this.passwordArr.toString() - this.textValue = str.replace(/,/g, '') - this.pinPassword() + let str = this.passwordArr.toString(); + this.textValue = str.replace(/,/g, ''); + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); } this.updateStorage(callback); } - } else if (keyValue === Constants.DEL_PWD) { - const index = this.passwordArr.map(item => item).indexOf('') + } else if (keyValue === DEL_PWD) { + const index = this.passwordArr.map(item => item).indexOf(''); if (index === -1) { - this.passwordArr[5] = '' + this.passwordArr[5] = ''; } else if (index === 1) { - this.passwordArr[index-1] = '' - this.numKeyboard[11].value = Constants.GO_BACK; - this.numKeyboard[11].row1 = Constants.TEXT_BACK; + this.passwordArr[index-1] = ''; + this.numKeyboard[11].value = GO_BACK; + this.numKeyboard[11].row1 = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_back')); } else { - this.passwordArr[index-1] = '' + this.passwordArr[index-1] = ''; } this.updateStorage(callback); - } else if (keyValue === Constants.GO_BACK) { + } else if (keyValue === GO_BACK) { this.lock = 0; - this.clearPassword() - globalThis.session?.terminateSelf(); - } else if (keyValue === Constants.CALL_PHONE) { + this.clearPassword(); + globalThis.session?.terminateSelf?.(); + } else if (keyValue === CALL_PHONE) { if (this.passwordArr.join('').length < 6) { return; } - let str = this.passwordArr.toString() - this.textValue = str.replace(/,/g, '') - this.pinPassword() - this.updateStorage(callback); + let str = this.passwordArr.toString(); + this.textValue = str.replace(/,/g, ''); + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); } } }) } else { - Text().height(Constants.FULL_CONTAINER_HEIGHT) + Text().height(Constants.fullContainerHeight) } } - .width(Constants.FULL_CONTAINER_WIDTH) + .width(Constants.fullContainerWidth) .height('40%') Column() { if (this.controlType.isShowFinger && this.lock !== 1) { - if (this.themeType === Constants.THEME_TYPE_WHITE) { - Image($r("app.media.ic_blue_fingerprint")).width('40vp').height('40vp') - .onClick(() => { - this.checkPassword(Constants.NOTICE_TYPE_FINGER) - }) + + if (this.themeType === THEME_WHITE) { + if (this.fingerPosition.sensorType === 'OUT_OF_SCREEN_SENSOR' + || this.fingerPosition.sensorType === 'BOTH_SENSOR' + || this.fingerPosition.sensorType === 'SensorType1') { + if (this.fingerPosition.udSensorCenterYInThousandth / this.screen[1] > 0.75 && !this.isLandscape) { + Image($r('app.media.ic_blue_fingerprint')) + .id('fingerprintImgCustomPwd') + .width(px2vp(this.fingerPosition.udSensorRadiusInPx)) + .height(px2vp(this.fingerPosition.udSensorRadiusInPx)) + .position({ + x: px2vp(this.fingerPosition.udSensorCenterXInThousandth), + y: px2vp(this.fingerPosition.udSensorCenterYInThousandth) + }) + .onClick(() => { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); + }) + } else { + Image($r('app.media.finger_guide')) + .id('fingerWhiteImgCustomPwd') + .width('24vp') + .height('24vp') + .margin({ top: '12vp' }) + .onClick(() => { + if (this.isLandscape) { + this.underFingerPrint = true; + } + if (!this.isLandscape) { + this.controlType.jumpFinger = true; + } + + }) + } + } } - if (this.themeType === Constants.THEME_TYPE_GAUSSIAN_BLUR) { - Image($r("app.media.finger_white")).width('24vp').height('24vp') - .margin({ top: '12vp' }) - .onClick(() => { - LogUtils.d(TAG, 'screenClass success' + JSON.stringify(this.screenClass)); - const screenInfo = JSON.parse(JSON.stringify(this.screenClass)); - this.controlType.jumpFinger = true - this.controlType.isLandscape = screenInfo.orientation === 2 + if (this.themeType === THEME_BLUR) { + if (this.fingerPosition.sensorType === 'OUT_OF_SCREEN_SENSOR' + || this.fingerPosition.sensorType === 'BOTH_SENSOR' + || this.fingerPosition.sensorType === 'SensorType1') { + if (this.fingerPosition.udSensorCenterYInThousandth / this.screen[1] > 0.75 && !this.isLandscape) { + Image($r('app.media.ic_unlock_fingerprint')) + .id('fingerprintImgCustomPSD') + .width(px2vp(this.fingerPosition.udSensorRadiusInPx)) + .height(px2vp(this.fingerPosition.udSensorRadiusInPx)) + .position({ + x: px2vp(this.fingerPosition.udSensorCenterXInThousandth), + y: px2vp(this.fingerPosition.udSensorCenterYInThousandth) + }) + .onClick(() => { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); + }) + } else { + Image($r('app.media.finger_white')) + .id('fingerWhiteImgCustomPSD') + .width('24vp') + .height('24vp') + .margin({ top: '12vp' }) + .onClick(() => { + if (this.isLandscape) { + this.underFingerPrint = true; + } + if (!this.isLandscape) { + this.controlType.jumpFinger = true; + } + }) + } - }) + } } } @@ -687,52 +520,68 @@ export default struct CustomPSD { .justifyContent(FlexAlign.Start) } .justifyContent(FlexAlign.End) - .width(Constants.FULL_CONTAINER_WIDTH) + .width(Constants.fullContainerWidth) } else if (!this.controlType.isLandscape) { Column() { - Text(globalThis.title) + Text(globalThis.wantParams?.title) .height('40vp') - .fontColor(this.themeType === Constants.THEME_TYPE_WHITE + .fontColor(this.themeType === THEME_WHITE ? $r('sys.color.ohos_id_color_text_primary') : $r('sys.color.ohos_id_color_text_primary_contrary')) .fontSize($r('sys.float.ohos_id_text_size_sub_title2')) .fontWeight(FontWeight.Medium) + .position({ y: TITLE_POSITION }) + .width('100%') + .textAlign(TextAlign.Center) Text(this.fingerText) .height('40vp') - .fontColor(this.themeType === Constants.THEME_TYPE_WHITE + .fontColor(this.themeType === THEME_WHITE ? $r('sys.color.ohos_id_color_text_secondary') : $r('sys.color.ohos_id_color_text_primary_contrary')) .fontSize($r('sys.float.ohos_id_text_size_body2')) - Image($r("app.media.ic_unlock_fingerprint")).width('60vp').height('60vp') - .margin({ "top": "0.00px", "right": "0.00px", "bottom": '90vp', "left": "0.00px" }) + .position({ y: FINGER_TEXT_POSITION }) + .width('100%') + .textAlign(TextAlign.Center) + Image(this.themeType === THEME_WHITE + ? $r('app.media.ic_blue_fingerprint') + : $r('app.media.ic_unlock_fingerprint')) + .id('unlockFingerprintImgCustomPwd') + .width((this.fingerPosition.udSensorRadiusInPx * 2)) + .height((this.fingerPosition.udSensorRadiusInPx * 2)) + .position({ x: FINGER_IMG_POSITION + , y: (this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH * this.screen[1] / 2) }) .onClick(() => { - if (this.prompt !== Constants.FINGER_LOCK) { - this.checkPassword(Constants.NOTICE_TYPE_FINGER) + if (this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); } }) Button($r('app.string.unified_authwidget_cancel'), { type: ButtonType.Normal, stateEffect: true }) - .margin({ bottom: '25vp' }) + .margin({ bottom: '300vp', left: 'auto', right: 'auto' }) .backgroundColor(Color.Transparent) + .fontColor(this.themeType === THEME_WHITE + ? $r('sys.color.ohos_id_color_text_secondary') + : $r('sys.color.ohos_id_color_text_primary_contrary')) .onClick(() => { - this.controlType.jumpFinger = false + this.controlType.jumpFinger = false; }) - }.justifyContent(FlexAlign.End) - .height('300vp') + } + .justifyContent(FlexAlign.End) + .height('100%') .width('100%') - } - else { + } else { Column() { - Text(Constants.FINGER_Landscape) + Text(globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_tip_verify_in_portrait_mode'))) .height('40vp') - .fontColor(this.themeType === Constants.THEME_TYPE_WHITE + .fontColor(this.themeType === THEME_WHITE ? $r('sys.color.ohos_id_color_text_primary') : $r('sys.color.ohos_id_color_text_primary_contrary')) .fontSize($r('sys.float.ohos_id_text_size_sub_title2')) .fontWeight(FontWeight.Medium) - }.justifyContent(FlexAlign.End) .height('300vp') .width('100%') diff --git a/entry/src/main/ets/common/components/NumkeyBoard.ets b/entry/src/main/ets/common/components/NumkeyBoard.ets index 0610a62..36d8b63 100644 --- a/entry/src/main/ets/common/components/NumkeyBoard.ets +++ b/entry/src/main/ets/common/components/NumkeyBoard.ets @@ -14,24 +14,20 @@ */ import deviceInfo from '@ohos.deviceInfo'; -import LogUtils from '../utils/LogUtils'; -import Constants from '../vm/Constants' +import Constants from '../vm/Constants'; -const TAG = 'NumKeyBoard' +const DIGITALPSD_BUTTON_DIAMETER = 60; +const DIGITALPSD_BUTTON_RECT_WH = 100; +const DIGITALPSD_BUTTON_RECT_HH = 50; +const DEL_PWD = -2; +const CALL_PHONE = -1; +const GO_BACK = -3; @Component export default struct NumKeyBoard { - @Link themeType: number + @Link themeType: number; private onKeyPress: (params, callback) => void; - @StorageLink('numKeyboard') numKeyboard: any[] = Constants.NUM_KEY_BOARD; - - aboutToAppear() { - LogUtils.i(TAG, 'aboutToAppear') - } - - aboutToDisappear() { - LogUtils.i(TAG, 'aboutToDisappear') - } + @StorageLink('numKeyboard') numKeyboard: any[] = Constants.numKeyBoard; build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -46,15 +42,15 @@ export default struct NumKeyBoard { alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - if (item.value == Constants.CALL_PHONE || - item.value == Constants.GO_BACK || - item.value == Constants.DEL_PWD) { + if (item.value === CALL_PHONE || + item.value === GO_BACK || + item.value === DEL_PWD) { Text(item.row1) .fontSize($r('app.float.digitalpsd_prompt_fontsize')) .fontWeight(FontWeight.Medium) .fontColor(this.themeType === 1 ? Color.Black : Color.White) .textAlign(TextAlign.Center) - .width(Constants.FULL_CONTAINER_WIDTH) + .width(Constants.fullContainerWidth) .padding(0) .margin(0) } else { @@ -63,7 +59,7 @@ export default struct NumKeyBoard { .fontWeight(FontWeight.Medium) .fontColor(this.themeType === 1 ? Color.Black : Color.White) .textAlign(TextAlign.Center) - .width(Constants.FULL_CONTAINER_WIDTH) + .width(Constants.fullContainerWidth) .padding(0) .margin(0) } @@ -72,33 +68,33 @@ export default struct NumKeyBoard { .fontSize($r('app.float.digitalpsd_row2_fontsize')) .fontWeight(FontWeight.Regular) .fontColor(this.themeType === 1 ? Color.Black : Color.White) - .opacity($r("app.float.numkeyBoard_text_opacity")) + .opacity($r('app.float.numkeyBoard_text_opacity')) .textAlign(TextAlign.Center) - .width(Constants.FULL_CONTAINER_WIDTH) + .width(Constants.fullContainerWidth) .padding(0) .margin(0) } } - .width(Constants.FULL_CONTAINER_WIDTH) + .width(Constants.fullContainerWidth) .height('120px') } if (deviceInfo.deviceType === 'tablet') { - if (item.value == Constants.CALL_PHONE || - item.value == Constants.GO_BACK || - item.value == Constants.DEL_PWD) { + if (item.value === CALL_PHONE || + item.value === GO_BACK || + item.value === DEL_PWD) { Column() { Button({ type: ButtonType.Normal, stateEffect: true }) - .backgroundColor("#00FFFFFF") - .width(Constants.DIGITALPSD_BUTTON_RECT_WH) - .height(Constants.DIGITALPSD_BUTTON_RECT_HH) + .backgroundColor('#00FFFFFF') + .width(DIGITALPSD_BUTTON_RECT_WH) + .height(DIGITALPSD_BUTTON_RECT_HH) } } else { Column() { Button({ type: ButtonType.Circle }) - .backgroundColor("#00FFFFFF") - .width(Constants.DIGITALPSD_BUTTON_DIAMETER) - .height(Constants.DIGITALPSD_BUTTON_DIAMETER) + .backgroundColor('#00FFFFFF') + .width(DIGITALPSD_BUTTON_DIAMETER) + .height(DIGITALPSD_BUTTON_DIAMETER) } } } @@ -107,16 +103,17 @@ export default struct NumKeyBoard { setTimeout(this.onKeyPress.bind(this), 0, item.index, () => { }); }) + .id('numKeyBordCustomPwd') } }) } .columnsTemplate('1fr 1fr 1fr') .rowsTemplate('1fr 1fr 1fr 1fr') - .rowsGap($r("app.float.numkeyBoard_rowsGap")) - .width(Constants.FULL_CONTAINER_WIDTH) - .height(Constants.FULL_CONTAINER_HEIGHT) + .rowsGap($r('app.float.numkeyBoard_rowsGap')) + .width(Constants.fullContainerWidth) + .height(Constants.fullContainerHeight) } - .width(Constants.FULL_CONTAINER_WIDTH) - .height(Constants.FULL_CONTAINER_HEIGHT) + .width(Constants.fullContainerWidth) + .height(Constants.fullContainerHeight) } } \ No newline at end of file diff --git a/entry/src/main/ets/common/components/Pwd.ets b/entry/src/main/ets/common/components/Pwd.ets index 1de8227..66d4907 100644 --- a/entry/src/main/ets/common/components/Pwd.ets +++ b/entry/src/main/ets/common/components/Pwd.ets @@ -17,7 +17,7 @@ import Constants from '../../common/vm/Constants'; @Component export default struct Pwd { - @Link type: number; + @Link pinSubType: string; @Link @Watch('onTextValueChange') textValue: string; @Link inputValue: string; @Link isEdit: boolean; @@ -26,30 +26,30 @@ export default struct Pwd { cancel: () => void; confirm: () => void; - onTextValueChange() { + onTextValueChange(): void { this.passwordArrNumber = this.textValue.replace(/[^\d]/g, '').split(''); } - clearPassword() { + clearPassword(): void { this.passwordArrNumber = []; this.textValue = ''; this.inputValue = ' '; } - aboutToDisappear() { + aboutToDisappear(): void { this.clearPassword(); } build() { Column() { - Text(globalThis.title) + Text(globalThis.wantParams?.title) .margin({ top: $r('app.float.content_padding_top') }) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) .fontWeight(FontWeight.Medium) TextInput({ placeholder: '', - text: this.type === Constants.TYPE_DIALOG_ARBITRARY_NUMBER ? this.passwordArrNumber.join('') : this.textValue + text: this.pinSubType === Constants.pinNumber ? this.passwordArrNumber.join('') : this.textValue }) .maxLength(32) .enabled(this.isEdit) @@ -63,18 +63,19 @@ export default struct Pwd { .textAlign(TextAlign.Center) .fontColor($r('sys.color.ohos_id_color_text_primary')) .border({ - width: this.inputValue == ' ' ? '' : $r('app.float.input_border'), - color: this.inputValue == ' ' ? '' : ($r('sys.color.ohos_id_color_warning')) + width: this.inputValue === ' ' ? '' : $r('app.float.input_border'), + color: this.inputValue === ' ' ? '' : ($r('sys.color.ohos_id_color_warning')) }) .onChange((value: string) => { - if (this.type === Constants.TYPE_DIALOG_ARBITRARY_NUMBER) { + if (this.pinSubType === Constants.pinNumber) { this.passwordArrNumber = value.replace(/[^\d]/g, '').split(''); } this.textValue = value; }) + .id('pinInputMix') Text(this.inputValue) .fontSize($r('sys.float.ohos_id_text_size_body2')) - .margin({ top: $r("app.float.element_margin") }) + .margin({ top: $r('app.float.element_margin') }) .fontColor($r('sys.color.ohos_id_color_warning')) } } diff --git a/entry/src/main/ets/common/components/SixPwd.ets b/entry/src/main/ets/common/components/SixPwd.ets index b56ab01..777c1c8 100644 --- a/entry/src/main/ets/common/components/SixPwd.ets +++ b/entry/src/main/ets/common/components/SixPwd.ets @@ -16,29 +16,29 @@ import userAuth from '@ohos.userIAM.userAuth'; import LogUtils from '../../common/utils/LogUtils'; import Constants from '../../common/vm/Constants'; +import AuthUtils from '../utils/AuthUtils'; import TimeUtils from '../utils/TimeUtils'; const TAG = 'SixPwd'; +const INTERVAL = 1000; @Component export default struct SixPwd { @Link textValue: string; @Link inputValue: string; @Link isEdit: boolean; - @Link controllerFlag: boolean; - cancel: () => void; - confirm: () => void; - countTime(freezingTime) { - const TRY_AGAIN = '后重试'; + countTime(freezingTime): void { + const TRY_AGAIN = globalThis.context.resourceManager.getStringSync($r('app.string.unified_authwidget_postretry')); let promptText: string = ''; let freezingMillisecond = freezingTime; if (freezingMillisecond > 0) { - promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond); - promptText += TRY_AGAIN; - setTimeout(this.countTime.bind(this), 1000, freezingTime - 1000); + promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond, globalThis.context); + promptText = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_many_failures')) + promptText + TRY_AGAIN; + setTimeout(this.countTime.bind(this), INTERVAL, freezingTime - INTERVAL); } else { - promptText = Constants.INPUT_PASSWORD + promptText = ' '; this.isEdit = true; } this.inputValue = promptText; @@ -46,7 +46,7 @@ export default struct SixPwd { build() { Column() { - Text(globalThis.title) + Text(globalThis.wantParams?.title) .margin({ top: $r('app.float.content_padding_top') }) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) @@ -61,21 +61,28 @@ export default struct SixPwd { let userAuthWidgetMgr; try { let that = this; - LogUtils.d(TAG, 'getUserAuthWidgetMgr start'); - userAuthWidgetMgr = await userAuth.getUserAuthWidgetMgr(1); + LogUtils.i(TAG, 'getUserAuthWidgetMgr start'); + userAuthWidgetMgr = await userAuth.getUserAuthWidgetMgr(Constants.userAuthWidgetMgrVersion); userAuthWidgetMgr.on('command', { callback: function (result) { - LogUtils.d(TAG, 'getUserAuthWidgetMgr result: ' + JSON.stringify(result)); - // fail + LogUtils.i(TAG, 'userAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); const cmdData = JSON.parse(result?.cmdData) - if (cmdData?.cmd?.[0]?.payload?.result !== Constants.USER_AUTH_WIDGET_MGR_SUCCESS) { + if (cmdData?.cmd?.[0]?.payload?.result === Constants.userAuthWidgetMgrSuccess) { + // success + globalThis.session?.terminateSelf?.(); + } else { + // fail // frequency const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; if (frequency) { - that.inputValue = Constants.ERROR_PASSWORD; + that.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error')); that.textValue = ''; - if (frequency < 4) { - that.inputValue = `密码错误,还可尝试${frequency}次`; + if (frequency < 3) { + that.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_pwd_error_can_try')) + + frequency + globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_frequency')); } return; } @@ -87,37 +94,19 @@ export default struct SixPwd { that.textValue = ''; return; } - that.inputValue = Constants.ERROR_PASSWORD; + that.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error')); that.textValue = ''; - } else { - // success - that.controllerFlag = true; } } }); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success userAuthWidgetMgr: ' + JSON.stringify(userAuthWidgetMgr)); + LogUtils.i(TAG, 'getUserAuthWidgetMgr success'); } catch (error) { LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); } // check - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'EVENT_AUTH_TYPE_READY', - version: '1', - payload: { - type: ['pin'] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'sendNotice start eventData: ' + jsonEventData); - await userAuth.sendNotice(1, jsonEventData); - LogUtils.d(TAG, 'sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); - } + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); } }) .backgroundImageSize(ImageSize.Auto) @@ -126,6 +115,7 @@ export default struct SixPwd { .visibility(Visibility.Visible) .opacity(0) .caretColor('transparent') + .id('pinSix') List({ space: 4 }) { ForEach(['', '', '', '', '', ''], (item, index) => { ListItem() { @@ -154,7 +144,7 @@ export default struct SixPwd { Text(this.inputValue) .fontSize($r('sys.float.ohos_id_text_size_body2')) - .margin({ top: $r("app.float.element_margin") }) + .margin({ top: $r('app.float.element_margin') }) .fontColor($r('sys.color.ohos_id_color_warning')) } } diff --git a/entry/src/main/ets/common/module/DialogType.ts b/entry/src/main/ets/common/module/DialogType.ts new file mode 100644 index 0000000..e6660c0 --- /dev/null +++ b/entry/src/main/ets/common/module/DialogType.ts @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export enum DialogType { + // only PIN + PIN = 1, + // only FACE + FACE = 2, + // only FINGER + FINGER = 3, + // PIN and FACE + PIN_FACE = 6, + // PIN and FINGER + PIN_FINGER = 7, + // ALL + ALL = 10, +} diff --git a/entry/src/main/ets/common/utils/AuthUtils.ts b/entry/src/main/ets/common/utils/AuthUtils.ts index eb15a14..23af285 100644 --- a/entry/src/main/ets/common/utils/AuthUtils.ts +++ b/entry/src/main/ets/common/utils/AuthUtils.ts @@ -12,6 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import userAuth from '@ohos.userIAM.userAuth'; +import Constants from '../vm/Constants'; +import LogUtils from './LogUtils'; + +const TAG = 'AuthUtils'; export default class AuthUtils { private static authUtilsInstance: AuthUtils; @@ -23,7 +28,22 @@ export default class AuthUtils { return AuthUtils.authUtilsInstance; } - getCurrentAuthMode() { - return 1; + sendNotice(cmd: string, type: Array): void { + try { + const eventData = { + widgetContextId: globalThis.widgetContextId, + event: cmd, + version: Constants.noticeVersion, + payload: { + type: type + } + }; + const jsonEventData = JSON.stringify(eventData); + LogUtils.i(TAG, 'sendNotice start eventData: ' + jsonEventData); + userAuth.sendNotice(userAuth.NoticeType.WIDGET_NOTICE, jsonEventData); + LogUtils.i(TAG, 'sendNotice success'); + } catch (error) { + LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); + } } } \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/FuncUtils.ts b/entry/src/main/ets/common/utils/FuncUtils.ts new file mode 100644 index 0000000..1d4e458 --- /dev/null +++ b/entry/src/main/ets/common/utils/FuncUtils.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import util from '@ohos.util'; +import userAuth from '@ohos.userIAM.userAuth'; +import { DialogType } from '../module/DialogType'; + +export class FuncUtils { + getUint8PW(value: string): Uint8Array { + let textEncoder = new util.TextEncoder(); + return textEncoder.encode(value); + } + + getDialogType(type: Array): DialogType { + if (type) { + if (type.includes(userAuth.UserAuthType.PIN)) { + if (type.includes(userAuth.UserAuthType.FACE)) { + if (type.includes(userAuth.UserAuthType.FINGERPRINT)) { + return DialogType.ALL; + } + return DialogType.PIN_FACE; + } + if (type.includes(userAuth.UserAuthType.FINGERPRINT)) { + return DialogType.PIN_FINGER; + } + return DialogType.PIN; + } + if (type.includes(userAuth.UserAuthType.FINGERPRINT)) { + return DialogType.FINGER; + } + if (type.includes(userAuth.UserAuthType.FACE)) { + return DialogType.FACE; + } + } + return DialogType.PIN; + } +} + +let funcUtils = new FuncUtils(); + +export default funcUtils as FuncUtils; diff --git a/entry/src/main/ets/common/utils/LogUtils.ts b/entry/src/main/ets/common/utils/LogUtils.ts index b58ad2d..0a73c1f 100644 --- a/entry/src/main/ets/common/utils/LogUtils.ts +++ b/entry/src/main/ets/common/utils/LogUtils.ts @@ -28,8 +28,8 @@ import hiLog from '@ohos.hilog'; const DOMAIN: number = 0x002A; -const TAG = "useriam_auth_widget"; -const SYMBOL = " --> "; +const TAG = 'useriam_auth_widget'; +const SYMBOL = ' --> '; /** * log package tool class @@ -40,12 +40,11 @@ export class LogUtils { * * @param tag Identifies the log tag. * @param format Indicates the log format string. - * @param args Indicates the log parameters. * @since 7 */ - d(tag: string, format: string, ...args: any[]) { + d(tag: string, format: string): void { if (LogUtils.isLogGable(hiLog.LogLevel.DEBUG)) { - hiLog.debug(DOMAIN, TAG, tag + SYMBOL + format, args); + hiLog.debug(DOMAIN, TAG, tag + SYMBOL + format); } } @@ -54,12 +53,11 @@ export class LogUtils { * * @param tag Identifies the log tag. * @param format Indicates the log format string. - * @param args Indicates the log parameters. * @since 7 */ - i(tag: string, format: string, ...args: any[]) { + i(tag: string, format: string): void { if (LogUtils.isLogGable(hiLog.LogLevel.INFO)) { - hiLog.info(DOMAIN, TAG, tag + SYMBOL + format, args); + hiLog.info(DOMAIN, TAG, tag + SYMBOL + format); } } @@ -68,12 +66,11 @@ export class LogUtils { * * @param tag Identifies the log tag. * @param format Indicates the log format string. - * @param args Indicates the log parameters. * @since 7 */ - w(tag: string, format: string, ...args: any[]) { + w(tag: string, format: string): void { if (LogUtils.isLogGable(hiLog.LogLevel.WARN)) { - hiLog.warn(DOMAIN, TAG, tag + SYMBOL + format, args); + hiLog.warn(DOMAIN, TAG, tag + SYMBOL + format); } } @@ -82,12 +79,11 @@ export class LogUtils { * * @param tag Identifies the log tag. * @param format Indicates the log format string. - * @param args Indicates the log parameters. * @since 7 */ - e(tag: string, format: string, ...args: any[]) { + e(tag: string, format: string): void { if (LogUtils.isLogGable(hiLog.LogLevel.ERROR)) { - hiLog.error(DOMAIN, TAG, tag + SYMBOL + format, args); + hiLog.error(DOMAIN, TAG, tag + SYMBOL + format); } } @@ -96,12 +92,11 @@ export class LogUtils { * * @param tag Identifies the log tag. * @param format Indicates the log format string. - * @param args Indicates the log parameters. * @since 7 */ - f(tag: string, format: string, ...args: any[]) { + f(tag: string, format: string): void { if (LogUtils.isLogGable(hiLog.LogLevel.FATAL)) { - hiLog.fatal(DOMAIN, TAG, tag + SYMBOL + format, args); + hiLog.fatal(DOMAIN, TAG, tag + SYMBOL + format); } } diff --git a/entry/src/main/ets/common/utils/TimeUtils.ts b/entry/src/main/ets/common/utils/TimeUtils.ts index 68f7c9a..3f14d59 100644 --- a/entry/src/main/ets/common/utils/TimeUtils.ts +++ b/entry/src/main/ets/common/utils/TimeUtils.ts @@ -12,17 +12,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + export class TimeUtils { - getFreezingTimeNm(freezingMillisecond: number): string { - const MINUTE_NM = '分钟'; - const SECOND_NM = '秒'; - let minute = Math.floor(freezingMillisecond / (60 * 1000)); - let second = Math.round((freezingMillisecond % (60 * 1000)) / 1000); + getFreezingTimeNm(freezingMillisecond: number, context: Context): string { + const MINUTE_NM = context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_minutes')); + const SECOND_NM = context?.resourceManager?.getStringSync($r('app.string.unified_authwidget_seconds')); + const ONE_MINUTE = 60; + const RATE = 1000; + let minute = Math.floor(freezingMillisecond / (ONE_MINUTE * RATE)); + let second = Math.round((freezingMillisecond % (ONE_MINUTE * RATE)) / RATE); let timeName = ''; - if (minute != 0) { + if (minute !== 0) { timeName += minute + MINUTE_NM; } - if (second != 0) { + if (second !== 0 && minute < 1) { timeName += second + SECOND_NM; } return timeName; diff --git a/entry/src/main/ets/common/vm/Constants.ts b/entry/src/main/ets/common/vm/Constants.ts index a1966de..f01d8bd 100644 --- a/entry/src/main/ets/common/vm/Constants.ts +++ b/entry/src/main/ets/common/vm/Constants.ts @@ -12,103 +12,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export default class Constants { - static WIN_NAME = "ScreenLockWindow" - - // prompt - static INPUT_PASSWORD = '请输入密码' - static INPUT_FINGER = '请按压屏内指纹感应区验证指纹' - static ERROR_PASSWORD = '密码错误' - static RESET_AGAIN = '未识别成功,点击此处重试' - static FACE_LOCK = '人脸已禁用,请输入密码' - static AGAIN_FINGER = '指纹不匹配,请稍许用力并适当停留' - static FINGER_LOCK = '指纹已禁用,请输入密码' - static FACE_SUCCESS = '人脸识别成功' - static FACE_DOING = '人脸识别中' - static FINGER_SUCCESS = '指纹识别成功' - static FINGER_FAIL = '失败次数过多,指纹已禁用' - static FINGER_Landscape = '请在竖屏状态下进行验证' - - //Shortcut params - static SHORTCUT_CIRCLE_WIDTH = '80px' - static SHORTCUT_CIRCLE_HEIGHT = '80px' - static SHORTCUT_TEXT_SIZE = '24px' - static SHORTCUT_TEXT_WIDTH = '48px' - static SHORTCUT_TEXT_HEIGHT = '34px' - static SHORTCUT_BLOCK_HEIGHT = '10px' - static SHORTCUT_HEIGHT = '150px' - //layout params - Pic - static FULL_CONTAINER_WIDTH = '100%' - static FULL_CONTAINER_HEIGHT = '100%' - static HALF_CONTAINER_WIDTH = '50%' - static NINETY_PERCENT_WIDTH = '90%' +export default class Constants { + static deviceDpi = ['360vp', '780vp']; - //dialog type - //dialog 0:six number 1:arbitrary character 2:arbitrary number - //full 3:six number 4:arbitrary character 5:arbitrary number - static TYPE_DIALOG_SIX_NUMBER = 0; - static TYPE_DIALOG_ARBITRARY_CHAR = 1; - static TYPE_DIALOG_ARBITRARY_NUMBER = 2; - static TYPE_SCREEN_SIX_NUMBER = 3; - static TYPE_SCREEN_ARBITRARY_CHAR = 4; - static TYPE_SCREEN_ARBITRARY_NUMBER = 5; - static TYPE_DIALOG_FACE = 6; + // Pin type + static pinSix = 'PIN_SIX'; + static pinNumber = 'PIN_NUMBER'; + static pinMixed = 'PIN_MIXED'; - //getUserAuthInstance - //param type pin - static USER_AUTH_INSTANCE_TYPE_PIN = 1; - //param type face - static USER_AUTH_INSTANCE_TYPE_FACE = 2; - //param window mode dialog - static USER_AUTH_INSTANCE_WINDOW_MODE_DIALOG = 1; - //param window mode screen - static USER_AUTH_INSTANCE_WINDOW_MODE_SCREEN = 2; - //param trust level 10000 - static USER_AUTH_INSTANCE_TRUST_LEVEL_ALL1 = 10000; + // layout params - Pic + static fullContainerWidth = '100%'; + static fullContainerHeight = '100%'; + static halfContainerWidth = '50%'; + static ninetyPercentWidth = '90%'; - //getUserAuthWidgetMgr - //params - static USER_AUTH_WIDGET_MGR_VERSION = 1; + // getUserAuthWidgetMgr params + static userAuthWidgetMgrVersion = 1; //command result success - static USER_AUTH_WIDGET_MGR_SUCCESS = 0; + static userAuthWidgetMgrSuccess = 0; - //sendNotice param + // sendNotice param + // version + static noticeVersion = '1'; // type - static NOTICE_TYPE = 1; - //version - static NOTICE_VERSION = '1'; - //event to ready - static NOTICE_EVENT_READY = 'EVENT_AUTH_TYPE_READY'; - //type - static NOTICE_TYPE_PIN = 'pin'; - static NOTICE_TYPE_FACE = 'face'; - static NOTICE_TYPE_FINGER = 'fingerprint'; - - //dialog full background type - //1:white 2:Gaussian Blur - static THEME_TYPE_WHITE = 1; - static THEME_TYPE_GAUSSIAN_BLUR = 2; - - //The refresh interval - static INTERVAL = 1000 + static noticeTypePin = 'pin'; + static noticeTypeFace = 'face'; + static noticeTypeFinger = 'fingerprint'; - //digitalpssword mask diameter - static DIGITALPSD_IC_DIAMETER = 12 - //digitalpssword keybord background diameter - static DIGITALPSD_BUTTON_DIAMETER = 60 - - //digitalpssword keybord background diameter - static DIGITALPSD_BUTTON_RECT_WH = 100 - static DIGITALPSD_BUTTON_RECT_HH = 50 - - //digital keybord - static CALL_PHONE = -1 - static DEL_PWD = -2 - static GO_BACK = -3 - static TEXT_BACK = '返回' - static NUM_KEY_BOARD = [ + static numKeyBoard = [ { index: 0, row1: '1', @@ -174,9 +107,9 @@ export default class Constants { }, { index: 9, - row1: '确认', + row1: $r('app.string.unified_authwidget_notarize'), row2: '', - value: Constants.CALL_PHONE, + value: -1, bkg: false }, { @@ -188,22 +121,28 @@ export default class Constants { }, { index: 11, - row1: '返回', - //row1: $r('app.string.back'), + row1: $r('app.string.unified_authwidget_back'), row2: '', - value: Constants.GO_BACK, + value: -3, bkg: false }]; - //max password length - static PASSWORD_MAX_LEN = 32 - static PASSWORD_TEXT_WIDTH = '290px' - static PASSWORD_TEXT_HEIGHT = '40px' - static PASSWORD_TEXT_BORDER = 20 - static ACCOUNT_SPACE = '24px' - static ACCOUNT_SPACE_PORTRAIT = '40px' } -export class StatusBarGroupComponentData { - backgroundColor: string = "#00000000"; - contentColor: string = "#FFFFFFFF"; +export interface FingerPosition { + sensorType: string, + udSensorCenterXInThousandth?: number, + udSensorCenterYInThousandth?: number, + udSensorRadiusInPx?: number +} + +export interface CmdData { + type: string, + remainAttempts: number, + lockoutDuration: number, + sensorInfo?: string +} + +export interface CmdType { + event: string, + payload: CmdData, } \ No newline at end of file diff --git a/entry/src/main/ets/extensionability/UserAuthAbility.ts b/entry/src/main/ets/extensionability/UserAuthAbility.ts index 112940e..a3e4660 100644 --- a/entry/src/main/ets/extensionability/UserAuthAbility.ts +++ b/entry/src/main/ets/extensionability/UserAuthAbility.ts @@ -20,33 +20,30 @@ const TAG = 'UserAuthAbility'; export default class UserAuthAbility extends UserAuthExtensionAbility { onCreate() { - LogUtils.i(TAG, `UserAuthExtensionAbility onCreate context: ` + JSON.stringify(this.context)) + LogUtils.i(TAG, 'UserAuthExtensionAbility onCreate context: ' + JSON.stringify(this.context)); globalThis.context = this.context; } - onForeground() { - LogUtils.i(TAG, `UserAuthExtensionAbility onForeground`) + onForeground(): void { + LogUtils.i(TAG, 'UserAuthExtensionAbility onForeground'); } - onBackground() { - LogUtils.i(TAG, `UserAuthExtensionAbility onBackground`) + onBackground(): void { + LogUtils.i(TAG, 'UserAuthExtensionAbility onBackground'); } - onDestroy() { - LogUtils.i(TAG, `UserAuthExtensionAbility onDestroy`) + onDestroy(): void | Promise { + LogUtils.i(TAG, 'UserAuthExtensionAbility onDestroy'); } - onSessionCreate(want, session) { - LogUtils.i(TAG, `UserAuthExtensionAbility onSessionCreate, want: ${JSON.stringify(want)}`) - let storage: LocalStorage = new LocalStorage({ - 'session': session - }); - globalThis.wantParams = want?.parameters?.wantParams; + onSessionCreate(want, session): void { + LogUtils.i(TAG, 'UserAuthExtensionAbility onSessionCreate want: ' + JSON.stringify(want)); + globalThis.wantParams = want?.parameters?.useriamCmdData; globalThis.session = session; - session.loadContent('pages/Index', storage); + session.loadContent('pages/Index'); } - onSessionDestroy(session) { - LogUtils.i(TAG, `UserAuthExtensionAbility onSessionDestroy`) + onSessionDestroy(session): void { + LogUtils.i(TAG, 'UserAuthExtensionAbility onSessionDestroy'); } } diff --git a/entry/src/main/ets/mainability/MainAbility.ts b/entry/src/main/ets/mainability/MainAbility.ts index e28041b..b78b955 100644 --- a/entry/src/main/ets/mainability/MainAbility.ts +++ b/entry/src/main/ets/mainability/MainAbility.ts @@ -20,16 +20,15 @@ import window from '@ohos.window'; const TAG = 'MainAbility'; export default class MainAbility extends UIAbility { - onCreate(want, launchParam) { + onCreate(): void { LogUtils.i(TAG, 'Ability onCreate'); } - onDestroy() { + onDestroy(): void | Promise { LogUtils.i(TAG, 'Ability onDestroy'); } - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability + onWindowStageCreate(windowStage: window.WindowStage): void { LogUtils.i(TAG, 'Ability onWindowStageCreate'); windowStage.loadContent('pages/Index', (err, data) => { @@ -41,18 +40,15 @@ export default class MainAbility extends UIAbility { }); } - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources + onWindowStageDestroy(): void { LogUtils.i(TAG, 'Ability onWindowStageDestroy'); } - onForeground() { - // Ability has brought to foreground + onForeground(): void { LogUtils.i(TAG, 'Ability onForeground'); } - onBackground() { - // Ability has back to background + onBackground(): void { LogUtils.i(TAG, 'Ability onBackground'); } } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 6bfcb9b..3fbcf64 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -13,161 +13,235 @@ * limitations under the License. */ +import screen from '@ohos.screen'; import userAuth from '@ohos.userIAM.userAuth'; -import window from '@ohos.window' +import window from '@ohos.window'; +import { DialogType } from '../common/module/DialogType'; +import AuthUtils from '../common/utils/AuthUtils'; +import FuncUtils from '../common/utils/FuncUtils'; import LogUtils from '../common/utils/LogUtils'; -import Constants from '../common/vm/Constants'; +import Constants, { CmdType } from '../common/vm/Constants'; import CustomPassword from './components/CustomPassword'; -import FaceAuth from './components/FaceAuth' -import FingerprintAuth from './components/FingerprintAuth' +import FaceAuth from './components/FaceAuth'; +import FingerprintAuth from './components/FingerprintAuth'; import PasswordAuth from './components/PasswordAuth'; const TAG = 'Index'; +const defaultSize = 72; +const THEME_WHITE = 1; +let userAuthWidgetMgr; -let storage = LocalStorage.GetShared() - -@Entry(storage) +@Entry @Component struct Index { - @State authType: Array = [userAuth.UserAuthType.PIN] - @State trust: string = '10000' - @State control_title: string = '请输入密码' - @State navigation_button_text: string = '确定' - @State topHeight: number = 72; - @State bottomHeight: number = 72; - // dialog 0:six number 1:arbitrary character 2:arbitrary number - // full 3:six number 4:arbitrary character 5:arbitrary number - @State type: number = Constants.TYPE_DIALOG_ARBITRARY_NUMBER + @State authType: Array = [userAuth.UserAuthType.PIN]; + @State type: string[] = []; + @State topHeight: number = defaultSize; + @State bottomHeight: number = defaultSize; + @State pinSubType: string = Constants.pinNumber; + @State dialogType: DialogType = DialogType.ALL; + @State windowModeType: string = 'DIALOG_BOX'; // background 1:white 2:Gaussian Blur - @State themeType: number = Constants.THEME_TYPE_WHITE + @State themeType: number = THEME_WHITE; + @State cmdData: Array = []; + @Provide isLandscape: boolean = false; + @Provide underFingerPrint: boolean = false; - randomChallenge() { - let arr = []; - for (let index = 0; index <= 5; index++) { - arr.push(Math.ceil(Math.random() * 9)); + onScreenChange(): void { + try { + screen.getAllScreens((err, data) => { + if (err.code) { + LogUtils.e(TAG, 'Failed to get all screens. Cause: ' + JSON.stringify(err)); + return; + } + this.isLandscape = data[0].orientation === 2; + LogUtils.d(TAG, ' get all screens. result: ' + JSON.stringify(this.isLandscape)); + LogUtils.d(TAG, ' get all screens. result:-- ' + JSON.stringify(data)); + }); + } catch (exception) { + LogUtils.e(TAG, 'getAllScreens catch exception: ' + exception); } - return new Uint8Array(arr); - } - onCancel() { - LogUtils.d(TAG, 'Callback when the first button is clicked') - globalThis.session?.terminateSelf(); - storage?.clear(); } - onAccept() { - LogUtils.d(TAG, 'Callback when the second button is clicked') + handleIsUnder(cmd: []): void { + cmd?.length > 0 && this.cmdData.map((item) => { + const { type,sensorInfo} = item.payload; + if (type === Constants.noticeTypeFinger) { + if (sensorInfo && JSON.stringify(sensorInfo) !== '{}') { + const fingerPosition = JSON.parse(sensorInfo); + if (fingerPosition.sensorType === 'UNDER_SCREEN_SENSOR' + || fingerPosition.sensorType === 'BOTH_SENSOR' + || fingerPosition.sensorType === 'SensorType1') { + if (this.authType.includes(userAuth.UserAuthType.FINGERPRINT) && this.authType.length < 2) { + this.underFingerPrint = true; + } + } + } + } + }) } - existApp() { - LogUtils.d(TAG, 'Click the callback in the blank area') - globalThis.session?.terminateSelf(); - storage?.clear(); + handleAuthStart(): void { + try { + userAuthWidgetMgr = userAuth.getUserAuthWidgetMgr(Constants.userAuthWidgetMgrVersion); + LogUtils.i(TAG, 'getUserAuthWidgetMgr success'); + let that = this; + userAuthWidgetMgr.on('command', { + callback: function (result) { + LogUtils.i(TAG, 'userAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); + const cmdDataObj = JSON.parse(result?.cmdData || '{}'); + if (cmdDataObj?.cmd?.[0]?.payload?.result === Constants.userAuthWidgetMgrSuccess) { + globalThis.session?.terminateSelf(); + } else { + that.cmdData = cmdDataObj?.cmd || []; + that.pinSubType = cmdDataObj?.pinSubType; + that.handleIsUnder(cmdDataObj?.cmd || []); + } + } + }); + } catch (error) { + LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); + } + AuthUtils.getInstance().sendNotice('CMD_NOTIFY_AUTH_START', [Constants.noticeTypePin]); } - aboutToAppear() { + aboutToAppear(): void { LogUtils.d(TAG, 'aboutToAppear'); if (globalThis.wantParams) { - this.getParams(); - LogUtils.d(TAG, 'globalThis.wantParams' + JSON.stringify(globalThis.wantParams)); + this.getParams(globalThis.wantParams); + this.handleAuthStart(); + this.cmdData = globalThis.wantParams?.cmd; + AuthUtils.getInstance().sendNotice('CMD_NOTIFY_AUTH_START', this.type); + LogUtils.d(TAG, 'globalThis.wantParams: ' + JSON.stringify(globalThis.wantParams)); } else { LogUtils.e(TAG, 'aboutToAppear wantParams null'); } + this.getWindowHeight(); + } - try { - window.on('systemBarTintChange', (data) => { - LogUtils.d(TAG, 'Succeeded in enabling the listener for window stage event changes. Data: ' + - JSON.stringify(data)); - for (let i = 0; i < data.regionTint.length; i++) { - let regionData = data.regionTint[i] - if (regionData.type === window.WindowType.TYPE_STATUS_BAR) { - this.topHeight = px2vp(regionData.region.height) - continue - } - if (regionData.type === window.WindowType.TYPE_NAVIGATION_BAR) { - this.bottomHeight = px2vp(regionData.region.top) - continue - } - } + aboutToDisappear(): void { + LogUtils.i(TAG, 'aboutToDisappear'); + if (userAuthWidgetMgr) { + userAuthWidgetMgr.off('command', { + callback: function (result) { + LogUtils.i(TAG, 'aboutToDisappear userAuthWidgetMgr offCommand result: ' + JSON.stringify(result)); + } }); - } catch (exception) { - LogUtils.e(TAG, 'Failed to enable the listener for window stage event changes. Cause:' + - JSON.stringify(exception)); } } - aboutToDisappear() { - LogUtils.d(TAG, 'aboutToDisappear') - } - - onPageShow() { + onPageShow(): void { LogUtils.i(TAG, 'onPageShow'); } - onPageHide() { + onPageHide(): void { LogUtils.i(TAG, 'onPageHide'); } - onBackPress() { + onBackPress(): void { LogUtils.i(TAG, 'onBackPress'); } - getParams() { + getParams(result): void { LogUtils.i(TAG, 'getParams'); - this.authType = globalThis.wantParams.authParam?.authType; - this.trust = globalThis.wantParams.authParam?.authTrustLevel; - this.control_title = globalThis.wantParams.widgetParam?.title; - this.navigation_button_text = globalThis.wantParams.widgetParam?.navigationButtonText; - this.type = globalThis.wantParams.widgetParam?.windowMode; - LogUtils.i(TAG, 'getParams--' + this.type.toString() + JSON.stringify(globalThis.wantParams.authParam) + JSON.stringify(globalThis.wantParams.widgetParam)); + const { pinSubType, windowModeType, cmd, type, widgetContextId } = result; + this.pinSubType = pinSubType; + const newType = type && type.map(item => { + switch (item) { + case Constants.noticeTypePin: + return userAuth.UserAuthType.PIN; + case Constants.noticeTypeFinger: + return userAuth.UserAuthType.FINGERPRINT; + case Constants.noticeTypeFace: + return userAuth.UserAuthType.FACE; + } + }) + globalThis.widgetContextId = widgetContextId; + this.authType = newType; + this.type = type; + this.windowModeType = windowModeType; + this.dialogType = FuncUtils.getDialogType(newType); + this.cmdData = cmd || []; + this.handleIsUnder(cmd || []); + } + + getWindowHeight(): void { + LogUtils.i(TAG, 'getWindowHeight'); + try { + window.on('systemBarTintChange', (data) => { + LogUtils.d(TAG, 'Succeeded in enabling the listener for window stage event changes. Data: ' + + JSON.stringify(data)); + for (let i = 0; i < data.regionTint.length; i++) { + let regionData = data.regionTint[i]; + if (regionData.type === window.WindowType.TYPE_STATUS_BAR) { + this.topHeight = px2vp(regionData.region.height); + continue; + } + if (regionData.type === window.WindowType.TYPE_NAVIGATION_BAR) { + this.bottomHeight = px2vp(regionData.region.top); + continue; + } + } + }); + } catch (exception) { + LogUtils.e(TAG, 'Failed to enable the listener for window stage event changes. Cause:' + + JSON.stringify(exception)); + } } build() { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { - if (userAuth.WindowModeType.DIALOG_BOX === this.type) { - if (this.authType.includes(2)) { - FaceAuth({ - cancel: this.onCancel, - confirm: this.onAccept, - type: $type - }) - } else if (this.authType.includes(4)) { - FingerprintAuth({ - cancel: this.onCancel, - confirm: this.onAccept, - type: $type - }) + if (this.isLandscape && this.underFingerPrint) { + Column() { + Text(globalThis.context.resourceManager.getStringSync($r('app.string.unified_authwidget_tip_verify_in_portrait_mode'))) + .height('40vp') + .fontColor(this.themeType === THEME_WHITE + ? $r('sys.color.ohos_id_color_text_primary') + : $r('sys.color.ohos_id_color_text_primary_contrary')) + .fontSize($r('sys.float.ohos_id_text_size_sub_title2')) + .fontWeight(FontWeight.Medium) + }.justifyContent(FlexAlign.End) + .width(Constants.fullContainerWidth) + .height(Constants.fullContainerWidth) + } else { + if ('DIALOG_BOX' === this.windowModeType) { + if (this.authType.includes(userAuth.UserAuthType.FACE)) { + FaceAuth({ + type: $windowModeType, + pinSubType: $pinSubType, + dialogType: $dialogType, + cmdData: $cmdData, + }) + } else if (this.authType.includes(userAuth.UserAuthType.FINGERPRINT)) { + FingerprintAuth({ + type: $windowModeType, + pinSubType: $pinSubType, + dialogType: $dialogType, + cmdData: $cmdData, + }) + } else { + PasswordAuth({ + pinSubType: $pinSubType, + cmdData: $cmdData + }) + } + } else { - PasswordAuth({ - cancel: this.onCancel, - confirm: this.onAccept, - type: $type + // full screen PIN + CustomPassword({ + themeType: $themeType, + authType: $authType, + pinSubType: $pinSubType, + cmdData: $cmdData, }) } - - } else if (userAuth.WindowModeType.FULLSCREEN === this.type) { - // full screen pin - CustomPassword({ - cancel: this.onCancel, - confirm: this.onCancel, - themeType: $themeType, - type: $type, - authType: $authType - }) - } else if (this.type === 6 || this.type === 9 || this.type === 10) { - // dialog face - FaceAuth({ - cancel: this.onCancel, - confirm: this.onAccept, - type: $type - }) - } else if (this.type === 7 || this.type === 8) { - // dialog finger - } } - .backgroundColor(Color.Pink) - .position({ x: 0, y: this.topHeight }) - .height((this.bottomHeight-this.topHeight)) + .onAreaChange(() => { + this.onScreenChange(); + }) + .backgroundColor(Color.Transparent) + .padding(this.isLandscape ? 0 : { top: this.topHeight, bottom: this.topHeight }) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/components/CustomPassword.ets b/entry/src/main/ets/pages/components/CustomPassword.ets index 690e967..bf0019e 100644 --- a/entry/src/main/ets/pages/components/CustomPassword.ets +++ b/entry/src/main/ets/pages/components/CustomPassword.ets @@ -15,40 +15,33 @@ import account_osAccount from '@ohos.account.osAccount'; import userAuth from '@ohos.userIAM.userAuth'; -import util from '@ohos.util'; import CustomPSD from '../../common/components/CustomPSD' +import FuncUtils from '../../common/utils/FuncUtils'; import LogUtils from '../../common/utils/LogUtils'; import Constants from '../../common/vm/Constants'; const TAG = 'CustomPassword'; - +const WHITE_OPACITY = 1; +const BLUR_OPACITY = 0.2; +const BTN_BORDER_RADIUS = 25; +const THEME_WHITE = 1; let pinAuthManager; let pinData = ''; @Component export default struct CustomPassword { - @Link type: number; + @Link pinSubType: string; @Link themeType: number; @Link authType: Array; - @State @Watch('onFlagChange') controllerFlag: boolean = false; + @Link cmdData: []; + @State isBackTouched: boolean = false @State @Watch('onTextValueChange') textValue: string = ''; - controller: CustomDialogController; - cancel: () => void; - confirm: () => void; - - onFlagChange() { - LogUtils.i(TAG, 'onFlagChange controllerFlag: ' + this.controllerFlag); - if (this.controllerFlag) { - globalThis.session?.terminateSelf(); - } - } - onTextValueChange() { - LogUtils.i(TAG, 'aboutToAppear onTextValueChange this.textValue: ' + this.textValue); + onTextValueChange(): void { pinData = this.textValue; } - aboutToAppear() { + aboutToAppear(): void { // register input try { LogUtils.i(TAG, 'aboutToAppear PINAuth start'); @@ -56,9 +49,8 @@ export default struct CustomPassword { LogUtils.i(TAG, 'aboutToAppear PINAuth pinAuthManager: ' + JSON.stringify(pinAuthManager)); pinAuthManager.registerInputer({ onGetData: (authSubType, callback) => { - let textEncoder = new util.TextEncoder(); - let uint8PW = textEncoder.encode(pinData); - LogUtils.i(TAG, `aboutToAppear PINAuth onGetData pinData:${this.textValue}, uint8PW:${uint8PW}`); + const uint8PW = FuncUtils.getUint8PW(pinData); + LogUtils.i(TAG, 'PINAuth onGetData pinData'); callback.onSetData(authSubType, uint8PW); } }); @@ -67,52 +59,77 @@ export default struct CustomPassword { } } - aboutToDisappear() { + aboutToDisappear(): void { LogUtils.i(TAG, 'aboutToDisappear PINAuth unregisterInputer'); - pinAuthManager?.unregisterInputer?.() + pinAuthManager?.unregisterInputer?.(); } build() { Stack() { - Text().width(Constants.FULL_CONTAINER_WIDTH) - .height(Constants.FULL_CONTAINER_WIDTH) + Text().width(Constants.fullContainerWidth) + .height(Constants.fullContainerWidth) .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) - .opacity(this.themeType === Constants.THEME_TYPE_WHITE ? 1 : 0.2) + .opacity(this.themeType === THEME_WHITE ? WHITE_OPACITY : BLUR_OPACITY) Column() { Flex({ direction: FlexDirection.Row }) { - if (this.themeType === Constants.THEME_TYPE_WHITE) { - Text('←') - .borderRadius(8) - .fontSize($r('app.float.title_size')) - .width($r('app.float.title_size')) - .height($r('app.float.title_size')) - .margin({ left: $r("app.float.element_margin"), right: $r("app.float.element_margin"), top: '2vp' }) - .backgroundColor(Color.Transparent) - .fontColor(Color.Black) - .onClick(() => { - globalThis.session?.terminateSelf(); - }) - Text($r('app.string.back')) - .fontSize($r('app.float.title_size')) - .fontWeight(FontWeight.Medium) - .fontColor(Color.Black) - .textAlign(TextAlign.Center) - .textOverflow({ overflow: TextOverflow.None }) + if (this.themeType === THEME_WHITE) { + Flex() { + Text('←') + .borderRadius(8) + .fontSize($r('app.float.title_size')) + .backgroundColor(Color.Transparent) + .fontColor(Color.Black) + Text($r('app.string.unified_authwidget_back')) + .fontSize($r('app.float.title_size')) + .fontWeight(FontWeight.Medium) + .fontColor(Color.Black) + .textAlign(TextAlign.Center) + .textOverflow({ overflow: TextOverflow.None }) + .margin({ left: 12 }) + } + .id('cancelIconCustomPwd') + .margin({ left: $r('sys.float.ohos_id_max_padding_start'), right: $r('app.float.element_margin'), top: + '2vp' }) + .padding($r('app.float.back_padding')) + .width($r('app.float.back_width')) + .backgroundColor(this.isBackTouched ? $r('sys.color.ohos_id_color_hover') : Color.Transparent) + .borderRadius(BTN_BORDER_RADIUS) + .onClick(() => { + globalThis.session?.terminateSelf?.(); + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isBackTouched = true; + } + if (event.type === TouchType.Up) { + this.isBackTouched = false; + } + }); } else { Image($r('app.media.ic_white_cancel')) - .width($r('app.float.title_size')) - .height($r('app.float.title_size')) - .margin({ left: $r("app.float.element_margin"), top: $r("app.float.element_margin") }) + .id('cancelImgCustomPwd') + .width($r('app.float.image_small')) + .height($r('app.float.image_small')) + .margin({ left: $r('app.float.element_margin'), top: $r('app.float.element_margin') }) + .backgroundColor(this.isBackTouched ? $r('sys.color.ohos_id_color_hover') : Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); + globalThis.session?.terminateSelf?.(); }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.isBackTouched = true; + } + if (event.type === TouchType.Up) { + this.isBackTouched = false; + } + }); } } GridRow({ columns: 8, gutter: { x: 5, y: 10 }, - breakpoints: { value: ['360vp', '780vp'], + breakpoints: { value: Constants.deviceDpi, reference: BreakpointsReference.WindowSize }, direction: GridRowDirection.Row }) { @@ -123,21 +140,20 @@ export default struct CustomPassword { }) { CustomPSD({ themeType: $themeType, - type: $type, textValue: $textValue, - controllerFlag: $controllerFlag, - authType: $authType + authType: $authType, + pinSubType: $pinSubType, + cmdData: $cmdData }) }.margin({ left: 'auto', right: 'auto' }) } - } .justifyContent(FlexAlign.SpaceBetween) - .width(Constants.FULL_CONTAINER_WIDTH) - .height(Constants.FULL_CONTAINER_WIDTH) + .width(Constants.fullContainerWidth) + .height(Constants.fullContainerWidth) } - .width(Constants.FULL_CONTAINER_WIDTH) - .height(Constants.FULL_CONTAINER_WIDTH) + .width(Constants.fullContainerWidth) + .height(Constants.fullContainerWidth) .backdropBlur(80) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/components/FaceAuth.ets b/entry/src/main/ets/pages/components/FaceAuth.ets index f115566..d4cff95 100644 --- a/entry/src/main/ets/pages/components/FaceAuth.ets +++ b/entry/src/main/ets/pages/components/FaceAuth.ets @@ -12,128 +12,75 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import screen from '@ohos.screen'; import account_osAccount from '@ohos.account.osAccount'; -import userAuth from '@ohos.userIAM.userAuth'; +import display from '@ohos.display'; import util from '@ohos.util'; import Pwd from '../../common/components/Pwd' import SixPwd from '../../common/components/SixPwd' +import { DialogType } from '../../common/module/DialogType'; +import AuthUtils from '../../common/utils/AuthUtils'; import LogUtils from '../../common/utils/LogUtils'; import TimeUtils from '../../common/utils/TimeUtils'; -import Constants from '../../common/vm/Constants'; +import Constants, { CmdType, FingerPosition } from '../../common/vm/Constants'; let pinAuthManager; -const TAG = "FaceAuth"; +const TAG = 'FaceAuth'; +const INTERVAL = 1000; +const THOUSANDTH = 1000; +const NORMAL_POSITION = -260; let pinData = ''; @Component export default struct FaceAuth { - @State prompt: string = Constants.FACE_DOING - @State @Watch('onFlagChange') controllerFlag: boolean = false - @State @Watch('onTextValueChange') textValue: string = ""; - @State isEdit: boolean = true + @State prompt: string = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')); + @State @Watch('onTextValueChange') textValue: string = ''; + @Link @Watch('onCmdDataChange') cmdData: Array; + @State isEdit: boolean = true; // 0:six number 1:arbitrary character 2:arbitrary number - @Link type: string - @State inputValue: string = "" - @State flag: boolean = true - @State flagN: number = this.type === '6' ? 1 : (this.type === '10' ? 2 : 6); - controller: CustomDialogController - cancel: () => void - confirm: () => void - - checkPassword(type: String) { - // check callback - let userAuthWidgetMgr; - - try { - let that = this; - userAuthWidgetMgr = userAuth.getUserAuthWidgetMgr(1); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success'); - userAuthWidgetMgr.on('command', { - callback: function (result) { - - LogUtils.d(TAG, 'getUserAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); - const cmdData = JSON.parse(result?.cmdData); - const authType = cmdData?.cmd?.[0]?.payload?.type; - switch (authType) { - case 'face': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.RESET_AGAIN; - } - // countdown - if (frequency === 0) { - that.prompt = Constants.FACE_LOCK; - } - } else { - that.controllerFlag = true; - } - break; - case 'fingerprint': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.AGAIN_FINGER; - } - if (frequency === 0) { - that.prompt = Constants.FINGER_LOCK; - } - // countdown - } else { - // check success - that.controllerFlag = true; - } - default: - break; - } - - } - }); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success: ' + JSON.stringify(userAuthWidgetMgr)); - } catch (error) { - LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); - } - // check - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'EVENT_AUTH_TYPE_READY', - version: '1', - payload: { - type: [type] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'sendNotice start eventData: ' + jsonEventData); - userAuth.sendNotice(1, jsonEventData); - LogUtils.d(TAG, 'sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); - } + @Link type: string; + @Link pinSubType: string; + @Link dialogType: DialogType; + @State inputValue: string = ''; + @State flag: boolean = true; + @State flagN: number = this.dialogType === DialogType.PIN_FACE ? 1 : (this.dialogType === DialogType.ALL ? 2 : 6); + @State screenClass: object = {}; + @State fingerPosition: FingerPosition = { + sensorType: '' } + @State screen: number[] = []; + @Consume isLandscape: boolean; + @Consume underFingerPrint: boolean; - countTime(freezingTime) { - const TRY_AGAIN = "后重试" + countTime(freezingTime): void { + const TRY_AGAIN = globalThis.context.resourceManager.getStringSync($r('app.string.unified_authwidget_postretry')); let promptText: string = ''; let freezingMillisecond = freezingTime; if (freezingMillisecond > 0) { - promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond); - promptText += TRY_AGAIN; - setTimeout(this.countTime.bind(this), 1000, freezingTime - 1000) + promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond, globalThis.context); + promptText = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_many_failures')) + promptText + TRY_AGAIN; + setTimeout(this.countTime.bind(this), INTERVAL, freezingTime - INTERVAL); } else { - promptText = Constants.INPUT_PASSWORD - this.isEdit = true + promptText = ' '; + this.isEdit = true; } this.inputValue = promptText; } - aboutToAppear() { - this.checkPassword(Constants.NOTICE_TYPE_FACE) + aboutToAppear(): void { + if (this.cmdData && this.cmdData.length > 0) { + this.onCmdDataChange('first'); + } + if (this.dialogType === DialogType.PIN_FACE || this.dialogType === DialogType.ALL || + this.dialogType === DialogType.FACE) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')); + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]); + } + try { LogUtils.d(TAG, 'PINAuth start'); pinAuthManager = new account_osAccount.PINAuth(); @@ -150,30 +97,90 @@ export default struct FaceAuth { } } - aboutToDisappear() { - pinAuthManager?.unregisterInputer?.() - } - - onTextValueChange() { - pinData = this.textValue + aboutToDisappear(): void { + pinAuthManager?.unregisterInputer?.(); } - onFlagChange() { - if (this.controllerFlag) { - globalThis.session?.terminateSelf(); - } + onTextValueChange(): void { + pinData = this.textValue; } - onCancel() { - LogUtils.i(TAG, 'onCancel Callback when the first button is clicked') - } - - onAccept() { - LogUtils.i(TAG, 'onAccept Callback when the second button is clicked') - } + onCmdDataChange(num?: string): void { + this.cmdData.length > 0 && this.cmdData.map((item) => { + const { type,remainAttempts, lockoutDuration,sensorInfo} = item.payload; + switch (type) { + case Constants.noticeTypePin: + if (remainAttempts) { + this.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error')); + this.textValue = ''; + if (num === 'first') { + this.inputValue = ''; + } + if (remainAttempts < 3) { + this.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_pwd_error_can_try')) + + remainAttempts + globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_frequency')); + } + } + if (remainAttempts === 0 && lockoutDuration) { + this.countTime(lockoutDuration); + this.isEdit = false; + } + break; + case Constants.noticeTypeFace: + if (remainAttempts) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1')); + } + if (num === 'first') { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')); + } + if (remainAttempts === 0) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden')); + } + break; + case Constants.noticeTypeFinger: + if (sensorInfo && JSON.stringify(sensorInfo) !== '{}') { + this.fingerPosition = JSON.parse(sensorInfo); + const displayClass = display.getDefaultDisplaySync(); + this.screen = [displayClass.width, displayClass.height]; + if ((JSON.parse(sensorInfo).udSensorCenterYInThousandth / displayClass.height < 0.75)) { + try { + screen.getAllScreens((err, data) => { + if (err.code) { + LogUtils.e(TAG, 'Failed to get all screens. Cause: ' + JSON.stringify(err)); + return; + } + if (data[0].orientation !== 2) { + this.flagN = 3; + } + }); + } catch (exception) { + LogUtils.e(TAG, 'getAllScreens catch exception: ' + exception); + } - existApp() { - LogUtils.i(TAG, 'existApp Click the callback in the blank area') + } + } + if (remainAttempts) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2')); + } + if (num === 'first') { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_normal_fp_only')); + } + if (remainAttempts === 0) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden')); + } + default: + break; + } + }) } build() { @@ -181,7 +188,7 @@ export default struct FaceAuth { GridRow({ columns: 8, gutter: { x: 5, y: 10 }, - breakpoints: { value: ['360vp', '780vp'], + breakpoints: { value: Constants.deviceDpi, reference: BreakpointsReference.WindowSize }, direction: GridRowDirection.Row }) { @@ -192,15 +199,16 @@ export default struct FaceAuth { }) { Column() { if (this.flagN === 1) { - // Single face - Text(globalThis.title) + // Single FACE + Text(globalThis.wantParams.title) .fontSize($r('sys.float.ohos_id_text_size_body1')) .margin({ top: $r('app.float.content_padding_top') }) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) .fontWeight(FontWeight.Medium) - if (this.prompt === Constants.FACE_SUCCESS) { - Image($r("app.media.right_faceID")) + if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognize_success'))) { + Image($r('app.media.right_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -210,8 +218,9 @@ export default struct FaceAuth { .colorBlend($r('sys.color.ohos_id_color_activated')) Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_secondary')) - } else if (this.prompt === Constants.RESET_AGAIN) { - Image($r("app.media.error_faceID")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1'))) { + Image($r('app.media.error_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -219,14 +228,17 @@ export default struct FaceAuth { .width($r('app.float.image_size')) .height($r('app.float.image_size')) .colorBlend($r('sys.color.ohos_id_color_activated')) - Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) + Text(this.prompt).id('promptTextResetPinFaceAuth') .fontColor($r('sys.color.ohos_id_color_warning')) .fontSize($r('sys.float.ohos_id_text_size_body2')) .onClick(() => { - this.checkPassword(Constants.NOTICE_TYPE_FACE) + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')); + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]); }) - } else if (this.prompt === Constants.FINGER_LOCK) { - Image($r("app.media.error_faceID")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + Image($r('app.media.error_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -237,8 +249,9 @@ export default struct FaceAuth { Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_warning')) .fontSize($r('sys.float.ohos_id_text_size_body2')) - } else if (this.prompt === Constants.FACE_DOING) { - Image($r("app.media.error_faceID")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition'))) { + Image($r('app.media.error_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -251,48 +264,55 @@ export default struct FaceAuth { } Row() { Column() { - Button($r("app.string.unified_authwidget_cancel"), { stateEffect: true }) + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBtnPinFaceAuth') .margin({ left: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() + globalThis.session?.terminateSelf?.(); }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) Divider() .vertical(true) .height($r('app.float.digitalpsd_passwdmask_height')) - .color($r("sys.color.ohos_id_color_list_separator")) + .color($r('sys.color.ohos_id_color_list_separator')) .width($r('app.float.divider_width')) Column() { Button($r('app.string.unified_authwidget_usepwd')) + .id('usePwdPinFaceAuth') .margin({ right: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - this.flagN = 5 - LogUtils.i(TAG, "flagN: " + this.flagN) + this.inputValue = ' ' + if (this.pinSubType !== Constants.pinSix) { + this.flagN = 4 + } else { + this.flagN = 5 + } + LogUtils.i(TAG, 'flagN: ' + this.flagN) }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) } .height($r('app.float.btn_height')) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } if (this.flagN === 2) { // The first form of facial fingerprint password Flex({ justifyContent: FlexAlign.SpaceBetween }) { - Image($r("app.media.ic_public_cancel")) + Image($r('app.media.ic_public_cancel')) + .id('cancelImgAllFaceAuth') .width($r('app.float.digitalpsd_passwdmask_height')) .height($r('app.float.digitalpsd_passwdmask_height')) .margin({ @@ -300,11 +320,11 @@ export default struct FaceAuth { left: $r('app.float.digitalpsd_passwdmask_height') }) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = "" + globalThis.session?.terminateSelf?.(); + this.textValue = '' }) Button($r('app.string.unified_authwidget_usepwd')) + .id('usePwdBtnAllFaceAuth') .backgroundColor(Color.White) .height($r('app.float.digitalpsd_passwdmask_height')) .padding(0) @@ -316,222 +336,199 @@ export default struct FaceAuth { .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontWeight(FontWeight.Medium) .onClick(() => { - this.flagN = 5 + this.inputValue = ' ' + if (this.pinSubType !== Constants.pinSix) { + this.flagN = 4 + } else { + this.flagN = 5 + } }) } - Image($r("app.media.error_faceID")) + Image($r('app.media.error_faceID')) .width($r('app.float.image_small')) .height($r('app.float.image_small')) .margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') }) .colorBlend($r('sys.color.ohos_id_color_activated')) - Text(globalThis.title).fontSize($r('sys.float.ohos_id_text_size_body1')) + Text(globalThis.wantParams.title).fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) - if (this.prompt === Constants.RESET_AGAIN) { + if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1'))) { Text(this.prompt) - .margin({ top: $r("app.float.element_margin") }) + .id('resetPromptTextAllFaceAuth') + .margin({ top: $r('app.float.element_margin') }) .fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_warning')) .onClick(() => { - this.checkPassword(Constants.NOTICE_TYPE_FACE) + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')); + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]); }) - } else if (this.prompt === Constants.FINGER_LOCK) { + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { Text(this.prompt) - .margin({ top: $r("app.float.element_margin") }) + .margin({ top: $r('app.float.element_margin') }) .fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_warning')) - } else if (this.prompt === Constants.FACE_LOCK) { + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden'))) { Text(this.prompt) - .margin({ top: $r("app.float.element_margin") }) + .margin({ top: $r('app.float.element_margin') }) .fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_warning')) } else { Text(this.prompt) - .margin({ top: $r("app.float.element_margin") }) + .margin({ top: $r('app.float.element_margin') }) .fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_secondary')) } - Image($r("app.media.ic_blue_fingerprint")) - .width($r('app.float.image_medium')) - .height($r('app.float.image_medium')) - .margin({ - top: $r('app.float.digitalpsd_passwdmask_height'), - bottom: $r('app.float.digitalpsd_passwdmask_height') - }) - .onClick(() => { - if (this.prompt !== Constants.FINGER_LOCK) { - this.checkPassword('fingerprint') - } - }) + if (this.isLandscape) { + Image($r('app.media.finger_guide')) + .id('blueFingerprintImgAllFaceAuth') + .width($r('app.float.digitalpsd_passwdmask_height')) + .height($r('app.float.digitalpsd_passwdmask_height')) + .margin({ + top: $r('app.float.digitalpsd_passwdmask_height'), + bottom: $r('app.float.digitalpsd_passwdmask_height') + }) + .onClick(() => { + this.underFingerPrint = true; + }) + } + if (!this.isLandscape) { + Image($r('app.media.ic_blue_fingerprint')) + .id('blueFingerprintImgAllFaceAuth') + .width($r('app.float.image_medium')) + .height($r('app.float.image_medium')) + .margin({ + top: $r('app.float.digitalpsd_passwdmask_height'), + bottom: $r('app.float.digitalpsd_passwdmask_height') + }) + .onClick(() => { + if (this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); + } + }) + } } if (this.flagN === 3) { // Facial fingerprint password, second form - Image($r("app.media.error_faceID")) + Image($r('app.media.error_faceID')) + .id('errFaceImgFaceAuth') .width($r('app.float.image_small')) .height($r('app.float.image_small')) .margin({ top: $r('app.float.content_padding_top'), bottom: $r('app.float.content_padding') }) .colorBlend($r('sys.color.ohos_id_color_activated')) - Text(globalThis.title).fontSize($r('sys.float.ohos_id_text_size_body1')) + Text(globalThis.wantParams.title).fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) - Image($r("app.media.ic_blue_fingerprint")) + Image($r('app.media.ic_blue_fingerprint')) + .id('blueFingerprintImgFaceAuth') .width($r('app.float.image_medium')) .height($r('app.float.image_medium')) .margin({ top: $r('app.float.content_padding') }) .onClick(() => { - if (this.prompt !== Constants.FINGER_LOCK) { - this.checkPassword('fingerprint') - } + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); }) - Text($r('app.string.unified_authwidget_hint_inscreen_fp')) + Text(this.prompt) .margin({ top: $r('app.float.content_padding') }) - .fontColor($r('sys.color.ohos_id_color_text_secondary')) .fontSize($r('sys.float.ohos_id_text_size_body2')) + .fontColor(this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')) + ? $r('sys.color.ohos_id_color_warning') + : $r('sys.color.ohos_id_color_secondary')) Row() { Column() { - Button($r("app.string.unified_authwidget_cancel"), { stateEffect: true }) + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBtnFaceAuth') .margin({ left: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = "" + globalThis.session?.terminateSelf?.(); + this.textValue = '' }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) Divider() .vertical(true) .height($r('app.float.digitalpsd_passwdmask_height')) - .color($r("sys.color.ohos_id_color_list_separator")) + .color($r('sys.color.ohos_id_color_list_separator')) .width($r('app.float.divider_width')) Column() { Button($r('app.string.unified_authwidget_usepwd')) + .id('usePwdBtnFaceAuth') .margin({ right: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() + globalThis.session?.terminateSelf?.(); }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) } .height($r('app.float.btn_height')) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } if (this.flagN === 4) { // Password 32-bit Column() { Pwd({ - type: $type, textValue: $textValue, inputValue: $inputValue, isEdit: $isEdit, + pinSubType: $pinSubType }) Row() { Column() { - Button($r("app.string.unified_authwidget_cancel"), { stateEffect: true }) + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBtnMixedPinFaceAuth') .margin({ left: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = "" + globalThis.session?.terminateSelf?.(); + this.textValue = '' }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) Divider() .vertical(true) .height($r('app.float.digitalpsd_passwdmask_height')) - .color($r("sys.color.ohos_id_color_list_separator")) + .color($r('sys.color.ohos_id_color_list_separator')) .width($r('app.float.divider_width')) Column() { Button($r('app.string.unified_authwidget_confirm')) + .id('okBtnFaceAuth') .margin({ right: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(async (e) => { - // check callback - let userAuthWidgetMgr; - try { - let that = this; - LogUtils.d(TAG, 'getUserAuthWidgetMgr start'); - userAuthWidgetMgr = await userAuth.getUserAuthWidgetMgr(1); - userAuthWidgetMgr.on('command', { - callback: function (result) { - LogUtils.d(TAG, 'getUserAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); - // check fail callback - const cmdData = JSON.parse(result?.cmdData) - if (cmdData?.cmd?.[0]?.payload?.result !== Constants.USER_AUTH_WIDGET_MGR_SUCCESS) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - LogUtils.d(TAG, 'frequency', frequency) - if (frequency) { - that.inputValue = Constants.ERROR_PASSWORD; - that.textValue = '' - if (frequency < 4) { - that.inputValue = `密码错误,还可尝试${frequency}次`; - } - } - // countdown - const time = cmdData?.cmd?.[0]?.payload?.lockoutDuration; - if (frequency === 0 && time) { - that.countTime(time); - that.isEdit = false; - } - } else { - // check success - that.controller.close(); - } - } - }); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success: ' + JSON.stringify(userAuthWidgetMgr)); - } catch (error) { - LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); - } - // check - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'EVENT_AUTH_TYPE_READY', - version: '1', - payload: { - type: ['pin'] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'sendNotice start eventData: ' + jsonEventData); - await userAuth.sendNotice(1, jsonEventData); - LogUtils.d(TAG, 'sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); - } + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) } .height($r('app.float.btn_height')) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } } @@ -541,34 +538,34 @@ export default struct FaceAuth { SixPwd({ textValue: $textValue, inputValue: $inputValue, - isEdit: $isEdit, - controllerFlag: $controllerFlag + isEdit: $isEdit }) Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBtnSixPinFaceAuth') .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = "" + globalThis.session?.terminateSelf?.(); + this.textValue = '' }) .backgroundColor(Color.Transparent) .height($r('app.float.btn_height')) - .width(Constants.HALF_CONTAINER_WIDTH) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .width(Constants.halfContainerWidth) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) .fontSize($r('sys.float.ohos_id_text_size_button1')) .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) } } if (this.flagN === 6) { - // Single face - Text(globalThis.title) + // Single FACE + Text(globalThis.wantParams.title) .fontSize($r('sys.float.ohos_id_text_size_body1')) .margin({ top: $r('app.float.content_padding_top') }) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) .fontWeight(FontWeight.Medium) - if (this.prompt === Constants.FACE_SUCCESS) { - Image($r("app.media.right_faceID")) + if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognize_success'))) { + Image($r('app.media.right_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -578,8 +575,9 @@ export default struct FaceAuth { .colorBlend($r('sys.color.ohos_id_color_activated')) Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_secondary')) - } else if (this.prompt === Constants.RESET_AGAIN) { - Image($r("app.media.error_faceID")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1'))) { + Image($r('app.media.error_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -587,16 +585,21 @@ export default struct FaceAuth { .width($r('app.float.image_size')) .height($r('app.float.image_size')) .colorBlend($r('sys.color.ohos_id_color_activated')) - Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) + Text(this.prompt) + .id('promptTextResetFaceAuth') .fontColor($r('sys.color.ohos_id_color_warning')) .fontSize($r('sys.float.ohos_id_text_size_body2')) .onClick(() => { - if (this.prompt === Constants.RESET_AGAIN) { - this.checkPassword(Constants.NOTICE_TYPE_FACE) + if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1'))) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition')); + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]); } }) - } else if (this.prompt === Constants.FACE_DOING) { - Image($r("app.media.error_faceID")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_recognition'))) { + Image($r('app.media.error_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -606,27 +609,82 @@ export default struct FaceAuth { .colorBlend($r('sys.color.ohos_id_color_activated')) Text(this.prompt).fontColor($r('sys.color.ohos_id_color_text_secondary')) .fontSize($r('sys.float.ohos_id_text_size_body2')) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden'))) { + Image($r('app.media.error_faceID')) + .margin({ + top: $r('app.float.digitalpsd_passwdmask_height'), + bottom: $r('app.float.digitalpsd_passwdmask_height') + }) + .width($r('app.float.image_size')) + .height($r('app.float.image_size')) + .colorBlend($r('sys.color.ohos_id_color_activated')) + Text(this.prompt) + .fontColor($r('sys.color.ohos_id_color_warning')) + .fontSize($r('sys.float.ohos_id_text_size_body2')) } - Row() { - Column() { - Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) - .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - }) - .backgroundColor(Color.Transparent) - .height($r('app.float.btn_height')) - .width(Constants.FULL_CONTAINER_WIDTH) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) - .fontWeight(FontWeight.Medium) + if (!globalThis.wantParams?.navigationButtonText) { + Row() { + Column() { + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBtnAllFace') + .onClick(() => { + globalThis.session?.terminateSelf?.(); + }) + .backgroundColor(Color.Transparent) + .height($r('app.float.btn_height')) + .width(Constants.fullContainerWidth) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) + .fontWeight(FontWeight.Medium) + } } + .height($r('app.float.btn_height')) + .padding({ left: $r('app.float.content_padding'), right: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) + } else { + Row() { + Column() { + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .margin({ left: $r('app.float.content_padding') }) + .width(Constants.ninetyPercentWidth) + .height($r('app.float.btn_height')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) + .fontWeight(FontWeight.Medium) + .backgroundColor(Color.Transparent) + .onClick(() => { + globalThis.session?.terminateSelf?.(); + }) + }.width(Constants.halfContainerWidth) + + Divider() + .vertical(true) + .height($r('app.float.digitalpsd_passwdmask_height')) + .color($r('sys.color.ohos_id_color_list_separator')) + .width($r('app.float.divider_width')) + Column() { + Button(globalThis.wantParams?.navigationButtonText) + .onClick(() => { + globalThis.session?.terminateSelf?.(); + }) + .margin({ right: $r('app.float.content_padding') }) + .width(Constants.ninetyPercentWidth) + .height($r('app.float.btn_height')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) + .fontWeight(FontWeight.Medium) + .backgroundColor(Color.Transparent) + }.width(Constants.halfContainerWidth) + } + .height($r('app.float.btn_height')) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } - .height($r('app.float.btn_height')) - .padding({ left: $r('app.float.content_padding'), right: $r('app.float.content_padding') }) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) } } + .position({ y: this.fingerPosition.udSensorCenterYInThousandth / this.screen[1] < 0.75 && !this.isLandscape + ? (this.fingerPosition.udSensorCenterYInThousandth - THOUSANDTH) + : NORMAL_POSITION }) .backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) .margin({ @@ -637,7 +695,7 @@ export default struct FaceAuth { } } } - .height(Constants.FULL_CONTAINER_HEIGHT) + .height(Constants.fullContainerHeight) .justifyContent(FlexAlign.End) .backgroundColor(Color.Transparent) } diff --git a/entry/src/main/ets/pages/components/FingerprintAuth.ets b/entry/src/main/ets/pages/components/FingerprintAuth.ets index c7a5fe6..e2eef1f 100644 --- a/entry/src/main/ets/pages/components/FingerprintAuth.ets +++ b/entry/src/main/ets/pages/components/FingerprintAuth.ets @@ -14,41 +14,72 @@ */ import account_osAccount from '@ohos.account.osAccount'; -import userAuth from '@ohos.userIAM.userAuth'; -import util from '@ohos.util'; -import Pwd from '../../common/components/Pwd' -import SixPwd from '../../common/components/SixPwd' +import display from '@ohos.display'; +import screen from '@ohos.screen'; +import Pwd from '../../common/components/Pwd'; +import SixPwd from '../../common/components/SixPwd'; +import { DialogType } from '../../common/module/DialogType'; +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 from '../../common/vm/Constants'; +import Constants, { CmdType, FingerPosition } from '../../common/vm/Constants'; + +const TAG = 'FingerprintAuth'; +const INTERVAL = 1000; let pinAuthManager; -const TAG = "FingerprintAuth"; let pinData = ''; +const THOUSANDTH = 1000; +const NORMAL_POSITION = -260; + @Component export default struct FingerprintAuth { - @Link type: string - @State prompt: string = Constants.INPUT_FINGER - @State @Watch('onFlagChange') controllerFlag: boolean = false - @State @Watch('onTextValueChange') textValue: string = ""; - @State isEdit: boolean = true - @State inputValue: string = '' - @State flag: boolean = true - @State state: number = this.type === '7' ? 2 : 1 - controller: CustomDialogController - cancel: () => void - confirm: () => void + @Link type: string; + @Link pinSubType: string; + @Link dialogType: DialogType; + @State prompt: string = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp')); + @State @Watch('onTextValueChange') textValue: string = ''; + @Link @Watch('onCmdDataChange') cmdData: Array; + @State isEdit: boolean = true; + @State inputValue: string = ''; + @State flag: boolean = true; + @State state: number = this.dialogType === DialogType.PIN_FINGER ? (this.flag ? 2 : 3) : (this.flag ? 1 : 3); + @State screenClass: object = {}; + @State fingerPosition: FingerPosition = { + sensorType: '' + } + @State screen: number[] = []; + @Consume isLandscape: boolean; + @Consume underFingerPrint: boolean; + + queryScreenInfo(): void { + try { + screen.getAllScreens((err, data) => { + if (err.code) { + LogUtils.e(TAG, 'Failed to get all screens. Cause: ' + JSON.stringify(err)); + return; + } + this.screenClass = data[0]; + }); + } catch (exception) { + LogUtils.e(TAG, 'getAllScreens catch exception: ' + exception); + } + } - aboutToAppear() { + aboutToAppear(): void { + if (this.cmdData && this.cmdData.length > 0) { + this.onCmdDataChange('first'); + } try { - LogUtils.d(TAG, 'aboutToAppear PINAuth start'); + LogUtils.i(TAG, 'aboutToAppear PINAuth start'); pinAuthManager = new account_osAccount.PINAuth(); - LogUtils.d(TAG, 'aboutToAppear PINAuth new success: ' + pinData); + LogUtils.i(TAG, 'aboutToAppear PINAuth new success: ' + pinData); pinAuthManager.registerInputer({ onGetData: (authSubType, callback) => { - let textEncoder = new util.TextEncoder(); - let uint8PW = textEncoder.encode(pinData); + let uint8PW = FuncUtils.getUint8PW(pinData); callback.onSetData(authSubType, uint8PW); } }); @@ -57,117 +88,101 @@ export default struct FingerprintAuth { } } - aboutToDisappear() { - pinAuthManager?.unregisterInputer?.() + aboutToDisappear(): void { + LogUtils.i(TAG, 'PINAuth unregisterInputer'); + pinAuthManager?.unregisterInputer?.(); } - onTextValueChange() { - pinData = this.textValue + onTextValueChange(): void { + pinData = this.textValue; } - onFlagChange() { - if (this.controllerFlag) { - globalThis.session?.terminateSelf(); - } + onCmdDataChange(num?: string): void { + this.cmdData.length > 0 && this.cmdData.map((item) => { + const { type,remainAttempts, lockoutDuration,sensorInfo } = item.payload; + switch (type) { + case Constants.noticeTypePin: + if (remainAttempts) { + this.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error')); + this.textValue = ''; + if (num === 'first') { + this.inputValue = ''; + } + if (remainAttempts < 3) { + this.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_pwd_error_can_try')) + + remainAttempts + globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_frequency')); + } + } + if (remainAttempts === 0 && lockoutDuration) { + this.countTime(lockoutDuration); + this.isEdit = false; + } + break; + case Constants.noticeTypeFace: + if (remainAttempts) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1')); + } + if (remainAttempts === 0) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_face_forbidden')); + } + break; + case Constants.noticeTypeFinger: + if (sensorInfo && JSON.stringify(sensorInfo) !== '{}') { + this.fingerPosition = JSON.parse(sensorInfo); + switch (this.fingerPosition.sensorType) { + case 'OUT_OF_SCREEN_SENSOR': { + this.flag = false; + break; + } + } + const displayClass = display.getDefaultDisplaySync(); + this.screen = [displayClass.width, displayClass.height]; + } + if (remainAttempts) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2')); + } + if (num === 'first') { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp')); + } + if (remainAttempts === 0) { + this.prompt = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden')); + } + default: + break; + } + }) } - countTime(freezingTime) { - const TRY_AGAIN = "后重试" + countTime(freezingTime): void { + const TRY_AGAIN = globalThis.context.resourceManager.getStringSync($r('app.string.unified_authwidget_postretry')); let promptText: string = ''; let freezingMillisecond = freezingTime; if (freezingMillisecond > 0) { - promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond); - promptText += TRY_AGAIN; - setTimeout(this.countTime.bind(this), 1000, freezingTime - 1000) + promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond, globalThis.context); + promptText = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_many_failures')) + promptText + TRY_AGAIN; + setTimeout(this.countTime.bind(this), INTERVAL, freezingTime - INTERVAL); } else { - promptText = Constants.INPUT_PASSWORD - this.isEdit = true + promptText = ' '; + this.isEdit = true; } this.inputValue = promptText; } - // face or finger - checkPassword(type: String) { - LogUtils.d(TAG, 'getUserAuthWidgetMgr success' + type); - // check callback - let userAuthWidgetMgr; - - try { - let that = this; - userAuthWidgetMgr = userAuth.getUserAuthWidgetMgr(1); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success'); - userAuthWidgetMgr.on('command', { - callback: function (result) { - - LogUtils.d(TAG, 'getUserAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); - const cmdData = JSON.parse(result?.cmdData); - const authType = cmdData?.cmd?.[0]?.payload?.type; - switch (authType) { - case 'face': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.RESET_AGAIN; - } - // countdown - if (frequency === 0) { - that.prompt = Constants.FACE_LOCK; - } - } else { - that.controllerFlag = true; - } - break; - case 'fingerprint': - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.prompt = Constants.AGAIN_FINGER; - } - if (frequency === 0) { - that.prompt = Constants.FINGER_LOCK; - } - // countdown - - } else { - // check success - that.controllerFlag = true; - } - default: - break; - } - } - }); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success: ' + JSON.stringify(userAuthWidgetMgr)); - } catch (error) { - LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); - } - // check - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'EVENT_AUTH_TYPE_READY', - version: '1', - payload: { - type: [type] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'sendNotice start eventData: ' + jsonEventData); - userAuth.sendNotice(1, jsonEventData); - LogUtils.d(TAG, 'sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); - } - } build() { Column() { GridRow({ columns: 8, gutter: { x: 5, y: 10 }, - breakpoints: { value: ['360vp', '780vp'], + breakpoints: { value: Constants.deviceDpi, reference: BreakpointsReference.WindowSize }, direction: GridRowDirection.Row }) { @@ -178,21 +193,21 @@ export default struct FingerprintAuth { }) { Column() { if (this.state === 3) { - Text(globalThis.title) + Text(globalThis.wantParams?.title) .margin({ top: $r('app.float.title_padding_top') }) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) .fontWeight(FontWeight.Medium) Swiper() { - Image($r("app.media.icon_applock_2")) + Image($r('app.media.icon_applock_2')) .width($r('app.float.image_big')) .height($r('app.float.image_big')) .margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') }) - Image($r("app.media.icon_applock_3")) + Image($r('app.media.icon_applock_3')) .width($r('app.float.image_big')) .height($r('app.float.image_big')) .margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') }) - Image($r("app.media.icon_applock_4")) + Image($r('app.media.icon_applock_4')) .width($r('app.float.image_big')) .height($r('app.float.image_big')) .margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') }) @@ -206,52 +221,68 @@ export default struct FingerprintAuth { .fontSize($r('sys.float.ohos_id_text_size_body2')) Row() { Column() { - Button($r("app.string.unified_authwidget_cancel"), { stateEffect: true }) + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBthState3FingerprintAuth') .margin({ left: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = "" + globalThis.session?.terminateSelf?.(); + this.textValue = ''; }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) Divider() .vertical(true) .height($r('app.float.digitalpsd_passwdmask_height')) - .color($r("sys.color.ohos_id_color_list_separator")) + .color($r('sys.color.ohos_id_color_list_separator')) .width($r('app.float.divider_width')) Column() { Button($r('app.string.unified_authwidget_usepwd')) + .id('usePwdBtnState3FingerprintAuth') .margin({ right: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - this.state = 5 + this.state = 5; }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) } .height($r('app.float.btn_height')) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } else if (this.state === 2) { - Text(globalThis.title) + Text(globalThis.wantParams?.title) .margin({ top: $r('app.float.title_padding_top') }) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) .fontWeight(FontWeight.Medium) - if (this.prompt === Constants.FINGER_SUCCESS) { - Image($r("app.media.right_faceID")) + if (this.isLandscape) { + Image($r('app.media.finger_guide')) + .id('blueFingerprint_state1_fingerprintAuth') + .margin({ + top: $r('app.float.digitalpsd_passwdmask_height'), + bottom: $r('app.float.digitalpsd_passwdmask_height') + }) + .width($r('app.float.digitalpsd_passwdmask_height')) + .height($r('app.float.digitalpsd_passwdmask_height')) + .onClick(() => { + this.underFingerPrint = true; + }) + Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) + .fontColor($r('sys.color.ohos_id_color_secondary')) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success'))) { + Image($r('app.media.right_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -261,20 +292,22 @@ export default struct FingerprintAuth { .colorBlend($r('sys.color.ohos_id_color_activated')) Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_secondary')) - } else if (this.prompt === Constants.FINGER_LOCK) { - Image($r("app.media.ic_unlock_fingerprint")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + Image($r('app.media.ic_blue_fingerprint')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') }) .width($r('app.float.image_size')) .height($r('app.float.image_size')) - .colorBlend($r('sys.color.ohos_id_color_activated')) Text(this.prompt) .fontColor($r('sys.color.ohos_id_color_warning')) .fontSize($r('sys.float.ohos_id_text_size_body2')) - } else if (this.prompt === Constants.INPUT_FINGER) { - Image($r("app.media.ic_blue_fingerprint")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp'))) { + Image($r('app.media.ic_blue_fingerprint')) + .id('blueFingerprintImgState2FingerprintAuth') .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -282,62 +315,102 @@ export default struct FingerprintAuth { .width($r('app.float.image_size')) .height($r('app.float.image_size')) .onClick(() => { - if (this.prompt !== Constants.FINGER_LOCK) { - this.checkPassword('fingerprint') + if (this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); } }) Text(this.prompt) .fontColor($r('sys.color.ohos_id_color_primary')) .fontSize($r('sys.float.ohos_id_text_size_body2')) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2'))) { + Image($r('app.media.ic_blue_fingerprint')) + .margin({ + top: $r('app.float.digitalpsd_passwdmask_height'), + bottom: $r('app.float.digitalpsd_passwdmask_height') + }) + .width($r('app.float.image_size')) + .height($r('app.float.image_size')) + .onClick(() => { + if (this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); + } + }) + Text(this.prompt) + .fontColor($r('sys.color.ohos_id_color_warning')) + .fontSize($r('sys.float.ohos_id_text_size_body2')) } Row() { Column() { - Button($r("app.string.unified_authwidget_cancel"), { stateEffect: true }) + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBtnState2FingerprintAuth') .margin({ left: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = "" + globalThis.session?.terminateSelf?.(); + this.textValue = ''; }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) Divider() .vertical(true) .height($r('app.float.digitalpsd_passwdmask_height')) - .color($r("sys.color.ohos_id_color_list_separator")) + .color($r('sys.color.ohos_id_color_list_separator')) .width($r('app.float.divider_width')) Column() { Button($r('app.string.unified_authwidget_usepwd')) + .id('usePwdBtnState2FingerprintAuth') .margin({ right: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - this.inputValue = " " - this.state = 5 + this.inputValue = ' '; + if (this.pinSubType !== Constants.pinSix) { + this.state = 5; + } else { + this.state = 6; + } }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) } .height($r('app.float.btn_height')) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } else if (this.state === 1) { - Text(globalThis.title) + + Text(globalThis.wantParams?.title) .margin({ top: $r('app.float.title_padding_top') }) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) .fontWeight(FontWeight.Medium) - if (this.prompt === Constants.FINGER_SUCCESS) { - Image($r("app.media.right_faceID")) + if (this.isLandscape) { + Image($r('app.media.finger_guide')) + .id('blueFingerprint_state1_fingerprintAuth') + .margin({ + top: $r('app.float.digitalpsd_passwdmask_height'), + bottom: $r('app.float.digitalpsd_passwdmask_height') + }) + .width($r('app.float.image_medium')) + .height($r('app.float.image_medium')) + .onClick(() => { + this.underFingerPrint = true; + }) + Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) + .fontColor($r('sys.color.ohos_id_color_secondary')) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success'))) { + Image($r('app.media.right_faceID')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -347,8 +420,9 @@ export default struct FingerprintAuth { .colorBlend($r('sys.color.ohos_id_color_activated')) Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2')) .fontColor($r('sys.color.ohos_id_color_secondary')) - } else if (this.prompt === Constants.FINGER_FAIL) { - Image($r("app.media.ic_blue_fingerprint")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + Image($r('app.media.ic_blue_fingerprint')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -359,8 +433,10 @@ export default struct FingerprintAuth { Text(this.prompt) .fontColor($r('sys.color.ohos_id_color_warning')) .fontSize($r('sys.float.ohos_id_text_size_body2')) - } else if (this.prompt === Constants.INPUT_FINGER) { - Image($r("app.media.ic_blue_fingerprint")) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp'))) { + Image($r('app.media.ic_blue_fingerprint')) + .id('blueFingerprintState1FingerprintAuth') .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') @@ -368,36 +444,97 @@ export default struct FingerprintAuth { .width($r('app.float.image_size')) .height($r('app.float.image_size')) .onClick(() => { - if (this.prompt !== Constants.FINGER_LOCK) { - this.checkPassword('fingerprint') + if (this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); } }) Text(this.prompt) .fontColor($r('sys.color.ohos_id_color_primary')) .fontSize($r('sys.float.ohos_id_text_size_body2')) + } else if (this.prompt === globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2'))) { + Image($r('app.media.ic_blue_fingerprint')) + .margin({ + top: $r('app.float.digitalpsd_passwdmask_height'), + bottom: $r('app.float.digitalpsd_passwdmask_height') + }) + .width($r('app.float.image_size')) + .height($r('app.float.image_size')) + .onClick(() => { + if (this.prompt !== globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]); + } + }) + Text(this.prompt) + .fontColor($r('sys.color.ohos_id_color_warning')) + .fontSize($r('sys.float.ohos_id_text_size_body2')) } - Row() { - Column() { - Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) - .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - }) - .backgroundColor(Color.Transparent) - .height($r('app.float.btn_height')) - .width(Constants.FULL_CONTAINER_HEIGHT) - .fontSize($r('sys.float.ohos_id_text_size_button1')) - .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) - .fontWeight(FontWeight.Medium) + if (!globalThis.wantParams?.navigationButtonText) { + Row() { + Column() { + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('usePwdBtnState1FingerprintAuth') + .onClick(() => { + globalThis.session?.terminateSelf?.(); + }) + .backgroundColor(Color.Transparent) + .height($r('app.float.btn_height')) + .width(Constants.fullContainerHeight) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) + .fontWeight(FontWeight.Medium) + } + } + .height($r('app.float.btn_height')) + .padding({ left: $r('app.float.content_padding'), right: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) + } else { + Row() { + Column() { + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBtnState1FingerprintAuth') + .margin({ left: $r('app.float.content_padding') }) + .width(Constants.ninetyPercentWidth) + .height($r('app.float.btn_height')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) + .fontWeight(FontWeight.Medium) + .backgroundColor(Color.Transparent) + .onClick(() => { + globalThis.session?.terminateSelf?.(); + }) + }.width(Constants.halfContainerWidth) + + Divider() + .vertical(true) + .height($r('app.float.digitalpsd_passwdmask_height')) + .color($r('sys.color.ohos_id_color_list_separator')) + .width($r('app.float.divider_width')) + Column() { + Button(globalThis.wantParams?.navigationButtonText) + .onClick(() => { + globalThis.session?.terminateSelf?.(); + }) + .margin({ right: $r('app.float.content_padding') }) + .width(Constants.ninetyPercentWidth) + .height($r('app.float.btn_height')) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) + .fontWeight(FontWeight.Medium) + .backgroundColor(Color.Transparent) + }.width(Constants.halfContainerWidth) } + .height($r('app.float.btn_height')) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } - .height($r('app.float.btn_height')) - .padding({ left: $r('app.float.content_padding'), right: $r('app.float.content_padding') }) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + } else if (this.state === 4) { Flex({ justifyContent: FlexAlign.SpaceBetween }) { - Image($r("app.media.ic_public_cancel")) + Image($r('app.media.ic_public_cancel')) + .id('cancelState4FingerprintAuth') .width($r('app.float.digitalpsd_passwdmask_height')) .height($r('app.float.digitalpsd_passwdmask_height')) .margin({ @@ -405,10 +542,10 @@ export default struct FingerprintAuth { left: $r('app.float.digitalpsd_passwdmask_height') }) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() + globalThis.session?.terminateSelf?.(); }) Button($r('app.string.unified_authwidget_usepwd')) + .id('usePwdBtnState4FingerprintAuth') .backgroundColor(Color.White) .height($r('app.float.digitalpsd_passwdmask_height')) .padding(0) @@ -420,129 +557,74 @@ export default struct FingerprintAuth { .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontWeight(FontWeight.Medium) .onClick(() => { - this.state = 5 + this.state = 5; }) } - Text(globalThis.title) + Text(globalThis.wantParams?.title) .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontColor($r('sys.color.ohos_id_color_text_primary')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height') }) Text($r('app.string.unified_authwidget_hint_inscreen_fp')) - .margin({ top: $r("app.float.element_margin") }) + .margin({ top: $r('app.float.element_margin') }) .fontColor($r('sys.color.ohos_id_color_text_secondary')) .fontSize($r('sys.float.ohos_id_text_size_body2')) - Image($r("app.media.ic_unlock_fingerprint")) + Image($r('app.media.ic_blue_fingerprint')) .width($r('app.float.image_medium')) .height($r('app.float.image_medium')) .margin({ top: $r('app.float.digitalpsd_passwdmask_height'), bottom: $r('app.float.digitalpsd_passwdmask_height') }) - .colorBlend($r('sys.color.ohos_id_color_activated')) } else if (this.state === 5) { // Password 32-bit Column() { Pwd({ - type: $type, textValue: $textValue, inputValue: $inputValue, isEdit: $isEdit, + pinSubType: $pinSubType }) Row() { Column() { - Button($r("app.string.unified_authwidget_cancel"), { stateEffect: true }) + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelBtnState5FingerprintAuth') .margin({ left: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = "" + globalThis.session?.terminateSelf?.(); + this.textValue = ''; }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) Divider() .vertical(true) .height($r('app.float.digitalpsd_passwdmask_height')) - .color($r("sys.color.ohos_id_color_list_separator")) + .color($r('sys.color.ohos_id_color_list_separator')) .width($r('app.float.divider_width')) Column() { Button($r('app.string.unified_authwidget_confirm')) + .id('okBthState5FingerprintAuth') .margin({ right: $r('app.float.content_padding') }) - .width(Constants.NINETY_PERCENT_WIDTH) + .width(Constants.ninetyPercentWidth) .height($r('app.float.btn_height')) - .fontSize($r("sys.float.ohos_id_text_size_button1")) - .fontColor($r("sys.color.ohos_id_color_text_primary_activated")) + .fontSize($r('sys.float.ohos_id_text_size_button1')) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(async (e) => { - // check callback - let userAuthWidgetMgr; - try { - let that = this; - LogUtils.d(TAG, 'getUserAuthWidgetMgr start'); - userAuthWidgetMgr = await userAuth.getUserAuthWidgetMgr(1); - userAuthWidgetMgr.on('command', { - callback: function (result) { - LogUtils.d(TAG, 'getUserAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); - // check fail callback - const cmdData = JSON.parse(result?.cmdData) - if (cmdData?.cmd?.[0]?.payload?.result !== 0) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - LogUtils.d(TAG, 'frequency: ' + frequency) - if (frequency) { - that.inputValue = Constants.ERROR_PASSWORD; - that.textValue = '' - if (frequency < 4) { - that.inputValue = `密码错误,还可尝试${frequency}次`; - } - } - // countdown - const time = cmdData?.cmd?.[0]?.payload?.lockoutDuration; - if (frequency === 0 && time) { - that.countTime(time); - that.isEdit = false; - } - } else { - // check success - that.controller.close(); - } - } - }); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success: ' + JSON.stringify(userAuthWidgetMgr)); - } catch (error) { - LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); - } - // check - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'EVENT_AUTH_TYPE_READY', - version: '1', - payload: { - type: ['pin'] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'sendNotice start eventData: ' + jsonEventData); - await userAuth.sendNotice(1, jsonEventData); - LogUtils.d(TAG, 'sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); - } + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); }) - }.width(Constants.HALF_CONTAINER_WIDTH) + }.width(Constants.halfContainerWidth) } .height($r('app.float.btn_height')) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } } else if (this.state === 6) { @@ -551,19 +633,18 @@ export default struct FingerprintAuth { SixPwd({ textValue: $textValue, inputValue: $inputValue, - isEdit: $isEdit, - controllerFlag: $controllerFlag + isEdit: $isEdit }) Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) + .id('cancelState6FingerprintAuth') .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = "" + globalThis.session?.terminateSelf?.(); + this.textValue = ''; }) .backgroundColor(Color.Transparent) .height($r('app.float.btn_height')) - .width(Constants.HALF_CONTAINER_WIDTH) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .width(Constants.halfContainerWidth) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) .fontSize($r('sys.float.ohos_id_text_size_button1')) .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) @@ -572,6 +653,9 @@ export default struct FingerprintAuth { }.backgroundColor($r('sys.color.ohos_id_color_dialog_bg')) .borderRadius($r('sys.float.ohos_id_corner_radius_dialog')) + .position({ + y: this.isLandscape ? NORMAL_POSITION : (this.fingerPosition.udSensorCenterYInThousandth - THOUSANDTH) + }) .margin({ left: ($r('sys.float.ohos_id_dialog_margin_start')), right: ($r('sys.float.ohos_id_dialog_margin_end')), @@ -580,7 +664,7 @@ export default struct FingerprintAuth { } } } - .height(Constants.FULL_CONTAINER_HEIGHT) + .height(Constants.fullContainerHeight) .justifyContent(FlexAlign.End) .backgroundColor(Color.Transparent) } diff --git a/entry/src/main/ets/pages/components/PasswordAuth.ets b/entry/src/main/ets/pages/components/PasswordAuth.ets index 814178f..daf40d3 100644 --- a/entry/src/main/ets/pages/components/PasswordAuth.ets +++ b/entry/src/main/ets/pages/components/PasswordAuth.ets @@ -14,53 +14,76 @@ */ import account_osAccount from '@ohos.account.osAccount'; -import userAuth from '@ohos.userIAM.userAuth'; -import util from '@ohos.util'; import Pwd from '../../common/components/Pwd'; import SixPwd from '../../common/components/SixPwd'; +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 from '../../common/vm/Constants'; +import Constants, { CmdType } from '../../common/vm/Constants'; const TAG = 'PasswordAuth'; +const INTERVAL = 1000; let pinAuthManager; let pinData = ''; - @Component export default struct PasswordAuth { - // 0:six number 1:arbitrary character 2:arbitrary number - @Link type: number; - @State @Watch('onFlagChange') controllerFlag: boolean = false; + @Link pinSubType: string; @State @Watch('onTextValueChange') textValue: string = ''; + @Link @Watch('onCmdDataChange') cmdData: Array; @State isEdit: boolean = true; // tip @State inputValue: string = ' '; - controller: CustomDialogController; - cancel: () => void; - confirm: () => void; - onFlagChange() { - if (this.controllerFlag) { - globalThis.session?.terminateSelf(); - } + onTextValueChange(): void { + pinData = this.textValue; } - onTextValueChange() { - pinData = this.textValue; + onCmdDataChange(num?: string): void { + this.cmdData.length > 0 && this.cmdData.map((item) => { + const { type,remainAttempts, lockoutDuration} = item.payload; + if (type === Constants.noticeTypePin) { + if (remainAttempts) { + this.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error')); + this.textValue = ''; + if (num === 'first') { + this.inputValue = ''; + } + if (remainAttempts < 3) { + this.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_pwd_error_can_try')) + + remainAttempts + globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_frequency')); + } + return; + } + if (remainAttempts === 0 && lockoutDuration) { + this.countTime(lockoutDuration); + this.isEdit = false; + this.textValue = ''; + return; + } + this.inputValue = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error')); + this.textValue = ''; + } + }) } - aboutToAppear() { + aboutToAppear(): void { + if (this.cmdData && this.cmdData.length > 0) { + this.onCmdDataChange('first'); + } // register input try { - LogUtils.d(TAG, 'aboutToAppear PINAuth start'); + LogUtils.i(TAG, 'aboutToAppear PINAuth start'); pinAuthManager = new account_osAccount.PINAuth(); pinAuthManager.registerInputer({ onGetData: (authSubType, callback) => { - let textEncoder = new util.TextEncoder(); - let uint8PW = textEncoder.encode(pinData); - LogUtils.d(TAG, `aboutToAppear PINAuth onGetData pinData: ${pinData}, uint8PW: ${uint8PW}`); + const uint8PW = FuncUtils.getUint8PW(pinData); callback.onSetData(authSubType, uint8PW); } }); @@ -69,20 +92,22 @@ export default struct PasswordAuth { } } - aboutToDisappear() { - pinAuthManager?.unregisterInputer?.() + aboutToDisappear(): void { + LogUtils.i(TAG, 'aboutToAppear pinAuthManager unregisterInputer'); + pinAuthManager?.unregisterInputer?.(); } - countTime(freezingTime) { - const TRY_AGAIN = '后重试'; + countTime(freezingTime): void { + const TRY_AGAIN = globalThis.context.resourceManager.getStringSync($r('app.string.unified_authwidget_postretry')); let promptText: string = ''; let freezingMillisecond = freezingTime; if (freezingMillisecond > 0) { - promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond); - promptText += TRY_AGAIN; - setTimeout(this.countTime.bind(this), 1000, freezingTime - 1000); + promptText = TimeUtils.getFreezingTimeNm(freezingMillisecond, globalThis.context); + promptText = globalThis.context.resourceManager + .getStringSync($r('app.string.unified_authwidget_many_failures')) + promptText + TRY_AGAIN; + setTimeout(this.countTime.bind(this), INTERVAL, freezingTime - INTERVAL); } else { - promptText = Constants.INPUT_PASSWORD; + promptText = ' '; this.isEdit = true; } this.inputValue = promptText; @@ -93,7 +118,7 @@ export default struct PasswordAuth { GridRow({ columns: 8, gutter: { x: 5, y: 10 }, - breakpoints: { value: ['360vp', '780vp'], + breakpoints: { value: Constants.deviceDpi, reference: BreakpointsReference.WindowSize }, direction: GridRowDirection.Row }) { @@ -103,18 +128,18 @@ export default struct PasswordAuth { span: { xs: 8, sm: 8, md: 4, lg: 4 }, }) { Column() { - if (this.type !== Constants.TYPE_DIALOG_SIX_NUMBER) { + if (this.pinSubType !== Constants.pinSix) { // arbitrary input Column() { Pwd({ - type: $type, + pinSubType: $pinSubType, textValue: $textValue, inputValue: $inputValue, isEdit: $isEdit, }) Row() { Column() { - Button($r('app.string.cancel'), { stateEffect: true }) + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) .margin({ left: $r('app.float.content_padding') }) .width('90%') .height($r('app.float.btn_height')) @@ -123,12 +148,9 @@ export default struct PasswordAuth { .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) .onClick(() => { - globalThis.session?.terminateSelf(); - LogUtils.d(TAG, `globalThis.session` + JSON.stringify(globalThis.session) + globalThis.session.terminateSelf()); - this.cancel(); - this.textValue = ''; - this.inputValue = ' '; + globalThis.session?.terminateSelf?.(); }) + .id('cancelBtnDialogPwd') }.width('50%') Divider() @@ -137,69 +159,9 @@ export default struct PasswordAuth { .color($r('sys.color.ohos_id_color_list_separator')) .width($r('app.float.divider_width')) Column() { - Button($r('app.string.confirm')) + Button($r('app.string.unified_authwidget_confirm')) .onClick(async () => { - // check callback - let userAuthWidgetMgr; - try { - let that = this; - LogUtils.d(TAG, 'getUserAuthWidgetMgr start'); - userAuthWidgetMgr = await userAuth.getUserAuthWidgetMgr(1); - // check callback - userAuthWidgetMgr.on('command', { - callback: function (result) { - LogUtils.d(TAG, 'getUserAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); - // fail - const cmdData = JSON.parse(result?.cmdData) - if (cmdData?.cmd?.[0]?.payload?.result !== Constants.USER_AUTH_WIDGET_MGR_SUCCESS) { - // frequency - const frequency = cmdData?.cmd?.[0]?.payload?.remainAttempts; - if (frequency) { - that.inputValue = Constants.ERROR_PASSWORD; - that.textValue = ''; - if (frequency < 4) { - that.inputValue = `密码错误,还可尝试${frequency}次`; - } - return; - } - // countdown - const time = cmdData?.cmd?.[0]?.payload?.lockoutDuration; - if (frequency === 0 && time) { - that.countTime(time); - that.isEdit = false; - that.textValue = ''; - return; - } - that.inputValue = Constants.ERROR_PASSWORD; - that.textValue = ''; - } else { - // success - that.controller.close(); - } - } - }); - LogUtils.d(TAG, 'getUserAuthWidgetMgr success userAuthWidgetMgr: ' + JSON.stringify(userAuthWidgetMgr)); - } catch (error) { - LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); - } - // check - try { - const eventData = { - // widgetContextId from onCreate - widgetContextId: 123456, - event: 'EVENT_AUTH_TYPE_READY', - version: '1', - payload: { - type: ['pin'] - } - }; - const jsonEventData = JSON.stringify(eventData); - LogUtils.d(TAG, 'sendNotice start eventData: ' + jsonEventData); - await userAuth.sendNotice(1, jsonEventData); - LogUtils.d(TAG, 'sendNotice success'); - } catch (error) { - LogUtils.e(TAG, 'sendNotice catch error: ' + JSON.stringify(error)); - } + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]); }) .enabled(this.textValue.length >= 4) .margin({ right: $r('app.float.content_padding') }) @@ -210,10 +172,11 @@ export default struct PasswordAuth { .opacity(this.textValue.length >= 4 ? 1 : $r('sys.float.ohos_fa_alpha_disabled')) .fontWeight(FontWeight.Medium) .backgroundColor(Color.Transparent) + .id('okBtn') }.width('50%') } .height($r('app.float.btn_height')) - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) } } else { // six number @@ -221,23 +184,22 @@ export default struct PasswordAuth { SixPwd({ textValue: $textValue, inputValue: $inputValue, - isEdit: $isEdit, - controllerFlag: $controllerFlag + isEdit: $isEdit }) - Button($r('app.string.cancel'), { stateEffect: true }) + Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true }) .onClick(() => { - globalThis.session?.terminateSelf(); - this.cancel() - this.textValue = '' - this.inputValue = ' ' + globalThis.session?.terminateSelf?.(); + this.textValue = ''; + this.inputValue = ' '; }) .backgroundColor(Color.Transparent) .height($r('app.float.btn_height')) .width('50%') - .margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') }) + .margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') }) .fontSize($r('sys.float.ohos_id_text_size_button1')) .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) + .id('cancelBtnDialogSixPwd') } } } @@ -256,7 +218,3 @@ export default struct PasswordAuth { .backgroundColor(Color.Transparent) } } - - - - diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 3f174ad..42607ef 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -18,7 +18,7 @@ "name": "entry", "type": "entry", "description": "$string:module_desc", - "mainElement": "EntryAbility", + "mainElement": "userauthuiextensionability", "deviceTypes": [ "default", "tablet" @@ -26,10 +26,33 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntrance": "./ets/mainability/MainAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], "extensionAbilities": [ { "name": "userauthuiextensionability", "srcEntry": "./ets/extensionability/UserAuthAbility.ts", + "icon": "$media:app_icon", "label": "$string:EntryAbility_label", "type": "sysDialog/userAuth", "permissions": [ diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index edad3c6..25bae4b 100644 --- a/entry/src/main/resources/base/element/float.json +++ b/entry/src/main/resources/base/element/float.json @@ -284,6 +284,10 @@ "name": "divider_width", "value": "2vp" }, + { + "name": "element_top", + "value": "8vp" + }, { "name": "element_margin", "value": "8vp" @@ -327,6 +331,14 @@ { "name": "title_size", "value": "20vp" + }, + { + "name": "back_width", + "value": "97vp" + }, + { + "name": "back_padding", + "value": "10vp" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 1f5f549..220be93 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -10,183 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "unified_identity_control_app", - "value": "unified identity control self-test app" - }, - { - "name": "single_command_authentication", - "value": "single_command_authentication" - }, - { - "name": "northbound_interface_testing", - "value": "northbound_interface_testing" - }, - { - "name": "api_9", - "value": "api_9" - }, - { - "name": "api_8", - "value": "api_8" - }, - { - "name": "api_6", - "value": "api_6" - }, - { - "name": "api_10", - "value": "api_10" - }, - { - "name": "prefabrication_condition", - "value": "prefabrication_condition" - }, - { - "name": "back", - "value": "back" - }, - { - "name": "authType", - "value": "authType" - }, - { - "name": "trust", - "value": "trustlevel" - }, - { - "name": "pop_type", - "value": "pop_type" - }, - { - "name": "Auth", - "value": "Auth" - }, - { - "name": "getAuthinstance", - "value": "getAuthinstance" - }, - { - "name": "on", - "value": "on" - }, - { - "name": "off", - "value": "off" - }, - { - "name": "start", - "value": "start" - }, - { - "name": "cancel", - "value": "cancel" - }, - { - "name": "authResult", - "value": "authResult" - }, - { - "name": "single_fingerprint_authentication", - "value": "single fingerprint authentication" - }, - { - "name": "single_face_authentication", - "value": "single face authentication" - }, - { - "name": "face_password_authentication", - "value": "face password authentication" - }, - { - "name": "fingerprint_password_authentication", - "value": "fingerprint password authentication" - }, - { - "name": "face_fingerprint_password_authentication", - "value": "face fingerprint password authentication" - }, - { - "name": "execution_result", - "value": "execution result" - }, - { - "name": "control_title", - "value": "control title" - }, - { - "name": "popup_six_digit_password_authentication", - "value": "popup--six digit password authentication" - }, - { - "name": "popup_any_digit_password_authentication", - "value": "popup--any digit password authentication" - }, - { - "name": "popup_any_character_password_authentication", - "value": "popup--any character password authentication" - }, - { - "name": "full_screen_six_character_password_authentication", - "value": "full_screen--six_character password authentication" - }, - { - "name": "full_screen_any_digit_password_authentication", - "value": "full_screen--any digit password authentication" - }, - { - "name": "full_screen_any_character_password_authentication", - "value": "full_screen--any character password authentication" - }, - { - "name": "preset_face", - "value": "preset face" - }, - { - "name": "preset_fingerprint", - "value": "preset fingerprint" - }, - { - "name": "delete_face", - "value": "delete face" - }, - { - "name": "delete_fingerprint", - "value": "delete fingerprint" - }, - { - "name": "navigation_button_text", - "value": "navigation button text" - }, - { - "name": "screen_single_fingerprint_authentication", - "value": "screen single fingerprint authentication" - }, - { - "name": "off_screen_single_fingerprint_authentication", - "value": "off screen single fingerprint authentication" - }, - { - "name": "confirm", - "value": "confirm" - }, - { - "name": "locked", - "value": "locked" - }, - { - "name": "please_try_again_in_60_seconds", - "value": "please try again in 60 seconds" - }, - { - "name": "forgot_password", - "value": "forgot password" - }, - { - "name": "use_password", - "value": "use password" + "value": "AuthWidget" }, { "name": "unified_authwidget_forgotpwd", @@ -303,6 +127,70 @@ { "name": "unified_authwidget_hint_pin_error", "value": "Incorrect PIN" + }, + { + "name": "unified_authwidget_use_pwd", + "value": "Enter password" + }, + { + "name": "unified_authwidget_title_face_forbidden", + "value": "Face Recognition disabled." + }, + { + "name": "unified_authwidget_hint_fp_retry_s2", + "value": "Fingerprint not recognized. Press down a little longer." + }, + { + "name": "unified_authwidget_title_fp_forbidden", + "value": "Fingerprint ID disabled." + }, + { + "name": "unified_authwidget_hint_recognition", + "value": "Face Scanning…" + }, + { + "name": "unified_authwidget_title_number_failed_fp_forbidden", + "value": "Excessive failure, fingerprint is disabled" + }, + { + "name": "unified_authwidget_tip_verify_in_portrait_mode", + "value": "Verify in portrait mode" + }, + { + "name": "unified_authwidget_pwd_error_can_try_frequency", + "value": "Password error, can still try %d frequency" + }, + { + "name": "unified_authwidget_pwd_error_can_try", + "value": "Password error, can still try " + }, + { + "name": "unified_authwidget_frequency", + "value": " frequency" + }, + { + "name": "unified_authwidget_many_failures", + "value": "Too many failures, please " + }, + { + "name": "unified_authwidget_postretry", + "value": "retry" + }, + { + "name": "unified_authwidget_minutes", + "value": "minutes " + }, + { + "name": "unified_authwidget_seconds", + "value": "seconds " + }, + { + "name": "unified_authwidget_notarize", + "value": "OK" + }, + { + "name": "unified_authwidget_title_number_failed_face_forbidden", + "value": "Excessive failure, face is disabled" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index 544047a..220be93 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -10,183 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "unified_identity_control_app", - "value": "unified identity control self-test app" - }, - { - "name": "single_command_authentication", - "value": "single_command_authentication" - }, - { - "name": "northbound_interface_testing", - "value": "northbound_interface_testing" - }, - { - "name": "api_9", - "value": "api_9" - }, - { - "name": "api_8", - "value": "api_8" - }, - { - "name": "api_6", - "value": "api_6" - }, - { - "name": "api_10", - "value": "api_10" - }, - { - "name": "prefabrication_condition", - "value": "prefabrication_condition" - }, - { - "name": "back", - "value": "back" - }, - { - "name": "authType", - "value": "authType" - }, - { - "name": "trust", - "value": "trustlevel" - }, - { - "name": "pop_type", - "value": "pop_up_type" - }, - { - "name": "Auth", - "value": "Auth" - }, - { - "name": "getAuthinstance", - "value": "getAuthinstance" - }, - { - "name": "on", - "value": "on" - }, - { - "name": "off", - "value": "off" - }, - { - "name": "start", - "value": "start" - }, - { - "name": "cancel", - "value": "cancel" - }, - { - "name": "authResult", - "value": "authResult" - }, - { - "name": "single_fingerprint_authentication", - "value": "single fingerprint authentication" - }, - { - "name": "single_face_authentication", - "value": "single face authentication" - }, - { - "name": "face_password_authentication", - "value": "face password authentication" - }, - { - "name": "fingerprint_password_authentication", - "value": "fingerprint password authentication" - }, - { - "name": "face_fingerprint_password_authentication", - "value": "face fingerprint password authentication" - }, - { - "name": "execution_result", - "value": "execution result" - }, - { - "name": "control_title", - "value": "control title" - }, - { - "name": "popup_six_digit_password_authentication", - "value": "popup--six digit password authentication" - }, - { - "name": "popup_any_digit_password_authentication", - "value": "popup--any digit password authentication" - }, - { - "name": "popup_any_character_password_authentication", - "value": "popup--any character password authentication" - }, - { - "name": "full_screen_six_character_password_authentication", - "value": "full_screen--six_character password authentication" - }, - { - "name": "full_screen_any_digit_password_authentication", - "value": "full_screen--any digit password authentication" - }, - { - "name": "full_screen_any_character_password_authentication", - "value": "full_screen--any character_password authentication" - }, - { - "name": "preset_face", - "value": "preset face" - }, - { - "name": "preset_fingerprint", - "value": "preset fingerprint" - }, - { - "name": "delete_face", - "value": "delete face" - }, - { - "name": "delete_fingerprint", - "value": "delete fingerprint" - }, - { - "name": "navigation_button_text", - "value": "navigation button text" - }, - { - "name": "screen_single_fingerprint_authentication", - "value": "screen single fingerprint authentication" - }, - { - "name": "off_screen_single_fingerprint_authentication", - "value": "off screen single fingerprint authentication" - }, - { - "name": "confirm", - "value": "confirm" - }, - { - "name": "locked", - "value": "locked" - }, - { - "name": "please_try_again_in_60_seconds", - "value": "please try again in 60 seconds" - }, - { - "name": "forgot_password", - "value": "forgot password" - }, - { - "name": "use_password", - "value": "use password" + "value": "AuthWidget" }, { "name": "unified_authwidget_forgotpwd", @@ -303,6 +127,70 @@ { "name": "unified_authwidget_hint_pin_error", "value": "Incorrect PIN" + }, + { + "name": "unified_authwidget_use_pwd", + "value": "Enter password" + }, + { + "name": "unified_authwidget_title_face_forbidden", + "value": "Face Recognition disabled." + }, + { + "name": "unified_authwidget_hint_fp_retry_s2", + "value": "Fingerprint not recognized. Press down a little longer." + }, + { + "name": "unified_authwidget_title_fp_forbidden", + "value": "Fingerprint ID disabled." + }, + { + "name": "unified_authwidget_hint_recognition", + "value": "Face Scanning…" + }, + { + "name": "unified_authwidget_title_number_failed_fp_forbidden", + "value": "Excessive failure, fingerprint is disabled" + }, + { + "name": "unified_authwidget_tip_verify_in_portrait_mode", + "value": "Verify in portrait mode" + }, + { + "name": "unified_authwidget_pwd_error_can_try_frequency", + "value": "Password error, can still try %d frequency" + }, + { + "name": "unified_authwidget_pwd_error_can_try", + "value": "Password error, can still try " + }, + { + "name": "unified_authwidget_frequency", + "value": " frequency" + }, + { + "name": "unified_authwidget_many_failures", + "value": "Too many failures, please " + }, + { + "name": "unified_authwidget_postretry", + "value": "retry" + }, + { + "name": "unified_authwidget_minutes", + "value": "minutes " + }, + { + "name": "unified_authwidget_seconds", + "value": "seconds " + }, + { + "name": "unified_authwidget_notarize", + "value": "OK" + }, + { + "name": "unified_authwidget_title_number_failed_face_forbidden", + "value": "Excessive failure, face is disabled" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 5dceaaa..2e6c08b 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -10,183 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" - }, - { - "name": "unified_identity_control_app", - "value": "统一身份控件自测App" - }, - { - "name": "single_command_authentication", - "value": "单口令认证" - }, - { - "name": "northbound_interface_testing", - "value": "北向接口测试" - }, - { - "name": "api_9", - "value": "API9 接口测试" - }, - { - "name": "api_8", - "value": "API8 接口测试" - }, - { - "name": "api_6", - "value": "API6 接口测试" - }, - { - "name": "api_10", - "value": "API10 接口测试" - }, - { - "name": "prefabrication_condition", - "value": "凭据管理" - }, - { - "name": "back", - "value": "返回" - }, - { - "name": "authType", - "value": "authType" - }, - { - "name": "trust", - "value": "trustlevel" - }, - { - "name": "pop_type", - "value": "弹窗类型" - }, - { - "name": "Auth", - "value": "Auth" - }, - { - "name": "getAuthinstance", - "value": "getAuthinstance" - }, - { - "name": "on", - "value": "on" - }, - { - "name": "off", - "value": "off" - }, - { - "name": "start", - "value": "start" - }, - { - "name": "cancel", - "value": "取消" - }, - { - "name": "authResult", - "value": "authResult" - }, - { - "name": "single_fingerprint_authentication", - "value": "单指纹认证" - }, - { - "name": "single_face_authentication", - "value": "单人脸认证" - }, - { - "name": "face_password_authentication", - "value": "人脸+口令认证" - }, - { - "name": "fingerprint_password_authentication", - "value": "指纹+口令认证" - }, - { - "name": "face_fingerprint_password_authentication", - "value": "人脸+指纹+口令认证" - }, - { - "name": "execution_result", - "value": "执行结果" - }, - { - "name": "control_title", - "value": "控件标题" - }, - { - "name": "navigation_button_text", - "value": "Navigation 按钮文字" - }, - { - "name": "popup_six_digit_password_authentication", - "value": "弹窗--6位数字口令认证" - }, - { - "name": "popup_any_digit_password_authentication", - "value": "弹窗--任意数字口令认证" - }, - { - "name": "popup_any_character_password_authentication", - "value": "弹窗--任意字符口令认证" - }, - { - "name": "full_screen_six_character_password_authentication", - "value": "全屏--6位字符口令认证" - }, - { - "name": "full_screen_any_digit_password_authentication", - "value": "全屏--任意数字口令认证" - }, - { - "name": "full_screen_any_character_password_authentication", - "value": "全屏--任意字符口令认证" - }, - { - "name": "preset_face", - "value": "预置人脸" - }, - { - "name": "preset_fingerprint", - "value": "预置指纹" - }, - { - "name": "delete_face", - "value": "删除人脸" - }, - { - "name": "delete_fingerprint", - "value": "删除指纹" - }, - { - "name": "screen_single_fingerprint_authentication", - "value": "屏下单指纹认证" - }, - { - "name": "off_screen_single_fingerprint_authentication", - "value": "屏外单指纹认证" - }, - { - "name": "confirm", - "value": "确定" - }, - { - "name": "locked", - "value": "已锁定" - }, - { - "name": "please_try_again_in_60_seconds", - "value": "请在60秒后重试" - }, - { - "name": "forgot_password", - "value": "忘记密码" - }, - { - "name": "use_password", - "value": "使用密码" + "value": "AuthWidget" }, { "name": "unified_authwidget_forgotpwd", @@ -303,6 +127,70 @@ { "name": "unified_authwidget_hint_pin_error", "value": "密码错误" + }, + { + "name": "unified_authwidget_use_pwd", + "value": "请输入密码" + }, + { + "name": "unified_authwidget_title_face_forbidden", + "value": "人脸已禁用" + }, + { + "name": "unified_authwidget_hint_fp_retry_s2", + "value": "指纹不匹配,请稍许用力并适当停留" + }, + { + "name": "unified_authwidget_title_fp_forbidden", + "value": "指纹已禁用" + }, + { + "name": "unified_authwidget_hint_recognition", + "value": "人脸识别中" + }, + { + "name": "unified_authwidget_title_number_failed_fp_forbidden", + "value": "失败次数过多,指纹已禁用" + }, + { + "name": "unified_authwidget_tip_verify_in_portrait_mode", + "value": "请在竖屏状态下进行验证" + }, + { + "name": "unified_authwidget_pwd_error_can_try_frequency", + "value": "密码错误,还可尝试%d次" + }, + { + "name": "unified_authwidget_pwd_error_can_try", + "value": "密码错误,还可尝试" + }, + { + "name": "unified_authwidget_frequency", + "value": "次" + }, + { + "name": "unified_authwidget_many_failures", + "value": "失败次数过多,请" + }, + { + "name": "unified_authwidget_postretry", + "value": "后重试" + }, + { + "name": "unified_authwidget_minutes", + "value": "分钟" + }, + { + "name": "unified_authwidget_seconds", + "value": "秒" + }, + { + "name": "unified_authwidget_notarize", + "value": "确认" + }, + { + "name": "unified_authwidget_title_number_failed_face_forbidden", + "value": "失败次数过多,人脸已禁用" } ] } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/extensionability/UserAuthAbility.ts b/entry/src/ohosTest/ets/extensionability/UserAuthAbility.ts new file mode 100644 index 0000000..432b48d --- /dev/null +++ b/entry/src/ohosTest/ets/extensionability/UserAuthAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import LogUtils from '../../../main/ets/common/utils/LogUtils'; +import UserAuthExtensionAbility from '@ohos.app.ability.UserAuthExtensionAbility'; + +const TAG = 'UserAuthAbility'; + +export default class UserAuthAbility extends UserAuthExtensionAbility { + onCreate() { + LogUtils.i(TAG, 'UserAuthExtensionAbility onCreate context: ' + JSON.stringify(this.context)); + globalThis.context = this.context; + } + + onForeground(): void { + LogUtils.i(TAG, 'UserAuthExtensionAbility onForeground'); + } + + onBackground(): void { + LogUtils.i(TAG, 'UserAuthExtensionAbility onBackground'); + } + + onDestroy(): void | Promise { + LogUtils.i(TAG, 'UserAuthExtensionAbility onDestroy'); + } + + onSessionCreate(want, session): void { + LogUtils.i(TAG, 'UserAuthExtensionAbility onSessionCreate want: ' + JSON.stringify(want)); + globalThis.wantParams = want?.parameters?.useriamCmdData; + globalThis.session = session; + session.loadContent('pages/Index'); + } + + onSessionDestroy(session): void { + LogUtils.i(TAG, 'UserAuthExtensionAbility onSessionDestroy'); + } +} diff --git a/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets index 02f6ad3..c9f635e 100644 --- a/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/entry/src/ohosTest/ets/test/Ability.test.ets @@ -14,7 +14,7 @@ */ import hilog from '@ohos.hilog'; -import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium' +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; export default function abilityTest() { describe('ActsAbilityTest', function () { @@ -40,11 +40,11 @@ export default function abilityTest() { it('assertContain', 0, function () { // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); - let a = 'abc' - let b = 'b' + let a = 'abc'; + let b = 'b'; // Defines a variety of assertion methods, which are used to declare expected boolean conditions. - expect(a).assertContain(b) - expect(a).assertEqual(a) + expect(a).assertContain(b); + expect(a).assertEqual(a); }) }) } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/Index.test.ets b/entry/src/ohosTest/ets/test/Index.test.ets new file mode 100644 index 0000000..3b2841f --- /dev/null +++ b/entry/src/ohosTest/ets/test/Index.test.ets @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Driver, ON } from '@ohos.UiTest'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; + +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +const delayms: number = 1000; + +export default function IndexTest() { + describe('IndexTest', function () { + beforeAll(async function () { + const data = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": "" + }, "version": "1" + }], + "pinSubType": "PIN_SIX", + "title": "", + "type": ["pin"], + "widgetContextId": 7932856209793250000, + "windowModeType": "DIALOG_BOX" + }; + globalThis.wantParams = data; + let want = { + bundleName: bundleName, + abilityName: "EntryAbility" + } + await delegator.startAbility(want); + }) + beforeEach(function () { + }) + afterEach(function () { + }) + afterAll(function () { + }) + it('clickEventCancal_Input', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + let cancel_btn = await driver.findComponent(ON.id('pinSix')); + await cancel_btn.inputText('11111'); + await driver.delayMs(delayms); + }) + it('clickEventUsePassWord_Input', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + let cancel_btn = await driver.findComponent(ON.type('Button').isAfter(ON.text('使用密码'))); + cancel_btn.click(); + done(); + }) + + it('clickEventOk_Input', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + let cancel_btn = await driver.findComponent(ON.id('pinSix')); + await cancel_btn.inputText('111111'); + await driver.delayMs(delayms); + let ok_btn = await driver.findComponent(ON.id('cancelBtn_dialog_pwd')); + await ok_btn.click(); + done(); + }) + + it('clickEventError_Input', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + + let Input = await driver.findComponent(ON.id('pinInput')); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + let ok_btn = await driver.findComponent(ON.id('okBtn')); + await ok_btn.click(); + await driver.delayMs(delayms); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + await ok_btn.click(); + await driver.delayMs(delayms); + + await driver.delayMs(delayms); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + await ok_btn.click(); + await driver.delayMs(delayms); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + await ok_btn.click(); + await driver.delayMs(delayms); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + await ok_btn.click(); + await driver.delayMs(delayms); + + done(); + }) + it('assertEqual', 0, function () { + let a = 'test'; + expect(a).assertEqual('test'); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets index b7c2aee..04fa52f 100644 --- a/entry/src/ohosTest/ets/test/List.test.ets +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -13,8 +13,36 @@ * limitations under the License. */ -import abilityTest from './Ability.test' +import IndexTest from './Index.test'; +import funcUtilsTest from './jsunit/commonUtilsTest/FuncUtils.test'; +import constantsTest from './jsunit/constantsTest/Constants.test'; +import customPasswordTest from './jsunit/widgetTest/CustomPassword.test'; +import CustomPasswordFaceTest from './jsunit/widgetTest/CustomPasswordFace.test'; +import CustomPasswordFingerTest from './jsunit/widgetTest/CustomPasswordFinger.test'; +import FaceAuth from './jsunit/widgetTest/FaceAuth.test'; +import FingerprintAuth from './jsunit/widgetTest/FingerprintAuth.test'; +import pageComTest from './jsunit/widgetTest/PageCom.test'; +import passwordAuthTest from './jsunit/widgetTest/PasswordAuth.test'; +import PasswordAuthTestSix from './jsunit/widgetTest/PasswordAuthSix.test'; +import CustomPasswordTest from './uitest/CustomPassword.test'; +import FaceAuthTest from './uitest/FaceAuth.test'; +import FingerprintAuthTest from './uitest/FingerprintAuth.test'; +import PasswordAuthTest from './uitest/PasswordAuth.test'; export default function testsuite() { - abilityTest() + IndexTest(); + CustomPasswordTest(); + PasswordAuthTest(); + FaceAuthTest(); + FingerprintAuthTest(); + funcUtilsTest(); + pageComTest(); + constantsTest(); + passwordAuthTest(); + PasswordAuthTestSix(); + FaceAuth(); + FingerprintAuth(); + customPasswordTest(); + CustomPasswordFaceTest(); + CustomPasswordFingerTest(); } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/commonUtilsTest/FuncUtils.test.ets b/entry/src/ohosTest/ets/test/jsunit/commonUtilsTest/FuncUtils.test.ets new file mode 100644 index 0000000..84a4557 --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/commonUtilsTest/FuncUtils.test.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import userAuth from '@ohos.userIAM.userAuth'; +import { beforeAll, describe, expect, it } from '@ohos/hypium'; +import AuthUtils from '../../../../../main/ets/common/utils/AuthUtils'; +import FuncUtils from '../../../../../main/ets/common/utils/FuncUtils'; +import LogUtils from '../../../../../main/ets/common/utils/LogUtils'; + +const TAG = 'FuncUtilsTest'; + +export default function FuncUtilsTest() { + describe('funcUtilsTest', function () { + beforeAll(async function () { + let userAuthInstance = null; + const authParam = { + challenge: new Uint8Array([49, 49, 49, 49, 49, 49]), + authType: [1], + authTrustLevel: 10000, + }; + const widgetParam = { + title: '', + windowMode: 1, + navigationButtonText: '', + }; + userAuthInstance = await userAuth.getUserAuthInstance(authParam, widgetParam); + userAuthInstance.on('result', { + callback: function (result) { + LogUtils.i(TAG, 'callback result = ' + JSON.stringify(result)); + } + }); + userAuthInstance.start(); + }) + + it('getUint8PWFunc_test', 0, function (done) { + const data1 = FuncUtils.getUint8PW('111111'); + const data2 = FuncUtils.getUint8PW('11111111'); + expect(data1).assertInstanceOf('Uint8Array'); + expect(data2).assertInstanceOf('Uint8Array'); + done(); + }) + + it('getDialogTypeFunc_test', 0, function (done) { + const data1 = FuncUtils.getDialogType([1]); + const data2 = FuncUtils.getDialogType([1, 2, 3]); + const data3 = FuncUtils.getDialogType([]); + const data4 = FuncUtils.getDialogType(null); + const data5 = FuncUtils.getDialogType(undefined); + expect(data1).assertEqual(1); + expect(data2).assertEqual(6); + expect(data3).assertEqual(1); + expect(data4).assertEqual(1); + expect(data5).assertEqual(1); + done(); + }) + + it('sendNotice_test', 0, async function (done) { + AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', ['pin']); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/constantsTest/Constants.test.ets b/entry/src/ohosTest/ets/test/jsunit/constantsTest/Constants.test.ets new file mode 100644 index 0000000..2db2196 --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/constantsTest/Constants.test.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, expect, it } from '@ohos/hypium'; +import Constants from '../../../../../main/ets/common/vm/Constants'; + +export default function ConstantsTest() { + describe('funcUtilsTest', function () { + it('constants_test', 0, function (done) { + expect(Constants.pinSix).assertEqual('PIN_SIX'); + expect(Constants.pinNumber).assertEqual('PIN_NUMBER'); + expect(Constants.pinMixed).assertEqual('PIN_MIXED'); + expect(Constants.userAuthWidgetMgrVersion).assertEqual(1); + expect(Constants.userAuthWidgetMgrSuccess).assertEqual(0); + expect(Constants.noticeVersion).assertEqual('1'); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPassword.test.ets b/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPassword.test.ets new file mode 100644 index 0000000..b1bf04b --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPassword.test.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Driver, ON } from '@ohos.UiTest'; +import { beforeAll, describe, expect, it } from '@ohos/hypium'; + +const delayTime: number = 1000; + +export default function CustomPasswordTest() { + describe('customPasswordTest', function () { + beforeAll(async function () { + const wantDefault = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": "" + }, "version": "1" + }], + "pinSubType": "PIN_SIX", + "title": "", + "type": ["pin"], + "widgetContextId": 6711153399710207000, + "windowModeType": "FULLSCREEN" + }; + globalThis.wantParams = wantDefault; + }) + + it('cancelIcon_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelIconCustomPwd')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('textPrompt_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelIconCustomPwd')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('forgotBtn_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('forgotBtnCustomPwd')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPasswordFace.test.ets b/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPasswordFace.test.ets new file mode 100644 index 0000000..8ffe464 --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPasswordFace.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Driver, ON } from '@ohos.UiTest'; +import { beforeAll, describe, expect, it } from '@ohos/hypium'; + +const delayTime: number = 1000; + +export default function CustomPasswordFaceTest() { + describe('CustomPasswordFaceTest', function () { + beforeAll(async function () { + const wantDefault = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": "" + }, "version": "1" + }], + "pinSubType": "PIN_SIX", + "title": "", + "type": ["pin", "face"], + "widgetContextId": 6711153399710207000, + "windowModeType": "FULLSCREEN" + }; + globalThis.wantParams = wantDefault; + }) + + it('faceImg_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('faceImgCustomPwd')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPasswordFinger.test.ets b/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPasswordFinger.test.ets new file mode 100644 index 0000000..860a141 --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/widgetTest/CustomPasswordFinger.test.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Driver, ON } from '@ohos.UiTest'; +import { beforeAll, describe, expect, it } from '@ohos/hypium'; + +const delayTime: number = 1000; + +export default function CustomPasswordTest() { + describe('customPasswordTest', function () { + beforeAll(async function () { + const wantDefault = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": "" + }, "version": "1" + }], + "pinSubType": "PIN_SIX", + "title": "", + "type": ["pin", "fingerprint"], + "widgetContextId": 6711153399710207000, + "windowModeType": "FULLSCREEN" + }; + globalThis.wantParams = wantDefault; + }) + + it('fingerWhiteImg_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('fingerWhiteImgCustomPwd')); + expect(true).assertTrue(); + done(); + }) + + it('unlockFingerprintImg_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('unlockFingerprintImgCustomPwd')); + expect(true).assertTrue(); + done(); + }) + + it('numKeyBord_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('numKeyBordCustomPwd')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('fingerprintImg_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('fingerprintImgCustomPwd')); + expect(true).assertTrue(); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/widgetTest/FaceAuth.test.ets b/entry/src/ohosTest/ets/test/jsunit/widgetTest/FaceAuth.test.ets new file mode 100644 index 0000000..5cd71fd --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/widgetTest/FaceAuth.test.ets @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Driver, ON } from '@ohos.UiTest'; +import { beforeAll, describe, expect, it } from '@ohos/hypium'; + +const delayTime: number = 1000; + +export default function FaceAuthTest() { + describe('faceAuthTest', function () { + beforeAll(async function () { + const data = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "face", "sensorInfo": "" + }, "version": "1" + }], + "title": "", + "type": ["face"], + "widgetContextId": 16850018705910348000, + "windowModeType": "DIALOG_BOX" + }; + globalThis.wantParams = data; + }) + + it('promptText_resetPin_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('promptTextResetPinFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('cancelBtn_pin_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelBtnPinFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('usePwd_pin_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('usePwdPinFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('cancelImg_all_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelImgAllFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('usePwdBtn_all_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('usePwdBtnAllFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('resetPromptText_all_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('resetPromptTextAllFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('blueFingerprintImg_all_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('blueFingerprintImgAllFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('unlockFingerprintImg_customPwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('unlockFingerprintImgCustomPwd')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('errFaceImg_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('errFaceImgFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('blueFingerprintImg_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('blueFingerprintImgFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('cancelBtn_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelBtnFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('usePwdBtn_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('usePwdBtnFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('cancelBtn_mixedPin_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelBtnMixedPinFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('okBtn_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('okBtnFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('cancelBtn_sixPin_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelBtnSixPinFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('promptText_reset_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('promptTextResetFaceAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/widgetTest/FingerprintAuth.test.ets b/entry/src/ohosTest/ets/test/jsunit/widgetTest/FingerprintAuth.test.ets new file mode 100644 index 0000000..af6d5c1 --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/widgetTest/FingerprintAuth.test.ets @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Driver, ON } from '@ohos.UiTest'; +import { beforeAll, describe, expect, it } from '@ohos/hypium'; + +const delayTime: number = 1000; + +export default function fingerprintAuthTest() { + describe('fingerprintAuthTest', function () { + beforeAll(async function () { + const data = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, + "remainAttempts": 5, + "type": "fingerprint", + "sensorInfo": "" + }, "version": "1" + }], + "title": "", + "type": ["fingerprint"], + "widgetContextId": 2477724982625843000, + "windowModeType": "DIALOG_BOX" + }; + globalThis.wantParams = data; + }) + + it('cancelBth_state3_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('cancelBthState3FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('usePwdBtn_state3_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('usePwdBtnState3FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('blueFingerprintImg_state2_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('blueFingerprintImgState2FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('cancelBtn_state2_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('cancelBtnState2FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('usePwdBtn_state2_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('usePwdBtnState2FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('blueFingerprint_state1_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('blueFingerprintState1FingerprintAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('blueFingerprintImg_all_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('blueFingerprintImgAllFaceAuth')); + expect(true).assertTrue(); + done(); + }) + + it('usePwdBtn_state1_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('usePwdBtnState1FingerprintAuth')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('cancel_state4_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('cancelState4FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('usePwdBtn_state4_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('usePwdBtnState4FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('cancelBtn_state5_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('cancelBtnState5FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('okBth_state5_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('okBthState5FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + + it('cancelBtn_mixedPin_faceAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('cancelBtnMixedPinFaceAuth')); + expect(true).assertTrue(); + done(); + }) + + it('cancel_state6_fingerprintAuth_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.findComponent(ON.id('cancelState6FingerprintAuth')); + expect(true).assertTrue(); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/widgetTest/PageCom.test.ets b/entry/src/ohosTest/ets/test/jsunit/widgetTest/PageCom.test.ets new file mode 100644 index 0000000..7441111 --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/widgetTest/PageCom.test.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, expect, it } from '@ohos/hypium' +import { Driver, ON } from '@ohos.UiTest' +import userAuth from '@ohos.userIAM.userAuth'; +import LogUtils from '../../../../../main/ets/common/utils/LogUtils'; + +const TAG = 'PageComTest'; + +const delayTime: number = 1000; + +export default function PageComTest() { + describe('pageComTest', function () { + beforeAll(async function () { + let userAuthInstance = null; + const authParam = { + challenge: new Uint8Array([49, 49, 49, 49, 49, 49]), + authType: [userAuth.UserAuthType.FINGERPRINT], + authTrustLevel: 10000, + }; + const widgetParam = { + title: '', + windowMode: 1, + navigationButtonText: '', + }; + userAuthInstance = await userAuth.getUserAuthInstance(authParam, widgetParam); + userAuthInstance.on('result', { + callback: function (result) { + LogUtils.i(TAG, 'userAuthInstance onResult: ' + JSON.stringify(result)); + } + }); + userAuthInstance.start(); + }) + + it('clickEventOk_Input', 0, async function (done) { + let userAuthInstance = null; + const authParam = { + challenge: new Uint8Array([49, 49, 49, 49, 49, 49]), + authType: [userAuth.UserAuthType.FINGERPRINT], + authTrustLevel: 10000, + }; + const widgetParam = { + title: '', + windowMode: 1, + navigationButtonText: '', + }; + userAuthInstance = await userAuth.getUserAuthInstance(authParam, widgetParam); + userAuthInstance.on('result', { + callback: function (result) { + LogUtils.i(TAG, 'userAuthInstance onResult: ' + JSON.stringify(result)); + } + }); + let driver = Driver.create(); + await driver.delayMs(delayTime); + + let btn = await driver.findComponent(ON.id('cancelBtn_dialog_pwd')); + LogUtils.i(TAG, 'btn: ' + JSON.stringify(btn)); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/widgetTest/PasswordAuth.test.ets b/entry/src/ohosTest/ets/test/jsunit/widgetTest/PasswordAuth.test.ets new file mode 100644 index 0000000..1faa87d --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/widgetTest/PasswordAuth.test.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Driver, ON } from '@ohos.UiTest'; +import { beforeAll, describe, expect, it } from '@ohos/hypium'; + +const delayTime: number = 1000; + +export default function PasswordAuthTest() { + describe('passwordAuthTest', function () { + beforeAll(async function () { + const data = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": "" + }, "version": "1" + }], + "pinSubType": "PIN_MIXED", + "title": "", + "type": ["pin"], + "widgetContextId": 7932856209793250000, + "windowModeType": "DIALOG_BOX" + }; + globalThis.wantParams = data; + }) + + it('cancelBtn_dialog_pwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelBtnDialogPwd')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + + it('okBtn_dialog_pwd_test', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('okBtn')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/jsunit/widgetTest/PasswordAuthSix.test.ets b/entry/src/ohosTest/ets/test/jsunit/widgetTest/PasswordAuthSix.test.ets new file mode 100644 index 0000000..5735d79 --- /dev/null +++ b/entry/src/ohosTest/ets/test/jsunit/widgetTest/PasswordAuthSix.test.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, expect, it } from '@ohos/hypium' +import { Driver, ON } from '@ohos.UiTest'; + +const delayTime: number = 1000; + +export default function passwordAuthSixTest() { + + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + describe('passwordAuthSixTest', function () { + beforeAll(async function () { + const data = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": "" + }, "version": "1" + }], + "pinSubType": "PIN_SIX", + "title": "", + "type": ["pin"], + "widgetContextId": 7932856209793250000, + "windowModeType": "DIALOG_BOX" + }; + globalThis.wantParams = data; + }) + + it('cancelBtn_dialog_sixPwd_test', 0, async function (done) { + await sleep(1000) + let driver = Driver.create(); + await driver.delayMs(delayTime); + let btn = await driver.findComponent(ON.id('cancelBtnDialogSixPwd')); + await btn.click(); + expect(true).assertTrue(); + done(); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/uitest/CustomPassword.test.ets b/entry/src/ohosTest/ets/test/uitest/CustomPassword.test.ets new file mode 100644 index 0000000..cf05179 --- /dev/null +++ b/entry/src/ohosTest/ets/test/uitest/CustomPassword.test.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Driver, ON } from '@ohos.UiTest'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; + +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +const delayms: number = 1000; + +export default function CustomPasswordTest() { + describe('CustomPasswordTest', function () { + beforeAll(async function () { + let want = { + bundleName: bundleName, + abilityName: "EntryAbility" + } + await delegator.startAbility(want); + }) + beforeEach(function () { + }) + afterEach(function () { + }) + afterAll(function () { + }) + // full six-PIN + it('clickEventCancal_Input', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + let numberOne = await driver.findComponent(ON.type('Text').isAfter(ON.text('1'))); + await numberOne.click(); + await driver.delayMs(delayms); + await numberOne.click(); + await driver.delayMs(delayms); + await numberOne.click(); + await driver.delayMs(delayms); + await numberOne.click(); + await driver.delayMs(delayms); + await numberOne.click(); + await driver.delayMs(delayms); + await numberOne.click(); + await driver.delayMs(delayms); + done(); + }) + it('assertEqual', 0, function () { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'test'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertEqual('test'); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/uitest/FaceAuth.test.ets b/entry/src/ohosTest/ets/test/uitest/FaceAuth.test.ets new file mode 100644 index 0000000..d43c84e --- /dev/null +++ b/entry/src/ohosTest/ets/test/uitest/FaceAuth.test.ets @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Driver, ON } from '@ohos.UiTest'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; + +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +const delayms: number = 1000 + +export default function FaceAuthTest() { + describe('FaceAuthTest', function () { + beforeAll(async function () { + let want = { + bundleName: bundleName, + abilityName: "EntryAbility" + } + await delegator.startAbility(want); + }) + beforeEach(function () { + }) + afterEach(function () { + }) + afterAll(function () { + }) + it('clickEventCancal_face', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + let click_btn = await driver.findComponent(ON.clickable(true)); + click_btn.click(); + done(); + }) + + + it('clickEventError_face', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + let click_btn = await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试')); + click_btn.click(); + await driver.delayMs(delayms); + + let click_btn_two = await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试')); + click_btn_two.click(); + await driver.delayMs(delayms); + + let click_btn_three = await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试')); + click_btn_three.click(); + await driver.delayMs(delayms); + + let click_btn_four = await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试')); + click_btn_four.click(); + await driver.delayMs(delayms); + done(); + }) + it('assertEqual', 0, function () { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'test'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertEqual('test'); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/uitest/FingerprintAuth.test.ets b/entry/src/ohosTest/ets/test/uitest/FingerprintAuth.test.ets new file mode 100644 index 0000000..86d6d6c --- /dev/null +++ b/entry/src/ohosTest/ets/test/uitest/FingerprintAuth.test.ets @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Driver, ON } from '@ohos.UiTest'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; + + +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +const delayms: number = 1000; + +export default function FingerprintAuthTest() { + describe('FingerprintAuthTest', function () { + beforeAll(async function () { + const data = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": "" + }, "version": "1" + }], + "pinSubType": "PIN_SIX", + "title": "", + "type": ["fingerprint"], + "widgetContextId": 7932856209793250000, + "windowModeType": "DIALOG_BOX" + }; + globalThis.wantParams = data; + let want = { + bundleName: bundleName, + abilityName: "EntryAbility" + } + await delegator.startAbility(want); + }) + beforeEach(function () { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(function () { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('clickEventCancal_finger', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + let click_btn = await driver.findComponent(ON.clickable(true).isAfter(ON.type('Image'))); + click_btn.click(); + done(); + }) + + it('clickEventError_finger', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + let click_btn = await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试')); + click_btn.click(); + await driver.delayMs(delayms); + + let click_btn_two = await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试')); + click_btn_two.click(); + await driver.delayMs(delayms); + + let click_btn_three = await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试')); + click_btn_three.click(); + await driver.delayMs(delayms); + + let click_btn_four = await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试')); + click_btn_four.click(); + await driver.delayMs(delayms); + done(); + }) + + it('assertEqual', 0, function () { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'test'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertEqual('test'); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/uitest/PasswordAuth.test.ets b/entry/src/ohosTest/ets/test/uitest/PasswordAuth.test.ets new file mode 100644 index 0000000..3abaaf0 --- /dev/null +++ b/entry/src/ohosTest/ets/test/uitest/PasswordAuth.test.ets @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import { Driver, ON } from '@ohos.UiTest'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; + +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +const delayms: number = 1000; +let ab: UIAbility; + +export default function PasswordAuthTest() { + describe('PasswordAuthTest', function () { + beforeAll(async function () { + const data = { + "cmd": [{ + "event": "CMD_NOTIFY_AUTH_START", "payload": { + "lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": "" + }, "version": "1" + }], + "pinSubType": "PIN_MIXED", + "title": "", + "type": ["pin"], + "widgetContextId": 7932856209793250000, + "windowModeType": "DIALOG_BOX" + }; + globalThis.wantParams = data; + await delegator.addAbilityMonitor({ + abilityName: 'EntryAbility', + moduleName: bundleName, + onAbilityCreate(ability: UIAbility) { + ab = ability; + } + }); + let want = { + bundleName: bundleName, + abilityName: "EntryAbility" + } + await delegator.startAbility(want); + }) + beforeEach(function () { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(function () { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + + it('clickEventOk_Input', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + + let pinInput = await driver.findComponent(ON.id('pinInputMix')); + await pinInput.inputText('111111'); + await driver.delayMs(delayms); + let input_new = await driver.findComponent(ON.id('pinInputMix')); + let text = await input_new.getText(); + expect(text === '111111').assertTrue(); + + done(); + }) + + it('clickEventCancel_Input', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + let cancel_btn = await driver.findComponent(ON.id('pinInputMix')) + await cancel_btn.inputText('1221212') + await driver.delayMs(delayms); + let ok_btn = await driver.findComponent(ON.id('okBtn')) + await ok_btn.click() + await driver.delayMs(delayms); + await cancel_btn.inputText('111111') + await ok_btn.click() + await driver.delayMs(delayms); + done() + }) + + it('clickEventError_Input', 0, async function (done) { + let driver = Driver.create(); + await driver.delayMs(delayms); + await driver.delayMs(delayms); + + let Input = await driver.findComponent(ON.id('pinInputMix')); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + let ok_btn = await driver.findComponent(ON.id('okBtn')); + await ok_btn.click(); + await driver.delayMs(delayms); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + await ok_btn.click(); + await driver.delayMs(delayms); + + await driver.delayMs(delayms); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + await ok_btn.click() + await driver.delayMs(delayms); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + await ok_btn.click() + await driver.delayMs(delayms); + + await Input.inputText('2345643'); + await driver.delayMs(delayms); + await ok_btn.click(); + await driver.delayMs(delayms); + + done(); + }) + it('assertEqual', 0, function () { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'test'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertEqual('test'); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/testability/TestAbility.ets b/entry/src/ohosTest/ets/testability/TestAbility.ets index 65f1176..1f479c4 100644 --- a/entry/src/ohosTest/ets/testability/TestAbility.ets +++ b/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -31,6 +31,8 @@ export default class TestAbility extends UIAbility { abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + globalThis.context = this.context; + globalThis.session = {}; } onDestroy() { diff --git a/entry/src/ohosTest/ets/testability/pages/Index.ets b/entry/src/ohosTest/ets/testability/pages/Index.ets index 083a07b..5fbff76 100644 --- a/entry/src/ohosTest/ets/testability/pages/Index.ets +++ b/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -13,40 +13,192 @@ * limitations under the License. */ -import hilog from '@ohos.hilog'; +import userAuth from '@ohos.userIAM.userAuth'; +import window from '@ohos.window'; +import { DialogType } from '../../../../main/ets/common/module/DialogType'; +import AuthUtils from '../../../../main/ets/common/utils/AuthUtils'; +import FuncUtils from '../../../../main/ets/common/utils/FuncUtils'; +import LogUtils from '../../../../main/ets/common/utils/LogUtils'; +import Constants, { CmdType } from '../../../../main/ets/common/vm/Constants'; +import CustomPassword from '../../../../main/ets/pages/components/CustomPassword'; +import FaceAuth from '../../../../main/ets/pages/components/FaceAuth'; +import FingerprintAuth from '../../../../main/ets/pages/components/FingerprintAuth'; +import PasswordAuth from '../../../../main/ets/pages/components/PasswordAuth'; + +const TAG = 'Index'; +const defaultSize = 72; +let userAuthWidgetMgr; @Entry @Component struct Index { - aboutToAppear() { - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + @State authType: Array = [userAuth.UserAuthType.PIN]; + @State type: string[] = []; + @State topHeight: number = defaultSize; + @State bottomHeight: number = defaultSize; + @State pinSubType: string = Constants.pinNumber; + @State dialogType: DialogType = DialogType.ALL; + @State windowModeType: string = 'DIALOG_BOX'; + // background 1:white 2:Gaussian Blur + @State themeType: number = Constants.themeTypeWhite; + @State cmdData: Array = []; + + onCancel(): void { + LogUtils.d(TAG, 'Callback when the first button is clicked'); + globalThis.session?.terminateSelf(); + } + + onAccept(): void { + LogUtils.d(TAG, 'Callback when the second button is clicked'); + } + + existApp(): void { + LogUtils.d(TAG, 'Click the callback in the blank area'); + globalThis.session?.terminateSelf(); + } + + handleAuthStart(): void { + try { + userAuthWidgetMgr = userAuth.getUserAuthWidgetMgr(Constants.userAuthWidgetMgrVersion); + LogUtils.i(TAG, 'getUserAuthWidgetMgr success'); + let that = this; + userAuthWidgetMgr.on('command', { + callback: function (result) { + LogUtils.i(TAG, 'userAuthWidgetMgr onCommand result: ' + JSON.stringify(result)); + const cmdDataObj = JSON.parse(result?.cmdData || '{}'); + if (cmdDataObj?.cmd?.[0]?.payload?.result === Constants.userAuthWidgetMgrSuccess) { + that.onCancel(); + } else { + that.cmdData = cmdDataObj?.cmd || []; + that.pinSubType = cmdDataObj?.pinSubType; + } + } + }); + } catch (error) { + LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error)); + } + AuthUtils.getInstance().sendNotice('CMD_NOTIFY_AUTH_START', [Constants.noticeTypePin]); + } + + aboutToAppear(): void { + LogUtils.d(TAG, 'aboutToAppear'); + if (globalThis.wantParams) { + this.getParams(globalThis.wantParams); + this.handleAuthStart(); + this.cmdData = globalThis.wantParams?.cmd; + AuthUtils.getInstance().sendNotice('CMD_NOTIFY_AUTH_START', this.type); + LogUtils.d(TAG, 'globalThis.wantParams: ' + JSON.stringify(globalThis.wantParams)); + } else { + LogUtils.e(TAG, 'aboutToAppear wantParams null'); + } + this.getWindowHeight(); } - @State message: string = 'Hello World' + aboutToDisappear(): void { + LogUtils.i(TAG, 'aboutToDisappear'); + if (userAuthWidgetMgr) { + userAuthWidgetMgr.off('command', { + callback: function (result) { + LogUtils.i(TAG, 'aboutToDisappear userAuthWidgetMgr offCommand result: ' + JSON.stringify(result)); + } + }); + } + } + + onPageShow(): void { + LogUtils.i(TAG, 'onPageShow'); + } + + onPageHide(): void { + LogUtils.i(TAG, 'onPageHide'); + } + + onBackPress(): void { + LogUtils.i(TAG, 'onBackPress'); + } + + getParams(result): void { + LogUtils.i(TAG, 'getParams'); + const { pinSubType, windowModeType, cmd, type, widgetContextId } = result; + this.pinSubType = pinSubType; + const newType = type && type.map(item => { + switch (item) { + case Constants.noticeTypePin: + return userAuth.UserAuthType.PIN; + case Constants.noticeTypeFinger: + return userAuth.UserAuthType.FINGERPRINT; + case Constants.noticeTypeFace: + return userAuth.UserAuthType.FACE; + } + }) + globalThis.widgetContextId = widgetContextId; + this.authType = newType; + this.type = type; + this.windowModeType = windowModeType; + this.dialogType = FuncUtils.getDialogType(newType); + this.cmdData = cmd || []; + } + + getWindowHeight(): void { + LogUtils.i(TAG, 'getWindowHeight'); + try { + window.on('systemBarTintChange', (data) => { + LogUtils.d(TAG, 'Succeeded in enabling the listener for window stage event changes. Data: ' + + JSON.stringify(data)); + for (let i = 0; i < data.regionTint.length; i++) { + let regionData = data.regionTint[i]; + if (regionData.type === window.WindowType.TYPE_STATUS_BAR) { + this.topHeight = px2vp(regionData.region.height); + continue; + } + if (regionData.type === window.WindowType.TYPE_NAVIGATION_BAR) { + this.bottomHeight = px2vp(regionData.region.top); + continue; + } + } + }); + } catch (exception) { + LogUtils.e(TAG, 'Failed to enable the listener for window stage event changes. Cause:' + + JSON.stringify(exception)); + } + } build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(20) - .fontWeight(FontWeight.Bold) + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { + if ('DIALOG_BOX' === this.windowModeType) { + if (this.authType.includes(userAuth.UserAuthType.FACE)) { + FaceAuth({ + type: $windowModeType, + pinSubType: $pinSubType, + dialogType: $dialogType, + cmdData: $cmdData, + }) + } else if (this.authType.includes(userAuth.UserAuthType.FINGERPRINT)) { + FingerprintAuth({ + type: $windowModeType, + pinSubType: $pinSubType, + dialogType: $dialogType, + cmdData: $cmdData, + }) + } else { + PasswordAuth({ + pinSubType: $pinSubType, + cmdData: $cmdData + }) } - .type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('35%') - .height('5%') - .onClick(() => { + + } else { + // full screen PIN + CustomPassword({ + themeType: $themeType, + authType: $authType, + pinSubType: $pinSubType, + cmdData: $cmdData }) } - .width('100%') } - .height('100%') + .backgroundColor(Color.Transparent) + .position({ x: 0, y: this.topHeight }) + .height((this.bottomHeight - this.topHeight)) } } \ No newline at end of file diff --git a/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts index f37a9f3..790a58f 100644 --- a/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts +++ b/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -48,7 +48,7 @@ export default class OpenHarmonyTestRunner implements TestRunner { abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName var debug = abilityDelegatorArguments.parameters['-D'] - if (debug == 'true') { + if (debug === 'true') { cmd += ' -D' } hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5 index e31c248..4d80a0c 100644 --- a/entry/src/ohosTest/module.json5 +++ b/entry/src/ohosTest/module.json5 @@ -18,7 +18,7 @@ "name": "entry_test", "type": "feature", "description": "$string:module_test_desc", - "mainElement": "TestAbility", + "mainElement": "userauthuiextensionability", "deviceTypes": [ "default", "tablet" @@ -47,6 +47,38 @@ } ] } + ], + "extensionAbilities": [ + { + "name": "userauthuiextensionability", + "srcEntry": "./ets/extensionability/UserAuthAbility.ts", + "icon": "$media:app_icon", + "label": "$string:EntryAbility_label", + "type": "sysDialog/userAuth", + "permissions": [ + "ohos.permission.ACCESS_PIN_AUTH", + "ohos.permission.ACCESS_BIOMETRIC", + "ohos.permission.SUPPORT_USER_AUTH" + ], + "metadata": [ + { + // 新增key值,定义垂域服务业务细分类型 + "name": "ohos.extension.servicetype", + "value": "commonDialog" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.ACCESS_PIN_AUTH" + }, + { + "name": "ohos.permission.ACCESS_BIOMETRIC" + }, + { + "name": "ohos.permission.SUPPORT_USER_AUTH" + }, ] } } diff --git a/entry/src/ohosTest/resources/base/element/float.json b/entry/src/ohosTest/resources/base/element/float.json new file mode 100644 index 0000000..25bae4b --- /dev/null +++ b/entry/src/ohosTest/resources/base/element/float.json @@ -0,0 +1,344 @@ +{ + "float": [ + { + "name": "lockicon_width", + "value": "40px" + }, + { + "name": "lockicon_height", + "value": "45px" + }, + { + "name": "lockicon_top_margin", + "value": "10px" + }, + { + "name": "lockicon_bottom_margin", + "value": "10px" + }, + { + "name": "lockicon_right_margin", + "value": "0" + }, + { + "name": "lock_prompt_fontsize", + "value": "32px" + }, + { + "name": "lock_Text_top_margin", + "value": "0" + }, + { + "name": "batterysoc_fontsize", + "value": "36px" + }, + { + "name": "accounts_component_height", + "value": "120px" + }, + { + "name": "accounts_ic_width", + "value": "72px" + }, + { + "name": "accounts_ic_height", + "value": "72px" + }, + { + "name": "accounts_name_fontsize", + "value": "24px" + }, + { + "name": "accounts_block", + "value": "8px" + }, + { + "name": "digitalpsd_prompt_fontsize", + "value": "32px" + }, + { + "name": "digitalpsd_prompt_margin_bottom", + "value": "48px" + }, + { + "name": "digitalpsd_prompt_width", + "value": "800px" + }, + { + "name": "digitalpsd_prompt_height", + "value": "72px" + }, + { + "name": "digitalpsd_passwdmask_width", + "value": "400px" + }, + { + "name": "digitalpsd_passwdmask_height", + "value": "24vp" + }, + { + "name": "digitalpsd_passwdmask_margin_bottom", + "value": "128px" + }, + { + "name": "digitalpsd_input_area_height", + "value": "200px" + }, + { + "name": "digitalpsd_row1_fontsize", + "value": "48px" + }, + { + "name": "digitalpsd_row2_fontsize", + "value": "24px" + }, + { + "name": "digitalpsd_row_height", + "value": "200px" + }, + { + "name": "digitalpsd_key_area_height", + "value": "800px" + }, + { + "name": "digitalpsd_key_area_margin_bottom", + "value": "64px" + }, + { + "name": "digitalpsd_key_area_margin_bottom_portrait", + "value": "128px" + }, + { + "name": "mixedpsd_prompt_fontsize", + "value": "32px" + }, + { + "name": "mixedpsd_prompt_text_fontsize", + "value": "32px" + }, + { + "name": "mixedpsd_prompt_margin_bottom", + "value": "48px" + }, + { + "name": "mixedpsd_prompt_margin_top", + "value": "0" + }, + { + "name": "mixedpsd_prompt_width", + "value": "800px" + }, + { + "name": "mixedpsd_prompt_height", + "value": "72px" + }, + { + "name": "mixedpsd_input_maxlen", + "value": "30px" + }, + { + "name": "mixedpsd_input_width", + "value": "600px" + }, + { + "name": "mixedpsd_input_height", + "value": "72px" + }, + { + "name": "mixedpsd_input_margin_bottom", + "value": "64px" + }, + { + "name": "custompsd_prompt_fontsize", + "value": "32px" + }, + { + "name": "custompsd_prompt_margin_bottom", + "value": "48px" + }, + { + "name": "custompsd_prompt_width", + "value": "800px" + }, + { + "name": "custompsd_prompt_height", + "value": "72px" + }, + { + "name": "custompsd_input_width", + "value": "600px" + }, + { + "name": "custompsd_input_width_portrait", + "value": "700px" + }, + { + "name": "custompsd_input_height", + "value": "72px" + }, + { + "name": "custompsd_input_radius", + "value": "36px" + }, + { + "name": "custompsd_input_margin_bottom", + "value": "90px" + }, + { + "name": "custompsd_passwdmask_margin_bottom", + "value": "128px" + }, + { + "name": "custompsd_input_area_height", + "value": "400px" + }, + { + "name": "custompsd_key_area_height", + "value": "800px" + }, + { + "name": "custompsd_key_area_margin_bottom", + "value": "64px" + }, + { + "name": "custompsd_key_area_margin_bottom_portrait", + "value": "128px" + }, + { + "name": "custompsd_text_opacity", + "value": "1px" + }, + { + "name": "custompsd_digitalpsd_ic_diameter", + "value": "12vp" + }, + { + "name": "custompsd_button_height", + "value": "36vp" + }, + { + "name": "numkeyBoard_text_opacity", + "value": "1" + }, + { + "name": "numkeyBoard_rowsGap", + "value": "0" + }, + { + "name": "status_bar_height", + "value": "48vp" + }, + { + "name": "status_bar_padding_left_right", + "value": "0" + }, + { + "name": "status_bar_margin_top", + "value": "0" + }, + { + "name": "status_bar_opacity", + "value": "1" + }, + { + "name": "hap_title_font_size", + "value": "30" + }, + { + "name": "hap_label_font_size", + "value": "20" + }, + { + "name": "hap_label_font_size_big", + "value": "25" + }, + { + "name": "hap_label_font_size_small", + "value": "15" + }, + { + "name": "hap_input_width", + "value": "240" + }, + { + "name": "hap_Item_height", + "value": "40" + }, + { + "name": "title_padding_top", + "value": "32vp" + }, + { + "name": "content_padding", + "value": "16vp" + }, + { + "name": "content_padding_top", + "value": "32vp" + }, + { + "name": "btn_height", + "value": "40vp" + }, + { + "name": "divider_width", + "value": "2vp" + }, + { + "name": "element_top", + "value": "8vp" + }, + { + "name": "element_margin", + "value": "8vp" + }, + { + "name": "input_height", + "value": "40vp" + }, + { + "name": "input_border", + "value": "1vp" + }, + { + "name": "input_btn_size", + "value": "12vp" + }, + { + "name": "input_btn_padding_around", + "value": "24vp" + }, + { + "name": "input_btn_padding_up_down", + "value": "3vp" + }, + { + "name": "image_size", + "value": "66vp" + }, + { + "name": "image_small", + "value": "30vp" + }, + { + "name": "image_medium", + "value": "60vp" + }, + { + "name": "image_big", + "value": "120vp" + }, + { + "name": "title_size", + "value": "20vp" + }, + { + "name": "back_width", + "value": "97vp" + }, + { + "name": "back_padding", + "value": "10vp" + } + ] +} \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/element/image.json b/entry/src/ohosTest/resources/base/element/image.json new file mode 100644 index 0000000..7545288 --- /dev/null +++ b/entry/src/ohosTest/resources/base/element/image.json @@ -0,0 +1,8 @@ +{ + "boolean": [ + { + "name": "boolean_1", + "value": true + } + ] +} \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/element/string.json b/entry/src/ohosTest/resources/base/element/string.json index 65d8fa5..220be93 100644 --- a/entry/src/ohosTest/resources/base/element/string.json +++ b/entry/src/ohosTest/resources/base/element/string.json @@ -1,16 +1,196 @@ { "string": [ { - "name": "module_test_desc", - "value": "test ability description" + "name": "module_desc", + "value": "module description" }, { - "name": "TestAbility_desc", - "value": "the test ability" + "name": "EntryAbility_desc", + "value": "description" }, { - "name": "TestAbility_label", - "value": "test label" + "name": "EntryAbility_label", + "value": "AuthWidget" + }, + { + "name": "unified_authwidget_forgotpwd", + "value": "Forgot password" + }, + { + "name": "unified_authwidget_locked", + "value": "Locked" + }, + { + "name": "unified_authwidget_confirm", + "value": "OK" + }, + { + "name": "unified_authwidget_cancel", + "value": "Cancel" + }, + { + "name": "unified_authwidget_delete", + "value": "Delete" + }, + { + "name": "unified_authwidget_back", + "value": "Back" + }, + { + "name": "unified_authwidget_usepwd", + "value": "Use password" + }, + { + "name": "unified_authwidget_hint_pwd_error", + "value": "Incorrect password" + }, + { + "name": "fingerprint_matching_failed", + "value": "Fingerprint matching failed" + }, + { + "name": "unified_authwidget_hint_inscreen_fp", + "value": "Press the fingerprint sensor to verify your fingerprint." + }, + { + "name": "unified_authwidget_hint_normal_fp_only", + "value": "Press the fingerprint sensor to verify your fingerprint." + }, + { + "name": "unified_authwidget_hint_fp_verify_success", + "value": "Verification successful." + }, + { + "name": "unified_authwidget_hint_fp_retry_s1", + "value": "Fingerprint not recognized. Make sure your finger and the sensor are clean." + }, + { + "name": "unified_authwidget_title_fp_forbidden_enter_pwd", + "value": "Fingerprint ID disabled. Enter your password." + }, + { + "name": "unified_authwidget_title_fp_forbidden_enter_pin", + "value": "Fingerprint ID disabled. Enter your PIN." + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pattern", + "value": "Fingerprint ID disabled. Use Face Recognition or your pattern." + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pwd", + "value": "Fingerprint ID disabled. Use Face Recognition or your password." + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pin", + "value": "Fingerprint ID disabled. Use Face Recognition or your PIN." + }, + { + "name": "unified_authwidget_hint_recognizing", + "value": "Scanning…" + }, + { + "name": "unified_authwidget_hint_recognize_success", + "value": "Verification successful." + }, + { + "name": "unified_authwidget_hint_face_verify_fail_click_retry_s1", + "value": "Face not recognized. Touch here to try again." + }, + { + "name": "unified_authwidget_hint_face_verify_fail_click_retry_s2", + "value": "Face not recognized. Double-tap to try again." + }, + { + "name": "unified_authwidget_title_face_forbidden_use_pwd", + "value": "Face Recognition disabled. Enter your password." + }, + { + "name": "unified_authwidget_title_face_forbidden_use_pin", + "value": "Face Recognition disabled. Enter your PIN." + }, + { + "name": "unified_authwidget_title_face_forbidden_use_fp_pwd", + "value": "Face Recognition disabled. Use your fingerprint or password." + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pwd", + "value": "Face Recognition and Fingerprint ID disabled. Enter your password." + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pin", + "value": "Face Recognition and Fingerprint ID disabled. Enter your PIN." + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pattern", + "value": "Face Recognition and Fingerprint ID disabled. Draw your pattern." + }, + { + "name": "unified_authwidget_hint_pin_error", + "value": "Incorrect PIN" + }, + { + "name": "unified_authwidget_use_pwd", + "value": "Enter password" + }, + { + "name": "unified_authwidget_title_face_forbidden", + "value": "Face Recognition disabled." + }, + { + "name": "unified_authwidget_hint_fp_retry_s2", + "value": "Fingerprint not recognized. Press down a little longer." + }, + { + "name": "unified_authwidget_title_fp_forbidden", + "value": "Fingerprint ID disabled." + }, + { + "name": "unified_authwidget_hint_recognition", + "value": "Face Scanning…" + }, + { + "name": "unified_authwidget_title_number_failed_fp_forbidden", + "value": "Excessive failure, fingerprint is disabled" + }, + { + "name": "unified_authwidget_tip_verify_in_portrait_mode", + "value": "Verify in portrait mode" + }, + { + "name": "unified_authwidget_pwd_error_can_try_frequency", + "value": "Password error, can still try %d frequency" + }, + { + "name": "unified_authwidget_pwd_error_can_try", + "value": "Password error, can still try " + }, + { + "name": "unified_authwidget_frequency", + "value": " frequency" + }, + { + "name": "unified_authwidget_many_failures", + "value": "Too many failures, please " + }, + { + "name": "unified_authwidget_postretry", + "value": "retry" + }, + { + "name": "unified_authwidget_minutes", + "value": "minutes " + }, + { + "name": "unified_authwidget_seconds", + "value": "seconds " + }, + { + "name": "unified_authwidget_notarize", + "value": "OK" + }, + { + "name": "unified_authwidget_title_number_failed_face_forbidden", + "value": "Excessive failure, face is disabled" } ] } \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/error_faceID.svg b/entry/src/ohosTest/resources/base/media/error_faceID.svg new file mode 100644 index 0000000..6329960 --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/error_faceID.svg @@ -0,0 +1,54 @@ + + + + + error + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/finger_guide.svg b/entry/src/ohosTest/resources/base/media/finger_guide.svg new file mode 100644 index 0000000..21ec461 --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/finger_guide.svg @@ -0,0 +1,48 @@ + + + 画板 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/finger_white.svg b/entry/src/ohosTest/resources/base/media/finger_white.svg new file mode 100644 index 0000000..02f1f0b --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/finger_white.svg @@ -0,0 +1,48 @@ + + + 画板 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/ic_blue_fingerprint.svg b/entry/src/ohosTest/resources/base/media/ic_blue_fingerprint.svg new file mode 100644 index 0000000..585905c --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_blue_fingerprint.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + diff --git a/entry/src/ohosTest/resources/base/media/ic_public_cancel.svg b/entry/src/ohosTest/resources/base/media/ic_public_cancel.svg new file mode 100644 index 0000000..bdec70b --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_public_cancel.svg @@ -0,0 +1,30 @@ + + + Public/ic_public_cancel + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/ic_public_password_unvisible.svg b/entry/src/ohosTest/resources/base/media/ic_public_password_unvisible.svg new file mode 100644 index 0000000..45fab35 --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_public_password_unvisible.svg @@ -0,0 +1,46 @@ + + + Public/ic_public_password_unvisible + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/ic_public_password_visible.svg b/entry/src/ohosTest/resources/base/media/ic_public_password_visible.svg new file mode 100644 index 0000000..87c465b --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_public_password_visible.svg @@ -0,0 +1,46 @@ + + + Public/ic_public_password_visible + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/ic_solid_dot.svg b/entry/src/ohosTest/resources/base/media/ic_solid_dot.svg new file mode 100644 index 0000000..5a04c1b --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_solid_dot.svg @@ -0,0 +1,35 @@ + + + Rectangle 9 Copy 5 + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/ic_unlock_fingerprint.svg b/entry/src/ohosTest/resources/base/media/ic_unlock_fingerprint.svg new file mode 100644 index 0000000..1a16dc6 --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_unlock_fingerprint.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + diff --git a/entry/src/ohosTest/resources/base/media/ic_white_cancel.svg b/entry/src/ohosTest/resources/base/media/ic_white_cancel.svg new file mode 100644 index 0000000..99200b4 --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_white_cancel.svg @@ -0,0 +1,30 @@ + + + Public/ic_public_cancel + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/icon_applock_2.png b/entry/src/ohosTest/resources/base/media/icon_applock_2.png new file mode 100644 index 0000000000000000000000000000000000000000..f7bc1d8329a4fc8f7e34db40e9cb7cbb8b52a3ea GIT binary patch literal 11422 zcmV;PEMe1$P)C?O#1T{iE$UD33%Q2`?WgwQB35)`Ln*)qv7gp^7OH zmSlH!W@l!XNjAyuY?cHJ3jqQNQ6K^V1ZtGGFGPGLB-7t_!*~`Z@wdb5&dhFR&beo1 zXJ_a2`|O?jyZ8R?}wM1T_n;YyCH__5m`8p%o04V)Cd$s4E~16Uy|0~NPou2)vFf%xyRFYFWh z#xa(bh$G%4#{}#+2b>EzCkJw8N^XKyWSH1MmrEMz66Im6Bwfe&D{mBnkO9UeCW zyn!(nf+dv8fGsUj>XU9xW;>imqF^1))x~i)cqC~!t|1n4G`o6FTaAjg@qcZwAj_J=9qcKb)dP6YsXq^l5T zgCuHibUuB);I+7BTzif)Wrs~n9>W9iNQNf9u+b@!HE`qFML9N%+zZF%&P&A2DHH-)j7qqXfm!EP*-YOYGu#`-#7^lh40s)gwQZ<{&L1ow2M|F(?K%+sHcNR2N~=10G!VA zRiA9Qr?|Jc$2rcF{y>N%#Rek)qBcUZ4dw_WSsPov1@{>D+6mO8X)2VYOOZ!`L?48M z`#Ol}mX(3Pt+>~?=eYMd&XhV|G9G~lhCqAhdmP)pQ;4~Bo*4RmanCtPx(RLI_^=I5 zNWMX|iz%1;yvDRrR5Ju^fi}r;CcU*?g2A;<)$DO-M=?MRCLmM(8p30@71xSHE|_xCw&q zjd(9KbKSr1eOtYuZ*?7IJ#`;Q{6gEI4P$*h;VGVjA<5UJ)5J)n4Q^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cLaYF{ zKOR3h-3lM!D}09Uo~pS~$4Y<6OF5g?m$j@G?vX~Us)+44ei--ypWqvOgssTSUzm$diaT0TAIP)g!26f!2%O=L5AX#(!8iEGvGTXX1a3mP;e^V4Yib(!s*Hra zACZHclE4j)aD_A6@d3WTCytdt2<}Q!&4WeL@U~PPIn$TS^2>iB55&w32e`lqZg7Mv zoWBb!EMRi1SotY2 z+BbJo&kh-Xci05E)br8aWYlnH^qA{H`#8UzwVYu)2S**CB(~yvJu; s!?oPQz34!fxy+@|-LYZ!=zUw>0S+?EE6mVUmH+?%07*qoM6N<$g5?x*#Q*>R literal 0 HcmV?d00001 diff --git a/entry/src/ohosTest/resources/base/media/icon_applock_3.png b/entry/src/ohosTest/resources/base/media/icon_applock_3.png new file mode 100644 index 0000000000000000000000000000000000000000..82d10ccfa5862954c52f516a73ae49c916838f96 GIT binary patch literal 5768 zcmYjVc{r4B_isgsNn~$Sk|fC9Ko^a!Er_PtFo#J?Z+d_quv}ZRR-`6 z)=j)T=j`a!XjNU4fCr(mTDdvpKgLpAD`y+L#Q1KjHAZVaNN)}7WfWik$!PC8z^E7N zN&VcVyDf>1U+I=7tlkhFbDJj;5>~;EJ-+jD#D@b$aMs|gXI@_067!v%w_Az}qh=Q< zg33gO5@LOCV}MX`n?V|H${JX#qwuxM?eEP>?(5Zt;$xv{>&bm`_IxhP5j}F~pUq|x zR4%G8Rn8icso`oH!Dpesf1&s_?UZaaiwf)Fw0|!nc`a4bVCzlA76OhyAxa!x!u~MvvvReTS&=u- z4!4E74hh)Wr-iLR7uF|A0l&GPr#a#N@6I z&J>t3PbN%=c% z$5idT9Uoowm*GM%bAivy4WR7Al8A}8t+oaC!p8DPF)0jAj%v^x4MEno!+d#KX^FsU z7ydUPqX9XSz-G;7u!X|k`g@&QA5Yp{Gt@cC1cY7Bi@e*5%C<36vQy=X5UF@{tDHkn zRe?)(RDW-Y{I2}E#wE-Qr{+C)N38HoKQGEhHnDbYT?tU?0w!UjDZ8f#D3K+il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sXCM@LyZ$D-$;<_dl8=>@g-twbv($i0gE~5$ppoz{)Uj&q`Cua2OmhY{x zD%M(kW#4N-*^e;GwG@h8Er}O$)Bz+JGn)zCmiudqG1y&5-%2R;{@wVgVMVk({Q_Tk z-TF>bXZ2W5d*H`*>*}q_GPl4^>)r$dxo51y*3?hfk?vjllFa;DkxM?4(Ylfe@>h;S z$k{`3m+~&S_Ix8r(m`SBJ?{@(Blq?cOHO4MD@9hakYzrG0^ z`1bZvPqP12|E2oNBCO$Rh1arghzh}EbNDu?y(4)>!zCu?J&N#-Ex_8VGl&7{AF8MJ z1z{v{mD0Se5q+|t_yW9SmyO2{7dF7@c{u!v+O6M$vnYkS7kLol2ikh$mz?FC{AMt_ z0o_rFg5TqN!G=DBOmL_t84r~f#2+iczzA@mIyfs#Ys&$$v_K6yv zsx@}Kn7}h!l3>vdzZ3K+)#-X~1V$_K;`N3cAx5?l>nLwwj-ah_h(NVTuXO!*f?VqF zV#f-jZlZ_B%y6F67s0tu`QS5Ws0`5#{6_0FEb@N3wj0bBbq!msc5GJI#mTF|i%)9W z*u8c5)V%bF4pgaqmpZrp(i+!s&!u1KBCMXLiiB%kpUAPb8vW_{@YB<{wl>6V&-2-u zdjU*6cRFoyRrz{M^p@qr+SN6F^9ye9&CS*nfjwRJ$lr==h~Kxu>gza~RoobNSh$^i XE{Y;0V~_t~KB29yuU4%3Ea3kDNNk>> literal 0 HcmV?d00001 diff --git a/entry/src/ohosTest/resources/base/media/icon_applock_4.png b/entry/src/ohosTest/resources/base/media/icon_applock_4.png new file mode 100644 index 0000000000000000000000000000000000000000..c900ef3d350c1117da056fa2982e2344b6d192da GIT binary patch literal 8717 zcmXwfcQ~8x_kWApgj#J7o7Sim6tR+;F>246EoqIkW^G!eMuSpCtyJwAwYMro&D7po z#NO2YrSH%8_gvTWJXh}PKIgp7dG7N%uRjv`SXZ5f5=eRD#tj-xjYkHAcjdpEoRsiX z=p&W5af54E^O1_t>zkXY;pk~Gx`-!^j<}O))V&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(F?26cq4w&IB2dCa7Guq4}o4)DEcLz^pA!o zDRF(>amS>qPb3mUOSQt}Z3qT;h51y}Id>U1{VcxtB5up6&2J_qw}iumS%)+QSaVkk z@8q&7GqdMVlZlxi_B?F3^Mfq15{b;TNDp0qRV#TtkO}vk<$TI)7opvfJxu$Kmjbf+}cV->#}QzBjJ z0iL5C#^iFD*eY>)6D8rtTI|Blh*qG`(gz(7FpHd`7fgftU_Gq`>r#J{7aHB7m;QIg zha%DaCVWC13_eWG$oL@?eV@=_h5+`l$=7q#Uk`BKxOk!aVzIEWpvw2kXc>gG^_vRUy7O3Y#%$)^;m;z)1qdG`+3ddm{#7?43-1<}ef5{%$*$<26ltXN>! zm@?~>jD)xM+u$?an-WN1g69KLhX3cb9`DH^#3W1G?yc&Z_jiaD9}QJ@Mh`f7o(70Q zHMAgIzHmif1UdVwu}9q7lM9GB$61-44v(qu+V_!h8_Wv$v*%WZbD7gQiso5QJNRRx zUD#+l-|qfp7g+DlydF5Az+7JoD4kyp`W~ + + + + right + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/white_faceID.svg b/entry/src/ohosTest/resources/base/media/white_faceID.svg new file mode 100644 index 0000000..3d3e474 --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/white_faceID.svg @@ -0,0 +1,54 @@ + + + + + error + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/en_US/element/string.json b/entry/src/ohosTest/resources/en_US/element/string.json new file mode 100644 index 0000000..52145f8 --- /dev/null +++ b/entry/src/ohosTest/resources/en_US/element/string.json @@ -0,0 +1,144 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "AuthWidget" + }, + { + "name": "unified_authwidget_forgotpwd", + "value": "Forgot password" + }, + { + "name": "unified_authwidget_locked", + "value": "Locked" + }, + { + "name": "unified_authwidget_confirm", + "value": "OK" + }, + { + "name": "unified_authwidget_cancel", + "value": "Cancel" + }, + { + "name": "unified_authwidget_delete", + "value": "Delete" + }, + { + "name": "unified_authwidget_back", + "value": "Back" + }, + { + "name": "unified_authwidget_usepwd", + "value": "Use password" + }, + { + "name": "unified_authwidget_hint_pwd_error", + "value": "Incorrect password" + }, + { + "name": "fingerprint_matching_failed", + "value": "Fingerprint matching failed" + }, + { + "name": "unified_authwidget_hint_inscreen_fp", + "value": "Press the fingerprint sensor to verify your fingerprint." + }, + { + "name": "unified_authwidget_hint_normal_fp_only", + "value": "Press the fingerprint sensor to verify your fingerprint." + }, + { + "name": "unified_authwidget_hint_fp_verify_success", + "value": "Verification successful." + }, + { + "name": "unified_authwidget_hint_fp_retry_s1", + "value": "Fingerprint not recognized. Make sure your finger and the sensor are clean." + }, + { + "name": "unified_authwidget_title_fp_forbidden_enter_pwd", + "value": "Fingerprint ID disabled. Enter your password." + }, + { + "name": "unified_authwidget_title_fp_forbidden_enter_pin", + "value": "Fingerprint ID disabled. Enter your PIN." + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pattern", + "value": "Fingerprint ID disabled. Use Face Recognition or your pattern." + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pwd", + "value": "Fingerprint ID disabled. Use Face Recognition or your password." + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pin", + "value": "Fingerprint ID disabled. Use Face Recognition or your PIN." + }, + { + "name": "unified_authwidget_hint_recognizing", + "value": "Scanning…" + }, + { + "name": "unified_authwidget_hint_recognize_success", + "value": "Verification successful." + }, + { + "name": "unified_authwidget_hint_face_verify_fail_click_retry_s1", + "value": "Face not recognized. Touch here to try again." + }, + { + "name": "unified_authwidget_hint_face_verify_fail_click_retry_s2", + "value": "Face not recognized. Double-tap to try again." + }, + { + "name": "unified_authwidget_title_face_forbidden_use_pwd", + "value": "Face Recognition disabled. Enter your password." + }, + { + "name": "unified_authwidget_title_face_forbidden_use_pin", + "value": "Face Recognition disabled. Enter your PIN." + }, + { + "name": "unified_authwidget_title_face_forbidden_use_fp_pwd", + "value": "Face Recognition disabled. Use your fingerprint or password." + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pwd", + "value": "Face Recognition and Fingerprint ID disabled. Enter your password." + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pin", + "value": "Face Recognition and Fingerprint ID disabled. Enter your PIN." + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pattern", + "value": "Face Recognition and Fingerprint ID disabled. Draw your pattern." + }, + { + "name": "unified_authwidget_hint_pin_error", + "value": "Incorrect PIN" + } + ] +} \ No newline at end of file diff --git a/entry/src/ohosTest/resources/zh_CN/element/string.json b/entry/src/ohosTest/resources/zh_CN/element/string.json new file mode 100644 index 0000000..71d7941 --- /dev/null +++ b/entry/src/ohosTest/resources/zh_CN/element/string.json @@ -0,0 +1,144 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "测试模块描述" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "AuthWidget" + }, + { + "name": "unified_authwidget_forgotpwd", + "value": "忘记密码" + }, + { + "name": "unified_authwidget_locked", + "value": "已锁定" + }, + { + "name": "unified_authwidget_confirm", + "value": "确定" + }, + { + "name": "unified_authwidget_cancel", + "value": "取消" + }, + { + "name": "unified_authwidget_delete", + "value": "删除" + }, + { + "name": "unified_authwidget_back", + "value": "返回" + }, + { + "name": "unified_authwidget_usepwd", + "value": "使用密码" + }, + { + "name": "unified_authwidget_hint_pwd_error", + "value": "密码错误" + }, + { + "name": "fingerprint_matching_failed", + "value": "指纹匹配失败" + }, + { + "name": "unified_authwidget_hint_inscreen_fp", + "value": "请按压屏内指纹感应区验证指纹" + }, + { + "name": "unified_authwidget_hint_normal_fp_only", + "value": "请轻触感应器验证指纹" + }, + { + "name": "unified_authwidget_hint_fp_verify_success", + "value": "指纹识别成功" + }, + { + "name": "unified_authwidget_hint_fp_retry_s1", + "value": "指纹不匹配,请保持手指和感应器清洁" + }, + { + "name": "unified_authwidget_title_fp_forbidden_enter_pwd", + "value": "指纹已禁用,请输入密码" + }, + { + "name": "unified_authwidget_title_fp_forbidden_enter_pin", + "value": "指纹已禁用,请输入密码" + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pattern", + "value": "指纹已禁用,请使用人脸或图案" + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pwd", + "value": "指纹已禁用,请使用人脸或密码" + }, + { + "name": "unified_authwidget_title_fp_forbidden_use_face_pin", + "value": "指纹已禁用,请使用人脸或密码" + }, + { + "name": "unified_authwidget_hint_recognizing", + "value": "正在识别中" + }, + { + "name": "unified_authwidget_hint_recognize_success", + "value": "人脸识别成功" + }, + { + "name": "unified_authwidget_hint_face_verify_fail_click_retry_s1", + "value": "未识别成功,点击此处重试" + }, + { + "name": "unified_authwidget_hint_face_verify_fail_click_retry_s2", + "value": "未识别成功,双击屏幕重试" + }, + { + "name": "unified_authwidget_title_face_forbidden_use_pwd", + "value": "人脸已禁用,请输入密码" + }, + { + "name": "unified_authwidget_title_face_forbidden_use_pin", + "value": "人脸已禁用,请输入密码" + }, + { + "name": "unified_authwidget_title_face_forbidden_use_fp_pwd", + "value": "人脸已禁用,请使用指纹或密码" + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pwd", + "value": "人脸和指纹已禁用,请输入密码" + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pin", + "value": "人脸和指纹已禁用,请输入密码" + }, + { + "name": "unified_authwidget_title_face_fp_forbidden_use_pattern", + "value": "人脸和指纹已禁用,请绘制图案" + }, + { + "name": "unified_authwidget_hint_pin_error", + "value": "密码错误" + } + ] +} \ No newline at end of file diff --git a/hvigorfile.js b/hvigorfile.js new file mode 100644 index 0000000..5f2735e --- /dev/null +++ b/hvigorfile.js @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file diff --git a/package.json b/package.json index 020bbbc..254c7ac 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,21 @@ { - "name": "auth_widget", - "version": "1.0.0", + "license": "ISC", + "devDependencies": {}, + "author": "", + "name": "authwidget", + "description": "Please describe the basic information.", "ohos": { "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "project" + "directoryLevel": "project", + "buildTool": "hvigor" }, - "description": "example description", - "repository": {}, - "license": "ISC", + "main": "", + "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.5", - "@ohos/hvigor": "1.4.0", - "@ohos/hvigor-ohos-plugin": "1.4.0" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "hypium": "^1.0.0", + "@ohos/hvigor": "1.3.1" } } + -- Gitee