update auth_widget code
Signed-off-by: dengjiewen <dengjiewen1@huawei.com>
@@ -0,0 +1,9 @@
|
||||
/node_modules
|
||||
/local.properties
|
||||
**/local.properties
|
||||
/.idea
|
||||
**/build
|
||||
/.hvigor
|
||||
.preview
|
||||
*/.preview
|
||||
**/package-lock.json
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
<!-- 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
|
||||
@@ -13,70 +13,14 @@
|
||||
limitations under the License.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
All configurations in this file will be merged to OAT-Default.xml, if you have any questions or concerns, please create issue in OpenHarmony/tools_oat and @jalenchen or chenyaxun.
|
||||
|
||||
licensefile:
|
||||
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
|
||||
|
||||
policylist:
|
||||
1. policy: If the OAT-Default.xml policies do not meet your requirements, please add policies here.
|
||||
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
|
||||
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
|
||||
3. policyitem type:
|
||||
"compatibility" is used to check license compatibility in the specified path;
|
||||
"license" is used to check source license header in the specified path;
|
||||
"copyright" is used to check source copyright header in the specified path;
|
||||
"import" is used to check source dependency in the specified path, such as import ... ,include ...
|
||||
"filetype" is used to check file type in the specified path, supported file types: archive, binary
|
||||
"filename" is used to check whether the specified file exists in the specified path(projectroot means the root dir of the project), supported file names: LICENSE, README, README.OpenSource
|
||||
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
|
||||
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
|
||||
7. policyitem filefilter: Used to bind filefilter which define filter rules.
|
||||
7. policyitem desc: Used to describe the reason of this policy item, committers will check this while merging the code.
|
||||
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
|
||||
|
||||
Note:If the text contains special characters, please escape them according to the following rules:
|
||||
" == "
|
||||
& == &
|
||||
' == '
|
||||
< == <
|
||||
> == >
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<!--policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/-->
|
||||
<!--policyitem type="license" name="LGPL" path=".*" desc="Dynamically linked by module X"/-->
|
||||
<!--policyitem type="copyright" name="xxx" path=".*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="Developed by X Company"/-->
|
||||
</policy>
|
||||
</policylist>
|
||||
|
||||
<filefilterlist>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies"/>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<filteritem type="filename" name="*.iml|*.json|*.txt" desc="desc files"/>
|
||||
<filteritem type="filepath" name="target/.*" desc="Compile output files"/>
|
||||
<filteritem type="filepath" name="out/.*" desc="Compile output files"/>
|
||||
<filteritem type="filepath" name="log/.*" desc="log files"/>
|
||||
<filteritem type="filepath" name=".idea/.*" desc="IDE temp files"/>
|
||||
<filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/>
|
||||
<filteritem type="filepath" name="src/test/.*" desc="Test files"/>
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<filteritem type="filepath" name="src/main/java/ohos/oat/analysis/headermatcher/.*" desc="License matcher rules, not license header"/>
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
|
||||
</filefilter>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
|
||||
</filefilter>
|
||||
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
|
||||
</filefilter>
|
||||
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<filteritem type="filename" name="*.png|*.jpg|*.svg" desc="Allow open source ux images"/>
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
</oatconfig>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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'
|
||||
import NumKeyBoard from './NumkeyBoard';
|
||||
|
||||
const TAG = "CustomPSD";
|
||||
|
||||
const CONTROL_TYPE_SIX_NUMBER = 1;
|
||||
const CONTROL_TYPE_ARBITRARY_NUMBER = 2;
|
||||
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<userAuth.UserAuthType>;
|
||||
@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<CmdType>;
|
||||
@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));
|
||||
}
|
||||
if (remainAttempts === 0 && lockoutDuration) {
|
||||
this.lock = 1;
|
||||
this.countdown(lockoutDuration);
|
||||
}
|
||||
|
||||
if (!remainAttempts && !lockoutDuration) {
|
||||
this.lock = 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
});
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
aboutToDisappear(): void {
|
||||
this.clearPassword();
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
}
|
||||
|
||||
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 === 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_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 === 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%')
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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<string>): 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<userAuth.UserAuthType>): 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;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
static deviceDpi = ['360vp', '780vp'];
|
||||
|
||||
// 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 = '请在竖屏状态下进行验证'
|
||||
// Pin type
|
||||
static pinSix = 'PIN_SIX';
|
||||
static pinNumber = 'PIN_NUMBER';
|
||||
static pinMixed = 'PIN_MIXED';
|
||||
|
||||
//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 fullContainerWidth = '100%';
|
||||
static fullContainerHeight = '100%';
|
||||
static halfContainerWidth = '50%';
|
||||
static ninetyPercentWidth = '90%';
|
||||
|
||||
//layout params - Pic
|
||||
static FULL_CONTAINER_WIDTH = '100%'
|
||||
static FULL_CONTAINER_HEIGHT = '100%'
|
||||
static HALF_CONTAINER_WIDTH = '50%'
|
||||
static NINETY_PERCENT_WIDTH = '90%'
|
||||
|
||||
//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;
|
||||
|
||||
//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;
|
||||
|
||||
//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';
|
||||
static noticeTypePin = 'pin';
|
||||
static noticeTypeFace = 'face';
|
||||
static noticeTypeFinger = '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
|
||||
|
||||
//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,
|
||||
}
|
||||
@@ -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<void> {
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,82 +13,176 @@
|
||||
* 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> = [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> = [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<CmdType> = [];
|
||||
@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();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onAccept() {
|
||||
LogUtils.d(TAG, 'Callback when the second button is clicked')
|
||||
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]);
|
||||
}
|
||||
|
||||
existApp() {
|
||||
LogUtils.d(TAG, 'Click the callback in the blank area')
|
||||
globalThis.session?.terminateSelf();
|
||||
storage?.clear();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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 || [];
|
||||
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
|
||||
}
|
||||
}
|
||||
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:' +
|
||||
@@ -96,78 +190,58 @@ struct Index {
|
||||
}
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
LogUtils.d(TAG, 'aboutToDisappear')
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
LogUtils.i(TAG, 'onPageShow');
|
||||
}
|
||||
|
||||
onPageHide() {
|
||||
LogUtils.i(TAG, 'onPageHide');
|
||||
}
|
||||
|
||||
onBackPress() {
|
||||
LogUtils.i(TAG, 'onBackPress');
|
||||
}
|
||||
|
||||
getParams() {
|
||||
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));
|
||||
}
|
||||
|
||||
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 })
|
||||
}
|
||||
}
|
||||
@@ -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<userAuth.UserAuthType>;
|
||||
@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)
|
||||
}
|
||||
}
|
||||
@@ -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<CmdType>;
|
||||
@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;
|
||||
|
||||
aboutToAppear() {
|
||||
queryScreenInfo(): void {
|
||||
try {
|
||||
LogUtils.d(TAG, 'aboutToAppear PINAuth start');
|
||||
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(): void {
|
||||
if (this.cmdData && this.cmdData.length > 0) {
|
||||
this.onCmdDataChange('first');
|
||||
}
|
||||
try {
|
||||
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,138 +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.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'))
|
||||
.fontColor($r('sys.color.ohos_id_color_secondary'))
|
||||
} else if (this.prompt === Constants.FINGER_LOCK) {
|
||||
Image($r("app.media.ic_unlock_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"))
|
||||
.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 !== Constants.FINGER_LOCK) {
|
||||
this.checkPassword('fingerprint')
|
||||
}
|
||||
})
|
||||
Text(this.prompt)
|
||||
.fontColor($r('sys.color.ohos_id_color_primary'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
}
|
||||
Row() {
|
||||
Column() {
|
||||
Button($r("app.string.unified_authwidget_cancel"), { stateEffect: true })
|
||||
.margin({ left: $r('app.float.content_padding') })
|
||||
.width(Constants.NINETY_PERCENT_WIDTH)
|
||||
.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();
|
||||
this.cancel()
|
||||
this.textValue = ""
|
||||
})
|
||||
}.width(Constants.HALF_CONTAINER_WIDTH)
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.width($r('app.float.digitalpsd_passwdmask_height'))
|
||||
.height($r('app.float.digitalpsd_passwdmask_height'))
|
||||
.color($r("sys.color.ohos_id_color_list_separator"))
|
||||
.width($r('app.float.divider_width'))
|
||||
Column() {
|
||||
Button($r('app.string.unified_authwidget_usepwd'))
|
||||
.margin({ right: $r('app.float.content_padding') })
|
||||
.width(Constants.NINETY_PERCENT_WIDTH)
|
||||
.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(() => {
|
||||
this.inputValue = " "
|
||||
this.state = 5
|
||||
})
|
||||
}.width(Constants.HALF_CONTAINER_WIDTH)
|
||||
}
|
||||
.height($r('app.float.btn_height'))
|
||||
.margin({ top: $r("app.float.element_margin"), bottom: $r('app.float.content_padding') })
|
||||
}
|
||||
else if (this.state === 1) {
|
||||
Text(globalThis.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"))
|
||||
.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,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_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')
|
||||
})
|
||||
.width($r('app.float.image_size'))
|
||||
.height($r('app.float.image_size'))
|
||||
|
||||
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')
|
||||
@@ -368,36 +315,226 @@ 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)
|
||||
.id('cancelBtnState2FingerprintAuth')
|
||||
.margin({ left: $r('app.float.content_padding') })
|
||||
.width(Constants.ninetyPercentWidth)
|
||||
.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)
|
||||
}
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.textValue = '';
|
||||
})
|
||||
}.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($r('app.string.unified_authwidget_usepwd'))
|
||||
.id('usePwdBtnState2FingerprintAuth')
|
||||
.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)
|
||||
.onClick(() => {
|
||||
this.inputValue = ' ';
|
||||
if (this.pinSubType !== Constants.pinSix) {
|
||||
this.state = 5;
|
||||
} else {
|
||||
this.state = 6;
|
||||
}
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
}
|
||||
.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') })
|
||||
.margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') })
|
||||
}
|
||||
else if (this.state === 1) {
|
||||
|
||||
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.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')
|
||||
})
|
||||
.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'))
|
||||
.fontColor($r('sys.color.ohos_id_color_secondary'))
|
||||
} 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'))
|
||||
|
||||
Text(this.prompt)
|
||||
.fontColor($r('sys.color.ohos_id_color_warning'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
} 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')
|
||||
})
|
||||
.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_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'))
|
||||
}
|
||||
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') })
|
||||
}
|
||||
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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<CmdType>;
|
||||
@State isEdit: boolean = true;
|
||||
// tip
|
||||
@State inputValue: string = ' ';
|
||||
controller: CustomDialogController;
|
||||
cancel: () => void;
|
||||
confirm: () => void;
|
||||
|
||||
onFlagChange() {
|
||||
if (this.controllerFlag) {
|
||||
globalThis.session?.terminateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
onTextValueChange() {
|
||||
onTextValueChange(): void {
|
||||
pinData = this.textValue;
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
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(): 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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": "失败次数过多,人脸已禁用"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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<void> {
|
||||
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');
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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');
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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');
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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');
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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');
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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');
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
@@ -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> = [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<CmdType> = [];
|
||||
|
||||
onCancel(): void {
|
||||
LogUtils.d(TAG, 'Callback when the first button is clicked');
|
||||
globalThis.session?.terminateSelf();
|
||||
}
|
||||
|
||||
@State message: string = 'Hello World'
|
||||
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();
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"boolean": [
|
||||
{
|
||||
"name": "boolean_1",
|
||||
"value": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<svg id="图层_5"
|
||||
data-name="图层 5"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 240 240">
|
||||
<defs>
|
||||
<style>.cls-1{fill:#000000;}</style>
|
||||
</defs>
|
||||
<title>error</title>
|
||||
<g
|
||||
id="人脸图标_圆环"
|
||||
data-name="人脸图标 圆环">
|
||||
<path
|
||||
id="形状结合"
|
||||
class="cls-1"
|
||||
d="M120,8.49a112,112,0,1,1-112,112A112,112,0,0,1,120,8.49Zm0,10a102,102,0,1,0,102,102A102,102,0,0,0,120,18.49Z"/>
|
||||
</g>
|
||||
<g
|
||||
id="人脸图标_眼睛"
|
||||
data-name="人脸图标 眼睛">
|
||||
<g id="Group-Copy-13">
|
||||
<path
|
||||
id="形状结合-2"
|
||||
data-name="形状结合"
|
||||
class="cls-1"
|
||||
d="M78.5,79.5A9.5,9.5,0,1,1,69,89,9.5,9.5,0,0,1,78.5,79.5Zm84,0A9.5,9.5,0,1,1,153,89,9.5,9.5,0,0,1,162.5,79.5Z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="人脸图标_嘴巴"
|
||||
data-name="人脸图标 嘴巴">
|
||||
<g
|
||||
id="Group-Copy-13-2"
|
||||
data-name="Group-Copy-13">
|
||||
<path
|
||||
id="形状结合-3"
|
||||
data-name="形状结合"
|
||||
class="cls-1"
|
||||
d="M75.52,157.69a5,5,0,0,1,6.87,1.67,44,44,0,0,0,75,.35,5,5,0,0,1,8.49,5.28,54,54,0,0,1-92-.43A5,5,0,0,1,75.52,157.69Z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="人脸图标_鼻子"
|
||||
data-name="人脸图标 鼻子">
|
||||
<g
|
||||
id="Group-Copy-13-3"
|
||||
data-name="Group-Copy-13">
|
||||
<path
|
||||
id="形状结合-4"
|
||||
data-name="形状结合"
|
||||
class="cls-1"
|
||||
d="M118.05,96.27a5,5,0,0,1,9.74,2.24l-0.05.22-8.32,32.77H129a5,5,0,0,1,5,4.78v0.22a5,5,0,0,1-4.78,5H113a5,5,0,0,1-4.89-6l0-.2Z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px"
|
||||
height="24px"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Public/ic_public_cancel</title>
|
||||
<defs>
|
||||
<path
|
||||
d="M19.7781746,4.22182541 C20.0710678,4.51471863 20.0710678,4.98959236 19.7781746,5.28248558 L5.28248558,19.7781746 C4.98959236,20.0710678 4.51471863,20.0710678 4.22182541,19.7781746 C3.92893219,19.4852814 3.92893219,19.0104076 4.22182541,18.7175144 L10.9395166,11.9994697 L4.22182541,5.28248558 C3.92893219,4.98959236 3.92893219,4.51471863 4.22182541,4.22182541 C4.51471863,3.92893219 4.98959236,3.92893219 5.28248558,4.22182541 L12,10.9389863 L18.7175144,4.22182541 C19.0104076,3.92893219 19.4852814,3.92893219 19.7781746,4.22182541 Z M19.7781746,18.7175144 C20.0710678,19.0104076 20.0710678,19.4852814 19.7781746,19.7781746 C19.4852814,20.0710678 19.0104076,20.0710678 18.7175144,19.7781746 L12.7072836,13.7675902 L13.767767,12.7071068 L19.7781746,18.7175144 Z"
|
||||
id="path-1"></path>
|
||||
</defs>
|
||||
<g
|
||||
id="Public/ic_public_cancel"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<mask
|
||||
id="mask-2"
|
||||
fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use
|
||||
id="形状"
|
||||
fill="#000000"
|
||||
xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="22px"
|
||||
height="20px"
|
||||
viewBox="0 0 22 20"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Public/ic_public_password_unvisible</title>
|
||||
<defs>
|
||||
<path
|
||||
d="M3.24433269,2.18592862 L3.28033009,2.21966991 L21.7803301,20.7196699 C22.0732233,21.0125631 22.0732233,21.4874369 21.7803301,21.7803301 C21.4991526,22.0615076 21.0502619,22.0727547 20.7556673,21.8140714 L20.7196699,21.7803301 L16.8721008,17.932592 C15.3324474,18.6243412 13.6700217,19 12,19 C7.6616265,19 3.34195001,16.4588234 1.1237988,12.4261126 C0.958720986,12.1259928 0.958734525,11.7622639 1.12383468,11.4621564 C2.22017457,9.46930648 3.82685023,7.86720015 5.69590623,6.75670025 L2.21966991,3.28033009 C1.9267767,2.98743687 1.9267767,2.51256313 2.21966991,2.21966991 C2.5008474,1.93849242 2.94973814,1.92724532 3.24433269,2.18592862 Z M2.6270143,11.855814 L2.57475,11.94425 L2.62906687,12.0363214 C4.20829156,14.682087 6.85453152,16.5732705 9.73508149,17.238259 C7.96961792,16.3923274 6.75,14.5885922 6.75,12.5 C6.75,11.9635357 6.83046337,11.4458645 6.9799799,10.9583969 C7.05366048,10.7181766 7.27572261,10.7770121 7.3241015,10.9659401 C7.58677335,11.9917192 8.51733369,12.75 9.625,12.75 C10.201929,12.75 10.7308116,12.5442893 11.1423007,12.2022152 L6.79486267,7.85576427 C5.10284139,8.78587388 3.64173689,10.1577737 2.6270143,11.855814 Z M14.2654924,17.2373858 L14.5117917,17.1777816 C14.9230064,17.0721181 15.3287239,16.9413925 15.7265286,16.7869819 L15.4217087,16.4818804 C15.0731107,16.7817122 14.6847015,17.036551 14.2654924,17.2373858 Z M11.9855652,5 C16.3241739,5 20.6294483,7.43580293 22.8461207,11.4681793 C23.0110287,11.7681655 23.0110272,12.1316601 22.8461169,12.4316451 C21.9169357,14.1218985 20.622921,15.5497164 19.1132976,16.6379205 L18.0366544,15.561523 C19.3555913,14.6523638 20.4980275,13.4559114 21.3406926,12.0424401 L21.395,11.95 L21.3427165,11.8611806 C19.3982331,8.6048523 15.8133859,6.54561308 12.1090841,6.50074831 L11.9855652,6.5 C11.0839296,6.5 10.1885641,6.61938777 9.32124627,6.84647433 L8.11784946,5.64302867 C9.3660598,5.22201139 10.6741502,5 11.9855652,5 Z M12,7.25 L12.2164046,7.25437905 C15.0155511,7.36786837 17.25,9.67299244 17.25,12.5 C17.25,12.639781 17.2456993,12.7637607 17.2371876,12.8731375 C17.1991898,13.4128088 17.0793591,13.9312499 16.8898895,14.4147476 L10.0849199,7.6102408 C10.1876906,7.56995961 10.2920404,7.53282481 10.3978507,7.49895493 C10.4034478,7.49733403 10.4100403,7.49502721 10.4168532,7.49287563 L10.523457,7.46048776 C10.5414874,7.4552137 10.5595579,7.45003377 10.5776681,7.44494854 L10.4168532,7.49287563 C10.5266282,7.45820774 10.6379617,7.42704833 10.7507223,7.39952944 L10.8001557,7.38773526 C10.8415571,7.37805619 10.8831468,7.36886707 10.9249186,7.36017433 L10.7507223,7.39952944 C10.8643833,7.37179081 10.9794942,7.34775107 11.0959203,7.32754546 C11.1654222,7.31549531 11.234869,7.3048751 11.3047495,7.29562937 C11.3270733,7.29267296 11.3495242,7.28984962 11.3720187,7.28716849 C11.4447555,7.27849891 11.5180446,7.27130708 11.5917602,7.26563766 C11.6262556,7.2629848 11.660759,7.2606707 11.6953521,7.2586915 C11.7961526,7.25292396 11.8977348,7.25 12,7.25 L12,7.25 L12,7.25 Z"
|
||||
id="path-1"></path>
|
||||
</defs>
|
||||
<g
|
||||
id="身份验证"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<g
|
||||
id="编组"
|
||||
transform="translate(-1.000000, -2.000000)">
|
||||
<mask
|
||||
id="mask-2"
|
||||
fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<g
|
||||
id="形状结合"
|
||||
fill-rule="nonzero"></g>
|
||||
<g
|
||||
mask="url(#mask-2)"
|
||||
fill="#000000"
|
||||
fill-opacity="0.9"
|
||||
id="color/#000000">
|
||||
<g>
|
||||
<rect
|
||||
x="0"
|
||||
y="0"
|
||||
width="24"
|
||||
height="24"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="22px"
|
||||
height="14px"
|
||||
viewBox="0 0 22 14"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Public/ic_public_password_visible</title>
|
||||
<defs>
|
||||
<path
|
||||
d="M11.9855652,5 C16.3241739,5 20.6294483,7.43580293 22.8461207,11.4681793 C23.0110287,11.7681655 23.0110272,12.1316601 22.8461169,12.4316451 C20.6306141,16.4618187 16.3409683,19 12,19 C7.6616265,19 3.34195001,16.4588234 1.1237988,12.4261126 C0.958720986,12.1259928 0.958734525,11.7622639 1.12383468,11.4621564 C3.34091662,7.43210006 7.6450303,5 11.9855652,5 Z M12.1090841,6.50074831 L11.9855652,6.5 C8.23510787,6.5 4.59313857,8.56569489 2.6270143,11.855814 L2.57475,11.94425 L2.62906687,12.0363214 C4.20829156,14.682087 6.85453152,16.5732705 9.73508149,17.238259 C7.96961792,16.3923274 6.75,14.5885922 6.75,12.5 C6.75,11.9635357 6.83046337,11.4458645 6.9799799,10.9583969 C7.05366048,10.7181766 7.27572261,10.7770121 7.3241015,10.9659401 C7.58677335,11.9917192 8.51733369,12.75 9.625,12.75 C10.9140612,12.75 11.9632598,11.7230265 11.9990559,10.4426197 L12,10.375 L12,10.125 C12,9.09101624 11.3392463,8.21135977 10.4169507,7.88524243 C10.2077236,7.81126118 10.1886209,7.56495342 10.4168532,7.49287563 C10.5266282,7.45820774 10.6379617,7.42704833 10.7507223,7.39952944 C11.151119,7.3018138 11.5695086,7.25 12,7.25 C14.8994949,7.25 17.25,9.60050506 17.25,12.5 C17.25,14.5881939 16.0308472,16.3916395 14.2654924,17.2373858 C17.1354905,16.5737801 19.7632982,14.688333 21.3406926,12.0424401 L21.395,11.95 L21.3427165,11.8611806 C19.3982331,8.6048523 15.8133859,6.54561308 12.1090841,6.50074831 Z"
|
||||
id="path-1"></path>
|
||||
</defs>
|
||||
<g
|
||||
id="身份验证"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<g
|
||||
id="编组"
|
||||
transform="translate(-1.000000, -5.000000)">
|
||||
<mask
|
||||
id="mask-2"
|
||||
fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<g
|
||||
id="形状结合"
|
||||
fill-rule="nonzero"></g>
|
||||
<g
|
||||
mask="url(#mask-2)"
|
||||
fill="#000000"
|
||||
fill-opacity="0.9"
|
||||
id="color/#000000">
|
||||
<g>
|
||||
<rect
|
||||
x="0"
|
||||
y="0"
|
||||
width="24"
|
||||
height="24"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="12px"
|
||||
height="12px"
|
||||
viewBox="0 0 12 12"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<title>Rectangle 9 Copy 5</title>
|
||||
<g
|
||||
id="password"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd"
|
||||
opacity="0.9">
|
||||
<g
|
||||
id="Lockscreen_password_six-digit-number"
|
||||
transform="translate(-376.000000, -728.000000)"
|
||||
fill="#FFFFFF">
|
||||
<g
|
||||
id="Group"
|
||||
transform="translate(304.000000, 728.000000)">
|
||||
<g id="Group-2">
|
||||
<rect
|
||||
id="Rectangle-9-Copy-5"
|
||||
x="72"
|
||||
y="0"
|
||||
width="12"
|
||||
height="12"
|
||||
rx="6"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 953 B |
|
After Width: | Height: | Size: 6.9 KiB |
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px"
|
||||
height="24px"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Public/ic_public_cancel</title>
|
||||
<defs>
|
||||
<path
|
||||
d="M19.7781746,4.22182541 C20.0710678,4.51471863 20.0710678,4.98959236 19.7781746,5.28248558 L5.28248558,19.7781746 C4.98959236,20.0710678 4.51471863,20.0710678 4.22182541,19.7781746 C3.92893219,19.4852814 3.92893219,19.0104076 4.22182541,18.7175144 L10.9395166,11.9994697 L4.22182541,5.28248558 C3.92893219,4.98959236 3.92893219,4.51471863 4.22182541,4.22182541 C4.51471863,3.92893219 4.98959236,3.92893219 5.28248558,4.22182541 L12,10.9389863 L18.7175144,4.22182541 C19.0104076,3.92893219 19.4852814,3.92893219 19.7781746,4.22182541 Z M19.7781746,18.7175144 C20.0710678,19.0104076 20.0710678,19.4852814 19.7781746,19.7781746 C19.4852814,20.0710678 19.0104076,20.0710678 18.7175144,19.7781746 L12.7072836,13.7675902 L13.767767,12.7071068 L19.7781746,18.7175144 Z"
|
||||
id="path-1"></path>
|
||||
</defs>
|
||||
<g
|
||||
id="Public/ic_public_cancel"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<mask
|
||||
id="mask-2"
|
||||
fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use
|
||||
id="形状"
|
||||
fill="#fff"
|
||||
xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
@@ -0,0 +1,30 @@
|
||||
<svg id="图层_1"
|
||||
data-name="图层 1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 240 240">
|
||||
<defs>
|
||||
<style>.cls-1{fill:#000000;}.cls-2{fill:#000000;}</style>
|
||||
</defs>
|
||||
<title>right</title>
|
||||
<g
|
||||
id="人脸图标_圆环"
|
||||
data-name="人脸图标 圆环">
|
||||
<path
|
||||
id="形状结合"
|
||||
class="cls-1"
|
||||
d="M120,8A112,112,0,1,1,8,120,112,112,0,0,1,120,8Zm0,10A102,102,0,1,0,222,120,102,102,0,0,0,120,18Z"/>
|
||||
</g>
|
||||
<g
|
||||
id="人脸图标_圆环-2"
|
||||
data-name="人脸图标 圆环">
|
||||
<path
|
||||
id="形状结合-2"
|
||||
data-name="形状结合"
|
||||
class="cls-2"
|
||||
d="M120,8A112,112,0,1,1,8,120,112,112,0,0,1,120,8Zm0,10A102,102,0,1,0,222,120,102,102,0,0,0,120,18Z"/>
|
||||
</g>
|
||||
<path
|
||||
id="Combined-Shape"
|
||||
class="cls-2"
|
||||
d="M70,115.94a6.21,6.21,0,0,1,8.78,0l33.65,33.65,57.06-57.06a6.21,6.21,0,0,1,8.78,8.78l-61.45,61.45h0a6.21,6.21,0,0,1-8.78,0l-38-38A6.21,6.21,0,0,1,70,115.94Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,54 @@
|
||||
<svg id="图层_5"
|
||||
data-name="图层 5"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 240 240">
|
||||
<defs>
|
||||
<style>.cls-1{fill:#fff;}</style>
|
||||
</defs>
|
||||
<title>error</title>
|
||||
<g
|
||||
id="人脸图标_圆环"
|
||||
data-name="人脸图标 圆环">
|
||||
<path
|
||||
id="形状结合"
|
||||
class="cls-1"
|
||||
d="M120,8.49a112,112,0,1,1-112,112A112,112,0,0,1,120,8.49Zm0,10a102,102,0,1,0,102,102A102,102,0,0,0,120,18.49Z"/>
|
||||
</g>
|
||||
<g
|
||||
id="人脸图标_眼睛"
|
||||
data-name="人脸图标 眼睛">
|
||||
<g id="Group-Copy-13">
|
||||
<path
|
||||
id="形状结合-2"
|
||||
data-name="形状结合"
|
||||
class="cls-1"
|
||||
d="M78.5,79.5A9.5,9.5,0,1,1,69,89,9.5,9.5,0,0,1,78.5,79.5Zm84,0A9.5,9.5,0,1,1,153,89,9.5,9.5,0,0,1,162.5,79.5Z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="人脸图标_嘴巴"
|
||||
data-name="人脸图标 嘴巴">
|
||||
<g
|
||||
id="Group-Copy-13-2"
|
||||
data-name="Group-Copy-13">
|
||||
<path
|
||||
id="形状结合-3"
|
||||
data-name="形状结合"
|
||||
class="cls-1"
|
||||
d="M75.52,157.69a5,5,0,0,1,6.87,1.67,44,44,0,0,0,75,.35,5,5,0,0,1,8.49,5.28,54,54,0,0,1-92-.43A5,5,0,0,1,75.52,157.69Z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="人脸图标_鼻子"
|
||||
data-name="人脸图标 鼻子">
|
||||
<g
|
||||
id="Group-Copy-13-3"
|
||||
data-name="Group-Copy-13">
|
||||
<path
|
||||
id="形状结合-4"
|
||||
data-name="形状结合"
|
||||
class="cls-1"
|
||||
d="M118.05,96.27a5,5,0,0,1,9.74,2.24l-0.05.22-8.32,32.77H129a5,5,0,0,1,5,4.78v0.22a5,5,0,0,1-4.78,5H113a5,5,0,0,1-4.89-6l0-.2Z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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": "密码错误"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||