mirror of
https://github.com/openharmony/applications_auth_widget.git
synced 2026-07-01 20:14:09 -04:00
add source build for AuthWidget
Signed-off-by: liuhanxiong <liuhanxiong@huawei.com> Change-Id: Iabe61c01e5a2c30cc1cd2ed99b498cba8e67cc0d
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.useriam.authwidget",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
"minAPIVersion": 10,
|
||||
"targetAPIVersion": 10,
|
||||
"distributedNotificationEnabled": true,
|
||||
"apiReleaseType": "Beta5"
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.useriam.authwidget",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
"distributedNotificationEnabled": true
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,10 @@
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "AuthWidget"
|
||||
},
|
||||
{
|
||||
"name": "authwidget_desc",
|
||||
"value": "authwidget"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -13,17 +13,9 @@
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
ohos_hap("authwidget_hap") {
|
||||
hap_profile = "entry/src/main/module5.json"
|
||||
deps = [
|
||||
":authwidget_js_assets",
|
||||
":authwidget_resources",
|
||||
]
|
||||
//certificate_profile = "signature/authwidget.p7b"
|
||||
hap_name = "Authwidget"
|
||||
subsystem_name = "applications"
|
||||
part_name = "prebuilt_hap"
|
||||
module_install_dir = "app/com.ohos.useriam.authwidget"
|
||||
ohos_app_scope("authwidget_app_profile") {
|
||||
app_profile = "./AppScope/app.json"
|
||||
sources = [ "./AppScope/resources" ]
|
||||
}
|
||||
|
||||
ohos_js_assets("authwidget_js_assets") {
|
||||
@@ -31,13 +23,21 @@ ohos_js_assets("authwidget_js_assets") {
|
||||
source_dir = "entry/src/main/ets"
|
||||
}
|
||||
|
||||
ohos_app_scope("authwidget_app_profile") {
|
||||
app_profile = "AppScope/app.json"
|
||||
sources = [ "AppScope/resources" ]
|
||||
}
|
||||
|
||||
ohos_resources("authwidget_resources") {
|
||||
sources = [ "entry/src/main/resources" ]
|
||||
deps = [ ":authwidget_app_profile" ]
|
||||
hap_profile = "entry/src/main/module5.json"
|
||||
hap_profile = "entry/src/main/module.json"
|
||||
}
|
||||
|
||||
ohos_hap("auth_widget") {
|
||||
hap_profile = "entry/src/main/module.json"
|
||||
deps = [
|
||||
":authwidget_js_assets",
|
||||
":authwidget_resources",
|
||||
]
|
||||
certificate_profile = "signature/auth_widget.p7b"
|
||||
hap_name = "AuthWidget"
|
||||
subsystem_name = "applications"
|
||||
part_name = "prebuilt_hap"
|
||||
module_install_dir = "app/com.ohos.useriam.authwidget"
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ The Authentication Widget works with the User Authentication Framework (user_aut
|
||||
In the root directory of the OpenHarmony source code, run the following command to build the Authentication Widget separately:
|
||||
|
||||
```
|
||||
./build.sh --product-name rk3568 --ccache --build-target useriam_auth_widget
|
||||
./build.sh --product-name rk3568 --ccache --build-target auth_widget
|
||||
```
|
||||
|
||||
> **NOTE**
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
在OpenHarmony源码根目录下,调用以下指令,单独编译统一身份认证控件部件。
|
||||
|
||||
```
|
||||
./build.sh --product-name rk3568 --ccache --build-target useriam_auth_widget
|
||||
./build.sh --product-name rk3568 --ccache --build-target auth_widget
|
||||
```
|
||||
|
||||
> 说明:
|
||||
|
||||
@@ -1,621 +0,0 @@
|
||||
/*
|
||||
* 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 display from '@ohos.display';
|
||||
import screen from '@ohos.screen';
|
||||
import userAuth from '@ohos.userIAM.userAuth';
|
||||
import Constants, { CmdType, FingerPosition } from '../../common/vm/Constants';
|
||||
import AuthUtils from '../utils/AuthUtils';
|
||||
import LogUtils from '../utils/LogUtils';
|
||||
import TimeUtils from '../utils/TimeUtils';
|
||||
import NumKeyBoard from './NumkeyBoard';
|
||||
|
||||
const TAG = 'CustomPSD';
|
||||
const INTERVAL = 1000;
|
||||
const DIGITALPSD_IC_DIAMETER = 12;
|
||||
const THOUSANDTH = 1000;
|
||||
const TITLE_POSITION = 200;
|
||||
const THEME_WHITE = 1;
|
||||
const THEME_BLUR = 2;
|
||||
const DEL_PWD = -2;
|
||||
const CALL_PHONE = -1;
|
||||
const GO_BACK = -3;
|
||||
const DEFAULT_SIZE = 72;
|
||||
const FINGER_TEXT_POSITION = 120;
|
||||
const FINGER_X_POSITION = 86;
|
||||
const FINGER_Y_POSITION = 40;
|
||||
|
||||
interface ControlType {
|
||||
isSixPassword?: boolean,
|
||||
isLandscape: boolean,
|
||||
jumpFinger: boolean,
|
||||
isShowFace: boolean,
|
||||
isShowFinger: boolean,
|
||||
}
|
||||
|
||||
interface KeyboardType {
|
||||
index: number,
|
||||
row1: string | Resource,
|
||||
row2?: string,
|
||||
value?: number,
|
||||
bkg?: boolean,
|
||||
}
|
||||
|
||||
@Component
|
||||
export default struct CustomPSD {
|
||||
@Link pinSubType: string;
|
||||
@Link textValue: string;
|
||||
@Link themeType: number;
|
||||
@Link authType: Array<userAuth.UserAuthType>;
|
||||
@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 = {
|
||||
jumpFinger: false,
|
||||
isLandscape: false,
|
||||
isSixPassword: true,
|
||||
isShowFace: this.authType.includes(2),
|
||||
isShowFinger: this.authType.includes(4)
|
||||
}
|
||||
@State fingerPosition: FingerPosition = {
|
||||
sensorType: ''
|
||||
}
|
||||
@State screen: number[] = [];
|
||||
@State lockArr: boolean[] = [false, false];
|
||||
@Consume isLandscape: boolean;
|
||||
@Consume underFingerPrint: boolean;
|
||||
|
||||
queryScreenInfo(): void {
|
||||
try {
|
||||
screen.getAllScreens((err, data) => {
|
||||
if (err.code) {
|
||||
LogUtils.e(TAG, 'Failed to get all screens. Cause: ' + JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
this.screenClass = data[0];
|
||||
});
|
||||
} catch (exception) {
|
||||
LogUtils.e(TAG, 'getAllScreens catch exception: ' + exception);
|
||||
}
|
||||
}
|
||||
|
||||
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'));
|
||||
}
|
||||
}
|
||||
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'));
|
||||
this.lockArr[0] = false;
|
||||
}
|
||||
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'));
|
||||
this.lockArr[0] = true;
|
||||
}
|
||||
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 (remainAttempts < 5) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}
|
||||
}
|
||||
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'));
|
||||
this.lockArr[1] = true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
AppStorage.SetOrCreate('passwordArr', ['', '', '', '', '', '']);
|
||||
this.queryScreenInfo();
|
||||
if (this.cmdData && this.cmdData.length > 0) {
|
||||
this.onCmdDataChange('first');
|
||||
}
|
||||
if (this.controlType.isShowFace && this.controlType.isShowFinger) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace, Constants.noticeTypeFace]);
|
||||
return;
|
||||
}
|
||||
if (this.controlType.isShowFace) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]);
|
||||
return;
|
||||
}
|
||||
if (this.controlType.isShowFinger) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
clearPassword(): void {
|
||||
this.passwordArr = [];
|
||||
this.passwordArrNumber = [];
|
||||
this.passwordArr = ['', '', '', '', '', ''];
|
||||
this.numKeyboard[11].value = GO_BACK;
|
||||
this.updateStorage(() => {
|
||||
})
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.clearPassword();
|
||||
}
|
||||
|
||||
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, globalThis.context);
|
||||
promptText += TRY_AGAIN;
|
||||
setTimeout(this.countdown.bind(this), INTERVAL, freezingTime - INTERVAL);
|
||||
} else {
|
||||
promptText = globalThis.context.resourceManager.getStringSync($r('app.string.unified_authwidget_use_pwd'));
|
||||
this.clearPassword();
|
||||
this.lock = 0;
|
||||
}
|
||||
this.prompt = promptText;
|
||||
}
|
||||
|
||||
updateStorage(callback): void {
|
||||
AppStorage.SetOrCreate('passwordArr', this.passwordArr);
|
||||
AppStorage.SetOrCreate('numKeyboard', this.numKeyboard);
|
||||
callback();
|
||||
}
|
||||
|
||||
build() {
|
||||
if (!this.controlType.jumpFinger) {
|
||||
Column() {
|
||||
Column() {
|
||||
if (this.lock === 1) {
|
||||
Text($r('app.string.unified_authwidget_locked'))
|
||||
.margin({ bottom: '16vp' })
|
||||
.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 === THEME_BLUR) {
|
||||
Image($r('app.media.white_faceID'))
|
||||
.id('faceImgCustomPwd')
|
||||
.width('30vp')
|
||||
.height('30vp')
|
||||
.margin({ bottom: '16vp' })
|
||||
.onClick(() => {
|
||||
if (!this.lockArr[0]) {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_recognition'));
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]);
|
||||
}
|
||||
})
|
||||
}
|
||||
if (this.themeType === THEME_WHITE) {
|
||||
Image($r('app.media.error_faceID'))
|
||||
.width('30vp')
|
||||
.height('30vp')
|
||||
.margin({ bottom: '16vp' })
|
||||
.visibility(Visibility.Visible)
|
||||
.colorBlend($r('sys.color.ohos_id_color_activated'))
|
||||
.onClick(() => {
|
||||
if (!this.lockArr[0]) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Text(this.prompt)
|
||||
.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 === THEME_WHITE
|
||||
? $r('sys.color.ohos_id_color_text_primary')
|
||||
: $r('sys.color.ohos_id_color_text_primary_contrary'))
|
||||
.margin({ bottom: '8vp' })
|
||||
.textAlign(TextAlign.Center)
|
||||
.textOverflow({ overflow: TextOverflow.None })
|
||||
.height('20vp')
|
||||
.onClick(() => {
|
||||
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.pinSubType === Constants.pinSix) {
|
||||
List({ space: DIGITALPSD_IC_DIAMETER }) {
|
||||
ForEach(this.passwordArr, (item) => {
|
||||
if ((!item || item === '') && item !== 0) {
|
||||
ListItem() {
|
||||
Button()
|
||||
.border({
|
||||
color: this.themeType === THEME_WHITE ? Color.Black : Color.White,
|
||||
style: BorderStyle.Solid,
|
||||
width: 1
|
||||
})
|
||||
.borderRadius('12vp')
|
||||
.width('12vp')
|
||||
.height('12vp')
|
||||
.type(ButtonType.Circle)
|
||||
.backgroundColor(Color.Transparent)
|
||||
|
||||
}
|
||||
.margin({ left: '5vp', right: '5vp' })
|
||||
} else {
|
||||
ListItem() {
|
||||
Button()
|
||||
.borderRadius('12vp')
|
||||
.width('12vp')
|
||||
.height('12vp')
|
||||
.type(ButtonType.Circle)
|
||||
.backgroundColor(this.themeType === THEME_WHITE ? Color.Black : Color.White)
|
||||
}
|
||||
.margin({ left: '5vp', right: '5vp' })
|
||||
}
|
||||
})
|
||||
}
|
||||
.listDirection(Axis.Horizontal)
|
||||
.height('12vp')
|
||||
|
||||
} 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, '');
|
||||
if (this.passwordArrNumber.length < 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
.visibility(Visibility.Visible)
|
||||
.copyOption(CopyOptions.None)
|
||||
.maxLength(32)
|
||||
|
||||
}
|
||||
} else if (this.pinSubType === Constants.pinMixed) {
|
||||
TextInput({ text: this.passwordObj })
|
||||
.height('40vp')
|
||||
.type(InputType.Password)
|
||||
.textAlign(TextAlign.Center)
|
||||
.copyOption(CopyOptions.None)
|
||||
.maxLength(32)
|
||||
.onSubmit(async (enterKey: EnterKeyType) => {
|
||||
// check callback
|
||||
if (this.passwordObj.length < 4) {
|
||||
return;
|
||||
}
|
||||
this.textValue = this.passwordObj;
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
})
|
||||
.onChange((value: string) => {
|
||||
this.passwordObj = value;
|
||||
})
|
||||
.id('pinInput')
|
||||
}
|
||||
}
|
||||
}
|
||||
.height('40vp')
|
||||
|
||||
Button(($r('app.string.unified_authwidget_forgotpwd')), {
|
||||
stateEffect: false
|
||||
})
|
||||
.id('forgotBtnCustomPwd')
|
||||
.height('40vp')
|
||||
.backgroundColor(Color.Transparent)
|
||||
.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'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.onClick(() => {
|
||||
let str = this.passwordArrNumber.toString()
|
||||
this.textValue = str.replace(/,/g, '');
|
||||
})
|
||||
.visibility(Visibility.Hidden)
|
||||
}
|
||||
|
||||
Column() {
|
||||
if (!this.isLandscape && this.lock === 0 && this.pinSubType === Constants.pinSix) {
|
||||
NumKeyBoard({
|
||||
themeType: $themeType,
|
||||
onKeyPress: (index, callback) => {
|
||||
let keyValue = this.numKeyboard[index].value;
|
||||
if (keyValue > 0 || keyValue === 0) {
|
||||
const index = this.passwordArr.map(item => item).indexOf('')
|
||||
if (index > -1) {
|
||||
this.passwordArr[index] = keyValue + '';
|
||||
this.numKeyboard[11].row1 = $r('app.string.unified_authwidget_delete');
|
||||
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, '');
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
}
|
||||
this.updateStorage(callback);
|
||||
}
|
||||
} else if (keyValue === DEL_PWD) {
|
||||
const index = this.passwordArr.map(item => item).indexOf('');
|
||||
if (index === -1) {
|
||||
this.passwordArr[5] = '';
|
||||
} else if (index === 1) {
|
||||
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.updateStorage(callback);
|
||||
} else if (keyValue === GO_BACK) {
|
||||
this.lock = 0;
|
||||
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, '');
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Text().height(Constants.fullContainerHeight)
|
||||
}
|
||||
}
|
||||
.width(Constants.fullContainerWidth)
|
||||
.height('40%')
|
||||
|
||||
Column() {
|
||||
if (this.controlType.isShowFinger && this.lock !== 1) {
|
||||
if (this.fingerPosition.sensorType !== 'OUT_OF_SCREEN_SENSOR'
|
||||
&& this.fingerPosition.sensorType !== 'NON_SENSOR') {
|
||||
if (this.themeType === THEME_WHITE) {
|
||||
if (this.fingerPosition.sensorType === 'UNDER_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;
|
||||
} else {
|
||||
this.controlType.jumpFinger = true;
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.themeType === THEME_BLUR) {
|
||||
if (this.fingerPosition.sensorType === 'UNDER_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;
|
||||
} else {
|
||||
this.controlType.jumpFinger = true;
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.width('24vp')
|
||||
.height(this.controlType.isShowFinger ? '72vp' : '9%')
|
||||
.justifyContent(FlexAlign.Start)
|
||||
}
|
||||
.justifyContent(FlexAlign.End)
|
||||
.width(Constants.fullContainerWidth)
|
||||
} else if (!this.controlType.isLandscape) {
|
||||
Column() {
|
||||
Text(globalThis.wantParams?.title)
|
||||
.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)
|
||||
.position({ y: TITLE_POSITION })
|
||||
.width('100%')
|
||||
.textAlign(TextAlign.Center)
|
||||
Text(this.fingerText)
|
||||
.height('40vp')
|
||||
.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'))
|
||||
.position({
|
||||
y: (px2vp(this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH * this.screen[1]) - 120 - px2vp(72 + this.fingerPosition.udSensorRadiusInPx))
|
||||
})
|
||||
.position({
|
||||
y: (px2vp(this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH * this.screen[1])
|
||||
- FINGER_TEXT_POSITION - px2vp(DEFAULT_SIZE + this.fingerPosition.udSensorRadiusInPx))
|
||||
})
|
||||
.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(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.position({
|
||||
x: (px2vp(this.fingerPosition.udSensorCenterXInThousandth / THOUSANDTH * this.screen[0])
|
||||
- px2vp(FINGER_X_POSITION + this.fingerPosition.udSensorRadiusInPx)),
|
||||
y: (px2vp(this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH * this.screen[1])
|
||||
- FINGER_Y_POSITION - px2vp(DEFAULT_SIZE + this.fingerPosition.udSensorRadiusInPx))
|
||||
})
|
||||
.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]);
|
||||
}
|
||||
})
|
||||
Button($r('app.string.unified_authwidget_cancel'), {
|
||||
type: ButtonType.Normal,
|
||||
stateEffect: true
|
||||
})
|
||||
.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;
|
||||
})
|
||||
}
|
||||
.justifyContent(FlexAlign.End)
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
} else {
|
||||
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)
|
||||
.height('300vp')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
import display from '@ohos.display';
|
||||
import screen from '@ohos.screen';
|
||||
import userAuth from '@ohos.userIAM.userAuth';
|
||||
import Constants, { CmdType, FingerPosition } from '../../common/vm/Constants';
|
||||
import AuthUtils from '../utils/AuthUtils';
|
||||
@@ -24,22 +23,21 @@ import NumKeyBoard from './NumkeyBoard';
|
||||
|
||||
const TAG = 'FullScreen';
|
||||
const INTERVAL = 1000;
|
||||
const DIGITAL_PASSWORD_IC_DIAMETER = 12;
|
||||
const THOUSANDTH = 1000;
|
||||
const TITLE_POSITION = 200;
|
||||
const DEL_PWD = -2;
|
||||
const CALL_PHONE = -1;
|
||||
const GO_BACK = -3;
|
||||
const DEFAULT_SIZE = 72;
|
||||
const FINGER_TEXT_POSITION = 120;
|
||||
const FINGER_HIGH = 72;
|
||||
const FINGER_X_POSITION = 86;
|
||||
const FINGER_Y_POSITION = 40;
|
||||
const FINGER_HIGH = 80;
|
||||
const FINGER_Y_POSITION = 60;
|
||||
const MAX_LENGTH = 32;
|
||||
const SIX_MAX_LENGTH = 6;
|
||||
const AUTH_TYPE_FACE = 2;
|
||||
const AUTH_TYPE_FINGER = 4;
|
||||
const PASSWORD_LENGTH = 4;
|
||||
const PASSWORD_ARRAY_LENGTH = 6;
|
||||
const UNDER_FINGER = 170;
|
||||
const NOTICE_DELAY = 500;
|
||||
|
||||
interface ControlType {
|
||||
isSixPassword?: boolean,
|
||||
@@ -64,7 +62,7 @@ export default struct FullScreen {
|
||||
@Link authType: Array<userAuth.UserAuthType>;
|
||||
@Link @Watch('onCmdDataChange') cmdData: Array<CmdType>;
|
||||
@State pinLock: number = 0;
|
||||
@State screenClass: object = {};
|
||||
@State fingerPositionY: number = 0;
|
||||
@StorageLink('cueWord') cueWord: string = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_use_pwd'));
|
||||
@StorageLink('passwordArray') passwordArray: string[] = [];
|
||||
@@ -76,6 +74,7 @@ export default struct FullScreen {
|
||||
@State fingerText: string = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp'));
|
||||
@StorageLink('screenLockDirection') screenLockDirection: number = 1;
|
||||
@StorageLink('SYSTEM_STATUS_BAR_HEIGHT') SYSTEM_STATUS_BAR_HEIGHT: number = 0;
|
||||
@State controlType: ControlType = {
|
||||
jumpFinger: false,
|
||||
isLandscape: false,
|
||||
@@ -88,23 +87,9 @@ export default struct FullScreen {
|
||||
}
|
||||
@State screen: number[] = [];
|
||||
@State faceFingerLockArr: boolean[] = [false, false];
|
||||
@Consume isLandscape: boolean;
|
||||
@StorageLink('IS_LANDSCAPE') IS_LANDSCAPE: boolean = false;
|
||||
@Consume underFingerPrint: boolean;
|
||||
|
||||
queryScreenInfo(): void {
|
||||
try {
|
||||
screen.getAllScreens((err, data) => {
|
||||
if (err.code) {
|
||||
LogUtils.error(TAG, 'Failed to get all screens. err: ' + err.code);
|
||||
return;
|
||||
}
|
||||
this.screenClass = data[0];
|
||||
});
|
||||
} catch (error) {
|
||||
LogUtils.error(TAG, 'getAllScreens catch error: ' + error?.code);
|
||||
}
|
||||
}
|
||||
|
||||
onCmdDataChange(num?: string): void {
|
||||
this.cmdData.length > 0 && this.cmdData.map((item) => {
|
||||
const { type,remainAttempts, lockoutDuration,sensorInfo} = item.payload;
|
||||
@@ -144,6 +129,9 @@ export default struct FullScreen {
|
||||
this.faceFingerLockArr[0] = false;
|
||||
}
|
||||
if (num === 'first') {
|
||||
if (remainAttempts === 0) {
|
||||
this.controlType.isShowFace = false;
|
||||
}
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_recognition'));
|
||||
}
|
||||
@@ -166,27 +154,40 @@ export default struct FullScreen {
|
||||
.getStringSync($r('app.string.unified_authwidget_use_pwd'));
|
||||
}
|
||||
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 (this.controlType.jumpFinger) {
|
||||
this.fingerText = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2'));
|
||||
} else {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_use_pwd'));
|
||||
}
|
||||
if (sensor) {
|
||||
if (sensor.sensorType === 'UNDER_SCREEN_SENSOR' ||
|
||||
sensor.sensorType === 'BOTH_SENSOR' ||
|
||||
sensor.sensorType === 'SensorType1') {
|
||||
// 5: Residual number
|
||||
sensor.sensorType === 'BOTH_SENSOR' ||
|
||||
sensor.sensorType === 'SensorType1') {
|
||||
if (num !== 'first' && remainAttempts > 0) {
|
||||
setTimeout(() => {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}, NOTICE_DELAY);
|
||||
}
|
||||
if (num === 'first' && sensor.udSensorCenterYInThousandth /
|
||||
this.screen[1] > Constants.fingerSensorPositionLine) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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'));
|
||||
if (num === 'first') {
|
||||
this.controlType.isShowFinger = false;
|
||||
} else {
|
||||
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'));
|
||||
}
|
||||
this.faceFingerLockArr[1] = true;
|
||||
this.controlType.jumpFinger = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -200,15 +201,11 @@ export default struct FullScreen {
|
||||
LogUtils.debug(TAG, 'aboutToAppear');
|
||||
try {
|
||||
AppStorage.SetOrCreate('passwordArray', []);
|
||||
this.queryScreenInfo();
|
||||
if (this.cmdData && this.cmdData.length > 0) {
|
||||
this.onCmdDataChange('first');
|
||||
}
|
||||
if (this.controlType.isShowFace && this.controlType.isShowFinger) {
|
||||
AuthUtils.getInstance()
|
||||
.sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace, Constants.noticeTypeFinger]);
|
||||
return;
|
||||
}
|
||||
this.fingerPositionY = px2vp(this.fingerPosition.udSensorCenterYInThousandth * this.screen[1]) / THOUSANDTH
|
||||
- this.SYSTEM_STATUS_BAR_HEIGHT - this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx)
|
||||
if (this.controlType.isShowFace) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]);
|
||||
return;
|
||||
@@ -268,7 +265,7 @@ export default struct FullScreen {
|
||||
.fontColor($r('sys.color.ohos_id_color_primary_contrary'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_headline6'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
} else if (this.controlType.isShowFace) {
|
||||
} else if (this.controlType.isShowFace && !this.faceFingerLockArr[0]) {
|
||||
Image($r('app.media.white_faceID'))
|
||||
.id('faceImgCustomPwd')
|
||||
.width($r('app.float.image_small'))
|
||||
@@ -316,46 +313,67 @@ export default struct FullScreen {
|
||||
// 0: pin unlock
|
||||
if (this.pinLock === 0) {
|
||||
if (this.pinSubType === Constants.pinSix) {
|
||||
List({ space: DIGITAL_PASSWORD_IC_DIAMETER }) {
|
||||
ForEach(this.passwordArray, (item) => {
|
||||
if ((!item || item === '') && item !== 0) {
|
||||
ListItem() {
|
||||
Button()
|
||||
.border({
|
||||
color: Color.White,
|
||||
style: BorderStyle.Solid,
|
||||
width: 1
|
||||
})
|
||||
.borderRadius($r('app.float.input_btn_size'))
|
||||
.width($r('app.float.input_btn_size'))
|
||||
.height($r('app.float.input_btn_size'))
|
||||
.type(ButtonType.Circle)
|
||||
.backgroundColor(Color.Transparent)
|
||||
Stack() {
|
||||
List() {
|
||||
ForEach(this.passwordArray, item => {
|
||||
if ((!item || item === '') && item !== 0) {
|
||||
ListItem() {
|
||||
Button()
|
||||
.border({
|
||||
color: Color.White,
|
||||
style: BorderStyle.Solid,
|
||||
width: 1
|
||||
})
|
||||
.borderRadius($r('app.float.input_btn_size'))
|
||||
.width($r('app.float.input_btn_size'))
|
||||
.height($r('app.float.input_btn_size'))
|
||||
.type(ButtonType.Circle)
|
||||
.backgroundColor(Color.Transparent)
|
||||
}
|
||||
.margin({
|
||||
left: $r('app.float.margin_12'),
|
||||
right: $r('app.float.margin_12'),
|
||||
top: $r('app.float.margin_14')
|
||||
})
|
||||
} else {
|
||||
ListItem() {
|
||||
Button()
|
||||
.borderRadius($r('app.float.input_btn_size'))
|
||||
.width($r('app.float.input_btn_size'))
|
||||
.height($r('app.float.input_btn_size'))
|
||||
.type(ButtonType.Circle)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_text_primary_contrary'))
|
||||
}
|
||||
.margin({
|
||||
left: $r('app.float.margin_12'),
|
||||
right: $r('app.float.margin_12'),
|
||||
top: $r('app.float.margin_14')
|
||||
})
|
||||
}
|
||||
.margin({
|
||||
left: $r('app.float.margin_12'),
|
||||
right: $r('app.float.margin_12'),
|
||||
top: $r('app.float.margin_14')
|
||||
})
|
||||
}
|
||||
.listDirection(Axis.Horizontal)
|
||||
.height($r('app.float.input_height'))
|
||||
|
||||
if (this.IS_LANDSCAPE) {
|
||||
TextInput({ placeholder: '', text: this.passwordArray?.join('') })
|
||||
.onChange(async (value: string) => {
|
||||
const arr = value?.replace(/[^\d]/g, '')?.split('');
|
||||
arr?.map((item, index) => {
|
||||
this.passwordArray[index] = item;
|
||||
});
|
||||
if (arr?.length === SIX_MAX_LENGTH) {
|
||||
this.textValue = arr?.join('');
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ListItem() {
|
||||
Button()
|
||||
.borderRadius($r('app.float.input_btn_size'))
|
||||
.width($r('app.float.input_btn_size'))
|
||||
.height($r('app.float.input_btn_size'))
|
||||
.type(ButtonType.Circle)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_text_primary_contrary'))
|
||||
}
|
||||
.margin({
|
||||
left: $r('app.float.margin_12'),
|
||||
right: $r('app.float.margin_12'),
|
||||
top: $r('app.float.margin_14')
|
||||
})
|
||||
}
|
||||
})
|
||||
.backgroundImageSize(ImageSize.Auto)
|
||||
.maxLength(SIX_MAX_LENGTH)
|
||||
.visibility(Visibility.Visible)
|
||||
.opacity(0)
|
||||
.caretColor('transparent')
|
||||
}
|
||||
}
|
||||
.listDirection(Axis.Horizontal)
|
||||
.height($r('app.float.input_height'))
|
||||
|
||||
} else if (this.pinSubType === Constants.pinNumber) {
|
||||
Stack() {
|
||||
@@ -382,12 +400,13 @@ export default struct FullScreen {
|
||||
.visibility(Visibility.Visible)
|
||||
.copyOption(CopyOptions.None)
|
||||
.maxLength(MAX_LENGTH)
|
||||
.textAlign(TextAlign.Start)
|
||||
}
|
||||
} else if (this.pinSubType === Constants.pinMixed) {
|
||||
TextInput({ text: this.passwordObj })
|
||||
.height($r('app.float.btn_height'))
|
||||
.type(InputType.Password)
|
||||
.textAlign(TextAlign.Center)
|
||||
.textAlign(TextAlign.Start)
|
||||
.copyOption(CopyOptions.None)
|
||||
.maxLength(MAX_LENGTH)
|
||||
.onSubmit(async (enterKey: EnterKeyType) => {
|
||||
@@ -425,7 +444,7 @@ export default struct FullScreen {
|
||||
|
||||
// 0: pin unlock
|
||||
Column() {
|
||||
if (!this.isLandscape && this.pinLock === 0 && this.pinSubType === Constants.pinSix) {
|
||||
if (!this.IS_LANDSCAPE && this.pinLock === 0 && this.pinSubType === Constants.pinSix) {
|
||||
NumKeyBoard({
|
||||
onKeyPress: (index, callback) => {
|
||||
let keyValue = this.numKeyboard[index].value;
|
||||
@@ -464,6 +483,7 @@ export default struct FullScreen {
|
||||
this.pinLock = 0;
|
||||
this.clearPassword();
|
||||
globalThis.session?.terminateSelf?.();
|
||||
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, globalThis?.wantParams?.type || []);
|
||||
} else if (keyValue === CALL_PHONE) {
|
||||
if (this.passwordArray.join('').length < PASSWORD_ARRAY_LENGTH) {
|
||||
return;
|
||||
@@ -484,26 +504,22 @@ export default struct FullScreen {
|
||||
|
||||
// 1: pin lock
|
||||
Column() {
|
||||
if (this.controlType.isShowFinger && this.pinLock !== 1) {
|
||||
if (this.fingerPosition.sensorType !== 'OUT_OF_SCREEN_SENSOR'
|
||||
&& this.fingerPosition.sensorType !== 'NON_SENSOR') {
|
||||
if (this.controlType.isShowFinger && this.pinLock !== 1 && !this.faceFingerLockArr[1]) {
|
||||
if (this.fingerPosition.sensorType !== 'OUT_OF_SCREEN_SENSOR' &&
|
||||
this.fingerPosition.sensorType !== 'NON_SENSOR') {
|
||||
if (this.fingerPosition.sensorType === 'UNDER_SCREEN_SENSOR' ||
|
||||
this.fingerPosition.sensorType === 'BOTH_SENSOR' ||
|
||||
this.fingerPosition.sensorType === 'SensorType1') {
|
||||
this.fingerPosition.sensorType === 'BOTH_SENSOR' ||
|
||||
this.fingerPosition.sensorType === 'SensorType1') {
|
||||
if (this.fingerPosition.udSensorCenterYInThousandth /
|
||||
this.screen[1] > Constants.fingerSensorPositionLine &&
|
||||
!this.isLandscape) {
|
||||
this.screen[1] > Constants.fingerSensorPositionLine &&
|
||||
!this.IS_LANDSCAPE) {
|
||||
Image($r('app.media.ic_unlock_fingerprint'))
|
||||
.id('fingerprintImgCustomPassword')
|
||||
.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]);
|
||||
})
|
||||
.position({ y: px2vp(UNDER_FINGER)
|
||||
- px2vp(this.screen[1])
|
||||
+ px2vp(this.fingerPosition.udSensorCenterYInThousandth * this.screen[1] / THOUSANDTH) })
|
||||
} else {
|
||||
Image($r('app.media.finger_white'))
|
||||
.id('fingerWhiteImgCustomPassword')
|
||||
@@ -511,7 +527,7 @@ export default struct FullScreen {
|
||||
.height($r('app.float.image_back_size'))
|
||||
.margin({ top: $r('app.float.input_btn_size') })
|
||||
.onClick(() => {
|
||||
if (this.isLandscape) {
|
||||
if (this.IS_LANDSCAPE) {
|
||||
this.underFingerPrint = true;
|
||||
} else {
|
||||
this.controlType.jumpFinger = true;
|
||||
@@ -530,48 +546,49 @@ export default struct FullScreen {
|
||||
.width(Constants.fullContainerWidth)
|
||||
} else if (!this.controlType.isLandscape) {
|
||||
Column() {
|
||||
Text(globalThis.wantParams?.title)
|
||||
Text(this.fingerText)
|
||||
.id('titleFullScreen')
|
||||
.height($r('app.float.text_high'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_sub_title2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary_contrary'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.position({ y: TITLE_POSITION })
|
||||
.width('100%')
|
||||
.textAlign(TextAlign.Center)
|
||||
Text(this.fingerText)
|
||||
.height($r('app.float.text_high'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.position({
|
||||
y: (px2vp(this.fingerPosition.udSensorCenterYInThousandth * this.screen[1] / THOUSANDTH) -
|
||||
FINGER_TEXT_POSITION - px2vp(FINGER_HIGH + this.fingerPosition.udSensorRadiusInPx))
|
||||
px2vp(FINGER_Y_POSITION) - FINGER_TEXT_POSITION - this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx))
|
||||
})
|
||||
.width('100%')
|
||||
.textAlign(TextAlign.Center)
|
||||
Text($r('app.string.unified_authwidget_hint_inscreen_fp'))
|
||||
.height($r('app.float.text_high'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary_contrary'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.position({
|
||||
y: (px2vp(this.fingerPosition.udSensorCenterYInThousandth * this.screen[1] / THOUSANDTH) -
|
||||
px2vp(FINGER_Y_POSITION) - FINGER_HIGH - this.SYSTEM_STATUS_BAR_HEIGHT - px2vp(this.fingerPosition.udSensorRadiusInPx))
|
||||
})
|
||||
.width('100%')
|
||||
.textAlign(TextAlign.Center)
|
||||
.margin({ top: $r('app.float.padding_8') })
|
||||
Image($r('app.media.ic_unlock_fingerprint'))
|
||||
.id('unlockFingerprintImgCustomPwd')
|
||||
// radius
|
||||
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.position({
|
||||
x: (px2vp(this.fingerPosition.udSensorCenterXInThousandth * this.screen[0] / THOUSANDTH)
|
||||
- px2vp(FINGER_X_POSITION + this.fingerPosition.udSensorRadiusInPx)),
|
||||
y: (px2vp(this.fingerPosition.udSensorCenterYInThousandth * this.screen[1] / THOUSANDTH)
|
||||
- FINGER_Y_POSITION - px2vp(DEFAULT_SIZE + this.fingerPosition.udSensorRadiusInPx))
|
||||
})
|
||||
.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]);
|
||||
}
|
||||
})
|
||||
Column() {
|
||||
Image($r('app.media.ic_unlock_fingerprint'))
|
||||
.id('unlockFingerprintImgCustomPwd')
|
||||
// radius
|
||||
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
}.width('100%')
|
||||
.position({ y: this.fingerPositionY })
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
|
||||
Button($r('app.string.unified_authwidget_cancel'), {
|
||||
type: ButtonType.Normal,
|
||||
stateEffect: true
|
||||
})
|
||||
.margin({ bottom: $r('app.float.three_hundred_size'), left: 'auto', right: 'auto' })
|
||||
.width('100%')
|
||||
.position({
|
||||
y: (px2vp(this.fingerPosition.udSensorCenterYInThousandth * this.screen[1] / THOUSANDTH))
|
||||
})
|
||||
.backgroundColor(Color.Transparent)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary_contrary'))
|
||||
.onClick(() => {
|
||||
@@ -579,6 +596,7 @@ export default struct FullScreen {
|
||||
})
|
||||
}
|
||||
.justifyContent(FlexAlign.End)
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export default struct PassWord {
|
||||
left: $r('app.float.digital_password_mask_height'),
|
||||
right: $r('app.float.digital_password_mask_height')
|
||||
})
|
||||
.textAlign(TextAlign.Center)
|
||||
.textAlign(TextAlign.Start)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.border({
|
||||
width: this.inputValue === ' ' ? '' : $r('app.float.input_border'),
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/**
|
||||
* 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 Constants from '../../common/vm/Constants';
|
||||
|
||||
@Component
|
||||
export default struct Pwd {
|
||||
@Link pinSubType: string;
|
||||
@Link @Watch('onTextValueChange') textValue: string;
|
||||
@Link inputValue: string;
|
||||
@Link isEdit: boolean;
|
||||
@StorageLink('passwordArrNumber') passwordArrNumber: string[] = [];
|
||||
controller: CustomDialogController;
|
||||
cancel: () => void;
|
||||
confirm: () => void;
|
||||
|
||||
onTextValueChange(): void {
|
||||
this.passwordArrNumber = this.textValue.replace(/[^\d]/g, '').split('');
|
||||
}
|
||||
|
||||
clearPassword(): void {
|
||||
this.passwordArrNumber = [];
|
||||
this.textValue = '';
|
||||
this.inputValue = ' ';
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.clearPassword();
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
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)
|
||||
.id('titlePwdAuth')
|
||||
TextInput({
|
||||
placeholder: '',
|
||||
text: this.pinSubType === Constants.pinNumber ? this.passwordArrNumber.join('') : this.textValue
|
||||
})
|
||||
.maxLength(32)
|
||||
.enabled(this.isEdit)
|
||||
.height($r('app.float.input_height'))
|
||||
.type(InputType.Password)
|
||||
.margin({
|
||||
top: $r('app.float.content_padding'),
|
||||
left: $r('app.float.digitalpsd_passwdmask_height'),
|
||||
right: $r('app.float.digitalpsd_passwdmask_height')
|
||||
})
|
||||
.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'))
|
||||
})
|
||||
.onChange((value: string) => {
|
||||
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') })
|
||||
.fontColor($r('sys.color.ohos_id_color_warning'))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,24 @@ const MAX_LENGTH = 6;
|
||||
|
||||
@Component
|
||||
export default struct SixPassword {
|
||||
@Link textValue: string;
|
||||
@Link inputValue: string;
|
||||
@Link isEdit: boolean;
|
||||
@Link @Watch('onTextValueChange') textValue: string;
|
||||
@StorageLink('passwordArrayNumber') passwordArrayNumber: string[] = [];
|
||||
|
||||
onTextValueChange(): void {
|
||||
this.passwordArrayNumber = this.textValue.replace(/[^\d]/g, '').split('');
|
||||
}
|
||||
|
||||
clearPassword(): void {
|
||||
this.passwordArrayNumber = [];
|
||||
this.textValue = '';
|
||||
this.inputValue = ' ';
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.clearPassword();
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
@@ -34,20 +49,6 @@ export default struct SixPassword {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
Column() {
|
||||
Stack() {
|
||||
TextInput({ placeholder: '', text: this.textValue })
|
||||
.onChange(async (value: string) => {
|
||||
this.textValue = value
|
||||
if (value.length === MAX_LENGTH) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
}
|
||||
})
|
||||
.backgroundImageSize(ImageSize.Auto)
|
||||
.enabled(this.isEdit)
|
||||
.maxLength(MAX_LENGTH)
|
||||
.visibility(Visibility.Visible)
|
||||
.opacity(0)
|
||||
.caretColor('transparent')
|
||||
.id('pinSix')
|
||||
List({ space: 4 }) {
|
||||
ForEach(['', '', '', '', '', ''], (item, index) => {
|
||||
ListItem() {
|
||||
@@ -75,6 +76,21 @@ export default struct SixPassword {
|
||||
.listDirection(Axis.Horizontal)
|
||||
.height($r('app.float.input_height'))
|
||||
|
||||
TextInput({ placeholder: '', text: this.passwordArrayNumber?.join('') })
|
||||
.onChange(async (value: string) => {
|
||||
this.passwordArrayNumber = value?.replace(/[^\d]/g, '')?.split('');
|
||||
this.textValue = this.passwordArrayNumber?.join('');
|
||||
if (this.textValue?.length === MAX_LENGTH) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
}
|
||||
})
|
||||
.backgroundImageSize(ImageSize.Auto)
|
||||
.enabled(this.isEdit)
|
||||
.maxLength(MAX_LENGTH)
|
||||
.visibility(Visibility.Visible)
|
||||
.opacity(0)
|
||||
.caretColor('transparent')
|
||||
.id('pinSix')
|
||||
}
|
||||
}
|
||||
.margin({ top: $r('app.float.content_padding') })
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
/**
|
||||
* 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 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;
|
||||
|
||||
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, 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 = ' ';
|
||||
this.isEdit = true;
|
||||
}
|
||||
this.inputValue = promptText;
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
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)
|
||||
Column() {
|
||||
Stack() {
|
||||
TextInput({ placeholder: '', text: this.textValue })
|
||||
.onChange(async (value: string) => {
|
||||
this.textValue = value
|
||||
if (value.length === 6) {
|
||||
// check callback
|
||||
let userAuthWidgetMgr;
|
||||
try {
|
||||
let that = this;
|
||||
LogUtils.i(TAG, 'getUserAuthWidgetMgr start');
|
||||
userAuthWidgetMgr = await userAuth.getUserAuthWidgetMgr(Constants.userAuthWidgetMgrVersion);
|
||||
userAuthWidgetMgr.on('command', {
|
||||
callback: function (result) {
|
||||
LogUtils.i(TAG, 'userAuthWidgetMgr onCommand result: ' + JSON.stringify(result));
|
||||
const cmdData = JSON.parse(result?.cmdData)
|
||||
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 = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error'));
|
||||
that.textValue = '';
|
||||
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;
|
||||
}
|
||||
// countdown
|
||||
const time = cmdData?.cmd?.[0]?.payload?.lockoutDuration;
|
||||
if (frequency === 0 && time) {
|
||||
that.countTime(time);
|
||||
that.isEdit = false;
|
||||
that.textValue = '';
|
||||
return;
|
||||
}
|
||||
that.inputValue = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error'));
|
||||
that.textValue = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
LogUtils.i(TAG, 'getUserAuthWidgetMgr success');
|
||||
} catch (error) {
|
||||
LogUtils.e(TAG, 'getUserAuthWidgetMgr catch error: ' + JSON.stringify(error));
|
||||
}
|
||||
// check
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
}
|
||||
})
|
||||
.backgroundImageSize(ImageSize.Auto)
|
||||
.enabled(this.isEdit)
|
||||
.maxLength(6)
|
||||
.visibility(Visibility.Visible)
|
||||
.opacity(0)
|
||||
.caretColor('transparent')
|
||||
.id('pinSix')
|
||||
List({ space: 4 }) {
|
||||
ForEach(['', '', '', '', '', ''], (item, index) => {
|
||||
ListItem() {
|
||||
Button()
|
||||
.border({
|
||||
color: Color.Black,
|
||||
style: BorderStyle.Solid,
|
||||
width: this.textValue.length !== 0 && index < this.textValue.length ? '6vp' : 1
|
||||
})
|
||||
.type(ButtonType.Circle)
|
||||
.backgroundColor(Color.White)
|
||||
.width($r('app.float.input_btn_size'))
|
||||
.height($r('app.float.input_btn_size'))
|
||||
.borderRadius($r('app.float.input_btn_size'))
|
||||
.margin(index > 0 ? { left: $r('app.float.input_btn_padding_around') } : {})
|
||||
.focusable(true)
|
||||
}
|
||||
}, item => item)
|
||||
}
|
||||
.listDirection(Axis.Horizontal)
|
||||
.height($r('app.float.input_btn_size'))
|
||||
}
|
||||
}
|
||||
.margin({ top: $r('app.float.content_padding') })
|
||||
.padding({ top: $r('app.float.input_btn_padding_up_down'), bottom: $r('app.float.input_btn_padding_up_down') })
|
||||
|
||||
Text(this.inputValue)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.margin({ top: $r('app.float.element_margin') })
|
||||
.fontColor($r('sys.color.ohos_id_color_warning'))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
export default class Constants {
|
||||
static deviceDpi = ['360vp', '780vp'];
|
||||
static deviceDpi = ['520vp', '840vp'];
|
||||
|
||||
// Pin type
|
||||
static pinSix = 'PIN_SIX';
|
||||
@@ -32,12 +32,15 @@ export default class Constants {
|
||||
// command result success
|
||||
static userAuthWidgetMgrSuccess = 0;
|
||||
|
||||
// sendNotice param: version
|
||||
// sendNotice params
|
||||
// version
|
||||
static noticeVersion = '1';
|
||||
// type
|
||||
static noticeTypePin = 'pin';
|
||||
static noticeTypeFace = 'face';
|
||||
static noticeTypeFinger = 'fingerprint';
|
||||
// event cancel
|
||||
static noticeEventCancel = 'EVENT_AUTH_USER_CANCEL';
|
||||
|
||||
static fingerSensorPositionLine = 0.75;
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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 '../common/utils/LogUtils';
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import window from '@ohos.window';
|
||||
|
||||
const TAG = 'MainAbility';
|
||||
|
||||
export default class MainAbility extends UIAbility {
|
||||
onCreate(): void {
|
||||
LogUtils.i(TAG, 'Ability onCreate');
|
||||
}
|
||||
|
||||
onDestroy(): void | Promise<void> {
|
||||
LogUtils.i(TAG, 'Ability onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||
LogUtils.i(TAG, 'Ability onWindowStageCreate');
|
||||
|
||||
windowStage.loadContent('pages/Index', (err, data) => {
|
||||
if (err.code) {
|
||||
LogUtils.e(TAG, 'Failed to load the content. Cause: %{public}s' + JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
LogUtils.i(TAG, 'Succeeded in loading the content. Data: %{public}s' + JSON.stringify(data) ?? '');
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy(): void {
|
||||
LogUtils.i(TAG, 'Ability onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground(): void {
|
||||
LogUtils.i(TAG, 'Ability onForeground');
|
||||
}
|
||||
|
||||
onBackground(): void {
|
||||
LogUtils.i(TAG, 'Ability onBackground');
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import PasswordAuth from './components/PasswordAuth';
|
||||
|
||||
const DEFAULT_SIZE = 72;
|
||||
const FIVE_SECOND = 5000;
|
||||
const LAND_SCAPE = 2;
|
||||
const LANDSCAPE = 2;
|
||||
const TAG = 'Index';
|
||||
let userAuthWidgetMgr;
|
||||
|
||||
@@ -41,7 +41,7 @@ struct Index {
|
||||
@State dialogType: DialogType = DialogType.ALL;
|
||||
@State windowModeType: string = 'DIALOG_BOX';
|
||||
@State cmdData: Array<CmdType> = [];
|
||||
@Provide isLandscape: boolean = false;
|
||||
@State isLandscape: boolean = false;
|
||||
@Provide underFingerPrint: boolean = false;
|
||||
@State loadFlag: boolean = false;
|
||||
|
||||
@@ -54,7 +54,9 @@ struct Index {
|
||||
return;
|
||||
}
|
||||
LogUtils.debug(TAG, ' get all screens. result:-- ' + JSON.stringify(data));
|
||||
this.isLandscape = data[0].orientation === LAND_SCAPE;
|
||||
this.isLandscape = data[0]?.orientation === LANDSCAPE
|
||||
|| data[0]?.supportedModeInfo[0]?.width > data[0]?.supportedModeInfo[0]?.height;
|
||||
AppStorage.SetOrCreate('IS_LANDSCAPE', this.isLandscape);
|
||||
LogUtils.debug(TAG, 'globalThis.wantParams: ' + JSON.stringify(globalThis.wantParams));
|
||||
if (globalThis.wantParams) {
|
||||
this.getParams(globalThis.wantParams);
|
||||
@@ -126,6 +128,7 @@ struct Index {
|
||||
|
||||
aboutToAppear(): void {
|
||||
LogUtils.debug(TAG, 'aboutToAppear');
|
||||
FuncUtils.getWindowHeight();
|
||||
this.onScreenChange();
|
||||
}
|
||||
|
||||
@@ -142,7 +145,6 @@ struct Index {
|
||||
|
||||
getParams(result): void {
|
||||
LogUtils.info(TAG, 'getParams');
|
||||
LogUtils.info(TAG, 'dengjiewen msg test');
|
||||
const { pinSubType, windowModeType, cmd, type, widgetContextId } = result;
|
||||
this.pinSubType = pinSubType;
|
||||
const newType = type && type.map(item => {
|
||||
@@ -220,8 +222,6 @@ struct Index {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.onAreaChange(() => {
|
||||
FuncUtils.getWindowHeight();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import FullScreen from '../../common/components/FullScreen';
|
||||
import FuncUtils from '../../common/utils/FuncUtils';
|
||||
import LogUtils from '../../common/utils/LogUtils';
|
||||
import Constants from '../../common/vm/Constants';
|
||||
import AuthUtils from '../../common/utils/AuthUtils';
|
||||
|
||||
const TAG = 'CustomPassword';
|
||||
const BLUR_OPACITY = 0.5;
|
||||
@@ -36,7 +37,7 @@ export default struct CustomPassword {
|
||||
@Link cmdData: [];
|
||||
@State isBackTouched: boolean = false
|
||||
@State @Watch('onTextValueChange') textValue: string = '';
|
||||
@Consume isLandscape: boolean;
|
||||
@StorageLink('IS_LANDSCAPE') IS_LANDSCAPE: boolean = false;
|
||||
@StorageLink('SYSTEM_STATUS_BAR_HEIGHT') SYSTEM_STATUS_BAR_HEIGHT: number = 0;
|
||||
@StorageLink('SYSTEM_NAVIGATION_BAR_HEIGHT') SYSTEM_NAVIGATION_BAR_HEIGHT: number = 0;
|
||||
|
||||
@@ -90,6 +91,7 @@ export default struct CustomPassword {
|
||||
? $r('sys.color.ohos_id_color_hover') : Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, globalThis?.wantParams?.type || []);
|
||||
})
|
||||
.onTouch((event: TouchEvent) => {
|
||||
if (event.type === TouchType.Down) {
|
||||
@@ -102,16 +104,15 @@ export default struct CustomPassword {
|
||||
}
|
||||
|
||||
GridRow({
|
||||
columns: 8,
|
||||
gutter: { x: 5, y: 10 },
|
||||
columns: { xs: 4, sm: 4, md: 8, lg: 12 },
|
||||
gutter: { x: 24, y: 24 },
|
||||
breakpoints: { value: Constants.deviceDpi,
|
||||
reference: BreakpointsReference.WindowSize },
|
||||
direction: GridRowDirection.Row
|
||||
}) {
|
||||
GridCol({ span: { xs: 0, sm: 1, md: 1, lg: 1 } })
|
||||
.visibility(Visibility.Hidden)
|
||||
GridCol({
|
||||
span: { xs: 8, sm: 6, md: 6, lg: 6 },
|
||||
span: { xs: 4, sm: 4, md: 4, lg: 6 },
|
||||
offset: { md: 2, lg: 3 },
|
||||
}) {
|
||||
FullScreen({
|
||||
textValue: $textValue,
|
||||
@@ -122,7 +123,7 @@ export default struct CustomPassword {
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(this.isLandscape
|
||||
.padding(this.IS_LANDSCAPE
|
||||
? PADDING_ZERO
|
||||
: { top: this.SYSTEM_STATUS_BAR_HEIGHT, bottom: this.SYSTEM_NAVIGATION_BAR_HEIGHT })
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import screen from '@ohos.screen';
|
||||
import account_osAccount from '@ohos.account.osAccount';
|
||||
import display from '@ohos.display';
|
||||
import util from '@ohos.util';
|
||||
@@ -38,6 +37,7 @@ const SIX_PIN = 5;
|
||||
const SINGLE_FACE = 6;
|
||||
const SCREEN_LAND = 1;
|
||||
const SCREEN_PORTRAIT = 2;
|
||||
const NOTICE_DELAY = 500;
|
||||
let pinData = '';
|
||||
|
||||
@Component
|
||||
@@ -46,6 +46,7 @@ export default struct FaceAuth {
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_recognition'));
|
||||
@State @Watch('onTextValueChange') textValue: string = '';
|
||||
@Link @Watch('onCmdDataChange') cmdData: Array<CmdType>;
|
||||
@StorageLink('IS_LANDSCAPE') IS_LANDSCAPE: boolean = false;
|
||||
@State isEdit: boolean = true;
|
||||
// 0:six number 1:arbitrary character 2:arbitrary number
|
||||
@Link type: string;
|
||||
@@ -62,7 +63,7 @@ export default struct FaceAuth {
|
||||
}
|
||||
@State screen: number[] = [];
|
||||
@State faceLock: boolean = false;
|
||||
@Consume isLandscape: boolean;
|
||||
@State fingerLock: boolean = false;
|
||||
@StorageLink('SYSTEM_NAVIGATION_BAR_HEIGHT') SYSTEM_NAVIGATION_BAR_HEIGHT: number = 0;
|
||||
|
||||
countTime(freezingTime): void {
|
||||
@@ -125,15 +126,20 @@ export default struct FaceAuth {
|
||||
}
|
||||
}
|
||||
|
||||
send(): void {
|
||||
if (this.prompt === globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1'))) {
|
||||
sendFaceEvent(): void {
|
||||
if (!this.faceLock) {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_recognition'));
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]);
|
||||
}
|
||||
}
|
||||
|
||||
sendFingerEvent(): void {
|
||||
if (!this.fingerLock) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}
|
||||
}
|
||||
|
||||
onTextValueChange(): void {
|
||||
pinData = this.textValue;
|
||||
}
|
||||
@@ -219,20 +225,13 @@ export default struct FaceAuth {
|
||||
default:
|
||||
if ((JSON.parse(sensorInfo)
|
||||
.udSensorCenterYInThousandth / displayClass.height < Constants.fingerSensorPositionLine)) {
|
||||
try {
|
||||
await screen.getAllScreens((err, data) => {
|
||||
if (err.code) {
|
||||
LogUtils.error(TAG, 'Failed to get all screens. err: ' + err.code);
|
||||
return;
|
||||
}
|
||||
if (data[0].orientation !== SCREEN_PORTRAIT && ![SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
|
||||
this.screenType = SCREEN_LAND;
|
||||
} else {
|
||||
this.screenType = SCREEN_PORTRAIT;
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
LogUtils.error(TAG, 'getAllScreens catch error: ' + error?.code);
|
||||
if (!this.IS_LANDSCAPE && ![SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
|
||||
this.screenType = SCREEN_LAND;
|
||||
}
|
||||
} else if ((JSON.parse(sensorInfo)
|
||||
.udSensorCenterYInThousandth / displayClass.height > Constants.fingerSensorPositionLine)) {
|
||||
if (!this.IS_LANDSCAPE && ![SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) {
|
||||
this.screenType = SCREEN_PORTRAIT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -241,8 +240,11 @@ export default struct FaceAuth {
|
||||
if (remainAttempts) {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2'));
|
||||
this.fingerLock = false;
|
||||
if (num !== 'first' && remainAttempts > 0) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
setTimeout(() => {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}, NOTICE_DELAY);
|
||||
}
|
||||
}
|
||||
if (num === 'first') {
|
||||
@@ -252,6 +254,7 @@ export default struct FaceAuth {
|
||||
if (remainAttempts === 0) {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'));
|
||||
this.fingerLock = true;
|
||||
this.toPin();
|
||||
}
|
||||
break;
|
||||
@@ -262,19 +265,23 @@ export default struct FaceAuth {
|
||||
})
|
||||
}
|
||||
|
||||
handleCancel(): void {
|
||||
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, globalThis?.wantParams?.type || []);
|
||||
globalThis.session?.terminateSelf?.();
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({
|
||||
columns: 8,
|
||||
gutter: { x: 5, y: 10 },
|
||||
columns: { xs: 4, sm: 4, md: 8, lg: 12 },
|
||||
gutter: { x: 24, y: 24 },
|
||||
breakpoints: { value: Constants.deviceDpi,
|
||||
reference: BreakpointsReference.WindowSize },
|
||||
direction: GridRowDirection.Row
|
||||
}) {
|
||||
GridCol({ span: { xs: 0, sm: 0, md: 2, lg: 2 } })
|
||||
.visibility(Visibility.Hidden)
|
||||
GridCol({
|
||||
span: { xs: 8, sm: 8, md: 4, lg: 4 },
|
||||
span: { xs: 4, sm: 4, md: 4, lg: 6 },
|
||||
offset: { md: 2, lg: 3 },
|
||||
}) {
|
||||
Column() {
|
||||
if (this.dialogTypeFlag === PIN_FACE) {
|
||||
@@ -296,13 +303,13 @@ export default struct FaceAuth {
|
||||
.height($r('app.float.image_size'))
|
||||
.colorBlend($r('sys.color.ohos_id_color_activated'))
|
||||
.onClick(() => {
|
||||
this.send();
|
||||
this.sendFaceEvent();
|
||||
})
|
||||
Text(this.prompt).fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor(this.onFontColor(this.prompt, globalThis.context))
|
||||
.height($r('app.float.size_24'))
|
||||
.onClick(() => {
|
||||
this.send();
|
||||
this.sendFaceEvent();
|
||||
})
|
||||
Row() {
|
||||
Column() {
|
||||
@@ -316,7 +323,7 @@ export default struct FaceAuth {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
|
||||
@@ -346,81 +353,67 @@ export default struct FaceAuth {
|
||||
.margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') })
|
||||
}
|
||||
if (this.dialogTypeFlag === PIN_FACE_FINGER && this.screenType === SCREEN_PORTRAIT) {
|
||||
if (!this.isLandscape) {
|
||||
// The first form of facial fingerprint password
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Image($r('app.media.ic_public_cancel'))
|
||||
.id('cancelImgAllFaceAuth')
|
||||
.width($r('app.float.digital_password_mask_height'))
|
||||
.height($r('app.float.digital_password_mask_height'))
|
||||
.margin({
|
||||
top: $r('app.float.digital_password_mask_height'),
|
||||
left: $r('app.float.digital_password_mask_height')
|
||||
})
|
||||
.onClick(() => {
|
||||
this.textValue = '';
|
||||
globalThis.session?.terminateSelf?.();
|
||||
})
|
||||
Button($r('app.string.unified_authwidget_usepwd'))
|
||||
.id('usePwdBtnAllFaceAuth')
|
||||
.backgroundColor(Color.White)
|
||||
.height($r('app.float.digital_password_mask_height'))
|
||||
.padding(0)
|
||||
.margin({
|
||||
top: $r('app.float.digital_password_mask_height'),
|
||||
right: $r('app.float.digital_password_mask_height')
|
||||
})
|
||||
.fontColor($r('sys.color.ohos_id_color_activated'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.onClick(() => {
|
||||
this.inputValue = ' ';
|
||||
this.toPin();
|
||||
})
|
||||
}
|
||||
|
||||
Image($r('app.media.error_faceID'))
|
||||
.id('imgAllFaceAuth')
|
||||
.width($r('app.float.image_small'))
|
||||
.height($r('app.float.image_small'))
|
||||
.margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') })
|
||||
.colorBlend($r('sys.color.ohos_id_color_activated'))
|
||||
.onClick(() => {
|
||||
if (!this.faceLock) {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_recognition'));
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]);
|
||||
}
|
||||
})
|
||||
Text(globalThis.wantParams.title).fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
Text(this.prompt)
|
||||
.id('resetPromptTextAllFaceAuth')
|
||||
.margin({ top: $r('app.float.element_margin') })
|
||||
.height($r('app.float.size_24'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor(this.onFontColor(this.prompt, globalThis.context))
|
||||
.onClick(() => {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_recognition'));
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFace]);
|
||||
})
|
||||
Image($r('app.media.ic_blue_fingerprint'))
|
||||
.id('blueFingerprintImgAllFaceAuth')
|
||||
// radius
|
||||
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
// The first form of facial fingerprint password
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Image($r('app.media.ic_public_cancel'))
|
||||
.id('cancelImgAllFaceAuth')
|
||||
.width($r('app.float.digital_password_mask_height'))
|
||||
.height($r('app.float.digital_password_mask_height'))
|
||||
.margin({
|
||||
top: $r('app.float.digital_password_mask_height'),
|
||||
bottom: $r('app.float.digital_password_mask_height')
|
||||
left: $r('app.float.digital_password_mask_height')
|
||||
})
|
||||
.onClick(() => {
|
||||
if (this.prompt !== globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'))) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}
|
||||
this.textValue = '';
|
||||
this.handleCancel();
|
||||
})
|
||||
Button($r('app.string.unified_authwidget_usepwd'))
|
||||
.id('usePwdBtnAllFaceAuth')
|
||||
.backgroundColor(Color.White)
|
||||
.height($r('app.float.digital_password_mask_height'))
|
||||
.padding(0)
|
||||
.margin({
|
||||
top: $r('app.float.digital_password_mask_height'),
|
||||
right: $r('app.float.digital_password_mask_height')
|
||||
})
|
||||
.fontColor($r('sys.color.ohos_id_color_activated'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.onClick(() => {
|
||||
this.inputValue = ' ';
|
||||
this.toPin();
|
||||
})
|
||||
}
|
||||
|
||||
Image($r('app.media.error_faceID'))
|
||||
.id('imgAllFaceAuth')
|
||||
.width($r('app.float.image_small'))
|
||||
.height($r('app.float.image_small'))
|
||||
.margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') })
|
||||
.colorBlend($r('sys.color.ohos_id_color_activated'))
|
||||
.onClick(() => {
|
||||
this.sendFaceEvent();
|
||||
})
|
||||
Text(globalThis.wantParams.title).fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
Text(this.prompt)
|
||||
.id('resetPromptTextAllFaceAuth')
|
||||
.margin({ top: $r('app.float.element_margin') })
|
||||
.height($r('app.float.size_24'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor(this.onFontColor(this.prompt, globalThis.context))
|
||||
Image($r('app.media.ic_blue_fingerprint'))
|
||||
.id('blueFingerprintImgAllFaceAuth')
|
||||
// radius
|
||||
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.margin({
|
||||
top: $r('app.float.digital_password_mask_height'),
|
||||
bottom: $r('app.float.digital_password_mask_height')
|
||||
})
|
||||
.onClick(() => {
|
||||
this.sendFingerEvent();
|
||||
})
|
||||
}
|
||||
if (this.dialogTypeFlag === PIN_FACE_FINGER && this.screenType === SCREEN_LAND) {
|
||||
// Facial fingerprint password, second form
|
||||
@@ -430,6 +423,9 @@ export default struct FaceAuth {
|
||||
.height($r('app.float.image_small'))
|
||||
.margin({ top: $r('app.float.content_padding_top'), bottom: $r('app.float.content_padding') })
|
||||
.colorBlend($r('sys.color.ohos_id_color_activated'))
|
||||
.onClick(() => {
|
||||
this.sendFaceEvent();
|
||||
})
|
||||
Text(globalThis.wantParams.title).fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
|
||||
@@ -439,14 +435,17 @@ export default struct FaceAuth {
|
||||
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * 2))
|
||||
.margin({ top: $r('app.float.content_padding') })
|
||||
.onClick(() => {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
})
|
||||
Text(this.prompt)
|
||||
.margin({ top: $r('app.float.content_padding') })
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.height($r('app.float.size_24'))
|
||||
.fontColor(this.onFontColor(this.prompt, globalThis.context))
|
||||
.onClick(() => {
|
||||
if (globalThis?.context?.resourceManager
|
||||
?.getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1'))) {
|
||||
this.sendFaceEvent();
|
||||
}
|
||||
})
|
||||
Row() {
|
||||
Column() {
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
@@ -459,7 +458,7 @@ export default struct FaceAuth {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
this.textValue = '';
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
@@ -511,7 +510,7 @@ export default struct FaceAuth {
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
this.textValue = '';
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
|
||||
@@ -551,7 +550,7 @@ export default struct FaceAuth {
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.id('cancelBtnSixPinFaceAuth')
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
this.textValue = '';
|
||||
})
|
||||
.backgroundColor(Color.Transparent)
|
||||
@@ -583,7 +582,7 @@ export default struct FaceAuth {
|
||||
.height($r('app.float.image_size'))
|
||||
.colorBlend($r('sys.color.ohos_id_color_activated'))
|
||||
.onClick(() => {
|
||||
this.send();
|
||||
this.sendFaceEvent();
|
||||
})
|
||||
Text(this.prompt)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
@@ -591,7 +590,7 @@ export default struct FaceAuth {
|
||||
.height($r('app.float.size_24'))
|
||||
.fontColor(this.onFontColor(this.prompt, globalThis.context))
|
||||
.onClick(() => {
|
||||
this.send();
|
||||
this.sendFaceEvent();
|
||||
})
|
||||
if (!globalThis.wantParams?.navigationButtonText) {
|
||||
Row() {
|
||||
@@ -599,7 +598,7 @@ export default struct FaceAuth {
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.id('cancelBtnAllFace')
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
.backgroundColor(Color.Transparent)
|
||||
.height($r('app.float.btn_height'))
|
||||
@@ -624,7 +623,7 @@ export default struct FaceAuth {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
|
||||
@@ -636,6 +635,7 @@ export default struct FaceAuth {
|
||||
Column() {
|
||||
Button(globalThis.wantParams?.navigationButtonText)
|
||||
.onClick(() => {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_USER_NAVIGATION', [Constants.noticeTypeFace]);
|
||||
globalThis.session?.terminateSelf?.();
|
||||
})
|
||||
.margin({ right: $r('app.float.content_padding') })
|
||||
@@ -654,7 +654,7 @@ export default struct FaceAuth {
|
||||
}
|
||||
.position({
|
||||
y: this.fingerPosition.udSensorCenterYInThousandth / this.screen[1] < Constants.fingerSensorPositionLine &&
|
||||
!this.isLandscape
|
||||
!this.IS_LANDSCAPE
|
||||
? (px2vp(this.screen[1]) * this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH)
|
||||
- px2vp(this.screen[1]) +
|
||||
this.SYSTEM_NAVIGATION_BAR_HEIGHT - MARGIN_TOP - px2vp(this.fingerPosition.udSensorRadiusInPx)
|
||||
|
||||
@@ -29,9 +29,10 @@ const INTERVAL = 1000;
|
||||
let pinAuthManager;
|
||||
let pinData = '';
|
||||
const THOUSANDTH = 1000;
|
||||
const NORMAL_POSITION = -260;
|
||||
const OUT_SENSOR = -292
|
||||
const MARGIN_TOP = 66
|
||||
const BOTTOM_BUTTON = 56;
|
||||
const BOTTOM_TEXT = 20;
|
||||
const PADDING_8 = 8;
|
||||
const PADDING_24 = 24;
|
||||
const OFF_SCREEN_FINGER = 3;
|
||||
const SINGLE_FINGER = 1;
|
||||
const PIN_FINGER = 2;
|
||||
@@ -40,6 +41,7 @@ const MULTI_PIN = 5;
|
||||
const RADIUS = 2;
|
||||
const PIN_FAIL_TIP = 3;
|
||||
const AUTH_LOCK = 0;
|
||||
const NOTICE_DELAY = 500;
|
||||
|
||||
@Component
|
||||
export default struct FingerprintAuth {
|
||||
@@ -53,14 +55,16 @@ export default struct FingerprintAuth {
|
||||
@State isEdit: boolean = true;
|
||||
@State inputValue: string = '';
|
||||
@State state: number = 0;
|
||||
@State fingerPositionY: number = 0;
|
||||
@State screenClass: object = {};
|
||||
@State fingerPosition: FingerPosition = {
|
||||
sensorType: '',
|
||||
udSensorRadiusInPx: 60
|
||||
}
|
||||
@State fingerLock: boolean = false;
|
||||
@StorageLink('SYSTEM_NAVIGATION_BAR_HEIGHT') SYSTEM_NAVIGATION_BAR_HEIGHT: number = 0;
|
||||
@State screen: number[] = [];
|
||||
@Consume isLandscape: boolean;
|
||||
@StorageLink('IS_LANDSCAPE') IS_LANDSCAPE: boolean = false;
|
||||
|
||||
aboutToAppear(): void {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
@@ -68,7 +72,9 @@ export default struct FingerprintAuth {
|
||||
if (this.cmdData && this.cmdData.length > 0) {
|
||||
this.onCmdDataChange('first');
|
||||
}
|
||||
LogUtils.info(TAG, 'aboutToAppear PINAuth');
|
||||
this.fingerPositionY = px2vp(this.screen[1]) - px2vp(this.fingerPosition.udSensorCenterYInThousandth *
|
||||
this.screen[1]) / THOUSANDTH + BOTTOM_BUTTON + PADDING_8 + BOTTOM_TEXT + PADDING_24;
|
||||
LogUtils.info(TAG, 'aboutToAppear PINAuth this.fingerPositionY: ' + this.fingerPositionY);
|
||||
pinAuthManager = new account_osAccount.PINAuth();
|
||||
pinAuthManager.registerInputer({
|
||||
onGetData: (authSubType, callback) => {
|
||||
@@ -129,23 +135,29 @@ export default struct FingerprintAuth {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num === 'first') {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync(stateNew === OFF_SCREEN_FINGER ?
|
||||
$r('app.string.unified_authwidget_hint_normal_fp_only') :
|
||||
$r('app.string.unified_authwidget_hint_inscreen_fp'));
|
||||
}
|
||||
const displayClass = display.getDefaultDisplaySync();
|
||||
this.screen = [displayClass.width, displayClass.height];
|
||||
}
|
||||
if (remainAttempts) {
|
||||
if (remainAttempts < Constants.maxFailTimes) {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2'));
|
||||
if (num !== 'first' && remainAttempts > AUTH_LOCK) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}
|
||||
this.fingerLock = false;
|
||||
}
|
||||
if (num === 'first') {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp'));
|
||||
if (remainAttempts > AUTH_LOCK && num !== 'first') {
|
||||
setTimeout(() => {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}, NOTICE_DELAY);
|
||||
}
|
||||
if (remainAttempts === AUTH_LOCK) {
|
||||
this.prompt = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_title_number_failed_fp_forbidden'));
|
||||
this.fingerLock = true;
|
||||
if (this.dialogType === DialogType.PIN_FINGER) {
|
||||
if (this.pinSubType !== Constants.pinSix) {
|
||||
stateNew = MULTI_PIN;
|
||||
@@ -163,6 +175,12 @@ export default struct FingerprintAuth {
|
||||
})
|
||||
}
|
||||
|
||||
sendFingerEvent(): void {
|
||||
if (!this.fingerLock) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypeFinger]);
|
||||
}
|
||||
}
|
||||
|
||||
countTime(freezingTime): void {
|
||||
const TRY_AGAIN = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_postretry'));
|
||||
@@ -192,7 +210,10 @@ export default struct FingerprintAuth {
|
||||
?.getStringSync($r('app.string.unified_authwidget_hint_fp_verify_success')):
|
||||
case context?.resourceManager
|
||||
?.getStringSync($r('app.string.unified_authwidget_hint_inscreen_fp')):
|
||||
case context?.resourceManager
|
||||
?.getStringSync($r('app.string.unified_authwidget_hint_normal_fp_only')): {
|
||||
return $r('sys.color.ohos_id_color_text_secondary');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,22 +228,26 @@ export default struct FingerprintAuth {
|
||||
}
|
||||
}
|
||||
|
||||
handleCancel(): void {
|
||||
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, globalThis?.wantParams?.type || []);
|
||||
globalThis.session?.terminateSelf?.();
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({
|
||||
columns: 8,
|
||||
gutter: { x: 5, y: 10 },
|
||||
columns: { xs: 4, sm: 4, md: 8, lg: 12 },
|
||||
gutter: { x: 24, y: 24 },
|
||||
breakpoints: { value: Constants.deviceDpi,
|
||||
reference: BreakpointsReference.WindowSize },
|
||||
direction: GridRowDirection.Row
|
||||
}) {
|
||||
GridCol({ span: { xs: 0, sm: 0, md: 2, lg: 2 } })
|
||||
.visibility(Visibility.Hidden)
|
||||
GridCol({
|
||||
span: { xs: 8, sm: 8, md: 4, lg: 4 },
|
||||
span: { xs: 4, sm: 4, md: 4, lg: 6 },
|
||||
offset: { md: 2, lg: 3 },
|
||||
}) {
|
||||
Column() {
|
||||
if (this.state === OFF_SCREEN_FINGER) {
|
||||
if (this.state === OFF_SCREEN_FINGER) {
|
||||
Column() {
|
||||
Text(globalThis.wantParams?.title)
|
||||
.margin({ top: $r('app.float.title_padding_top') })
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
@@ -233,8 +258,8 @@ export default struct FingerprintAuth {
|
||||
.height($r('app.float.image_big'))
|
||||
.margin({ top: $r('app.float.content_padding'), bottom: $r('app.float.content_padding') })
|
||||
|
||||
Text($r('app.string.unified_authwidget_hint_normal_fp_only'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'))
|
||||
Text(this.prompt)
|
||||
.fontColor(this.onFingerPrintFontColor(this.prompt, globalThis.context))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
if (this.dialogType === DialogType.PIN_FINGER) {
|
||||
Row() {
|
||||
@@ -249,7 +274,7 @@ export default struct FingerprintAuth {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
this.textValue = '';
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
@@ -288,7 +313,7 @@ export default struct FingerprintAuth {
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.id('cancelDefBtnState3FingerprintAuth')
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
.backgroundColor(Color.Transparent)
|
||||
.height($r('app.float.btn_height'))
|
||||
@@ -314,7 +339,7 @@ export default struct FingerprintAuth {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
|
||||
@@ -326,6 +351,8 @@ export default struct FingerprintAuth {
|
||||
Column() {
|
||||
Button(globalThis.wantParams?.navigationButtonText)
|
||||
.onClick(() => {
|
||||
AuthUtils.getInstance()
|
||||
.sendNotice('EVENT_AUTH_USER_NAVIGATION', [Constants.noticeTypeFinger]);
|
||||
globalThis.session?.terminateSelf?.();
|
||||
})
|
||||
.margin({ right: $r('app.float.content_padding') })
|
||||
@@ -341,8 +368,17 @@ export default struct FingerprintAuth {
|
||||
.margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') })
|
||||
}
|
||||
}
|
||||
} else if (this.state === PIN_FINGER) {
|
||||
if (!this.isLandscape) {
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_dialog'))
|
||||
.margin({
|
||||
left: ($r('sys.float.ohos_id_dialog_margin_start')),
|
||||
right: ($r('sys.float.ohos_id_dialog_margin_end')),
|
||||
bottom: ($r('sys.float.ohos_id_dialog_margin_bottom'))
|
||||
})
|
||||
} else {
|
||||
Column() {
|
||||
if (this.state === PIN_FINGER) {
|
||||
Text(globalThis.wantParams?.title)
|
||||
.margin({ top: $r('app.float.title_padding_top') })
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
@@ -358,12 +394,6 @@ export default struct FingerprintAuth {
|
||||
.id('blueFingerprintImgState2FingerprintAuth')
|
||||
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS))
|
||||
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS))
|
||||
.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(this.onFingerPrintFontColor(this.prompt, globalThis.context))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
@@ -379,7 +409,7 @@ export default struct FingerprintAuth {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
this.textValue = '';
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
@@ -411,9 +441,7 @@ export default struct FingerprintAuth {
|
||||
}
|
||||
.height($r('app.float.btn_height'))
|
||||
.margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') })
|
||||
}
|
||||
} else if (this.state === SINGLE_FINGER) {
|
||||
if (!this.isLandscape) {
|
||||
} else if (this.state === SINGLE_FINGER) {
|
||||
Text(globalThis.wantParams?.title)
|
||||
.margin({ top: $r('app.float.title_padding_top') })
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
@@ -429,12 +457,6 @@ export default struct FingerprintAuth {
|
||||
.id('blueFingerprintState1FingerprintAuth')
|
||||
.width(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS))
|
||||
.height(px2vp(this.fingerPosition.udSensorRadiusInPx * RADIUS))
|
||||
.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(this.onFingerPrintFontColor(this.prompt, globalThis.context))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
@@ -444,7 +466,7 @@ export default struct FingerprintAuth {
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.id('cancelDefBtnState1FingerprintAuth')
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
.backgroundColor(Color.Transparent)
|
||||
.height($r('app.float.btn_height'))
|
||||
@@ -470,7 +492,7 @@ export default struct FingerprintAuth {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
|
||||
@@ -482,6 +504,8 @@ export default struct FingerprintAuth {
|
||||
Column() {
|
||||
Button(globalThis.wantParams?.navigationButtonText)
|
||||
.onClick(() => {
|
||||
AuthUtils.getInstance()
|
||||
.sendNotice('EVENT_AUTH_USER_NAVIGATION', [Constants.noticeTypeFinger]);
|
||||
globalThis.session?.terminateSelf?.();
|
||||
})
|
||||
.margin({ right: $r('app.float.content_padding') })
|
||||
@@ -496,94 +520,88 @@ export default struct FingerprintAuth {
|
||||
.height($r('app.float.btn_height'))
|
||||
.margin({ top: $r('app.float.element_margin'), bottom: $r('app.float.content_padding') })
|
||||
}
|
||||
}
|
||||
} else if (this.state === MULTI_PIN) {
|
||||
// Password 32-bit
|
||||
Column() {
|
||||
PassWord({
|
||||
textValue: $textValue,
|
||||
inputValue: $inputValue,
|
||||
isEdit: $isEdit,
|
||||
pinSubType: $pinSubType
|
||||
})
|
||||
Row() {
|
||||
Column() {
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.id('cancelBtnState5FingerprintAuth')
|
||||
.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?.();
|
||||
this.textValue = '';
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.height($r('app.float.digital_password_mask_height'))
|
||||
.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.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(async (e) => {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
})
|
||||
}.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 === SIX_PIN) {
|
||||
// Password 6-bit
|
||||
Column() {
|
||||
SixPassword({
|
||||
textValue: $textValue,
|
||||
inputValue: $inputValue,
|
||||
isEdit: $isEdit
|
||||
})
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.id('cancelState6FingerprintAuth')
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.textValue = '';
|
||||
} else if (this.state === MULTI_PIN) {
|
||||
// Password 32-bit
|
||||
Column() {
|
||||
PassWord({
|
||||
textValue: $textValue,
|
||||
inputValue: $inputValue,
|
||||
isEdit: $isEdit,
|
||||
pinSubType: $pinSubType
|
||||
})
|
||||
.backgroundColor(Color.Transparent)
|
||||
Row() {
|
||||
Column() {
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.id('cancelBtnState5FingerprintAuth')
|
||||
.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(() => {
|
||||
this.handleCancel();
|
||||
this.textValue = '';
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.height($r('app.float.digital_password_mask_height'))
|
||||
.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.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(async (e) => {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', [Constants.noticeTypePin]);
|
||||
})
|
||||
}.width(Constants.halfContainerWidth)
|
||||
}
|
||||
.height($r('app.float.btn_height'))
|
||||
.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)
|
||||
}
|
||||
} else if (this.state === SIX_PIN) {
|
||||
// Password 6-bit
|
||||
Column() {
|
||||
SixPassword({
|
||||
textValue: $textValue,
|
||||
inputValue: $inputValue,
|
||||
isEdit: $isEdit
|
||||
})
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.id('cancelState6FingerprintAuth')
|
||||
.onClick(() => {
|
||||
this.handleCancel();
|
||||
this.textValue = '';
|
||||
})
|
||||
.backgroundColor(Color.Transparent)
|
||||
.height($r('app.float.btn_height'))
|
||||
.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
.position({ y: -this.fingerPositionY })
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_dialog'))
|
||||
.margin({
|
||||
left: ($r('sys.float.ohos_id_dialog_margin_start')),
|
||||
right: ($r('sys.float.ohos_id_dialog_margin_end')),
|
||||
bottom: ($r('sys.float.ohos_id_dialog_margin_bottom'))
|
||||
})
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_dialog_bg'))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_dialog'))
|
||||
.position({
|
||||
y: (this.isLandscape || !this.fingerPosition.udSensorCenterYInThousandth)
|
||||
? (this.state === OFF_SCREEN_FINGER
|
||||
? OUT_SENSOR - this.SYSTEM_NAVIGATION_BAR_HEIGHT : NORMAL_POSITION)
|
||||
: (px2vp(this.screen[1]) * this.fingerPosition.udSensorCenterYInThousandth / THOUSANDTH)
|
||||
- px2vp(this.screen[1]) - MARGIN_TOP - px2vp(this.fingerPosition.udSensorRadiusInPx)
|
||||
})
|
||||
.margin({
|
||||
left: ($r('sys.float.ohos_id_dialog_margin_start')),
|
||||
right: ($r('sys.float.ohos_id_dialog_margin_end')),
|
||||
bottom: ($r('sys.float.ohos_id_dialog_margin_bottom'))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ export default struct PasswordAuth {
|
||||
|
||||
onCmdDataChange(num?: string): void {
|
||||
this.cmdData.length > 0 && this.cmdData.map((item) => {
|
||||
const { type,remainAttempts, lockoutDuration} = item.payload;
|
||||
const { type, remainAttempts, lockoutDuration } = item.payload;
|
||||
if (type === Constants.noticeTypePin) {
|
||||
if (remainAttempts) {
|
||||
if (remainAttempts && remainAttempts < Constants.maxFailTimes) {
|
||||
this.inputValue = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error'));
|
||||
this.textValue = '';
|
||||
@@ -56,7 +56,7 @@ export default struct PasswordAuth {
|
||||
this.inputValue = '';
|
||||
}
|
||||
// pin auth Remaining number
|
||||
if (remainAttempts < 3) {
|
||||
if (remainAttempts < Constants.hintTimesByFailLess) {
|
||||
this.inputValue = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_pwd_error_can_try'))
|
||||
+ remainAttempts + globalThis.context.resourceManager
|
||||
@@ -71,8 +71,7 @@ export default struct PasswordAuth {
|
||||
this.textValue = '';
|
||||
return;
|
||||
}
|
||||
this.inputValue = globalThis.context.resourceManager
|
||||
.getStringSync($r('app.string.unified_authwidget_hint_pwd_error'));
|
||||
this.inputValue = ' ';
|
||||
this.textValue = '';
|
||||
}
|
||||
})
|
||||
@@ -120,19 +119,23 @@ export default struct PasswordAuth {
|
||||
this.inputValue = promptText;
|
||||
}
|
||||
|
||||
handleCancel(): void {
|
||||
AuthUtils.getInstance().sendNotice(Constants.noticeEventCancel, globalThis?.wantParams?.type || []);
|
||||
globalThis.session?.terminateSelf?.();
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({
|
||||
columns: 8,
|
||||
gutter: { x: 5, y: 10 },
|
||||
columns: { xs: 4, sm: 4, md: 8, lg: 12 },
|
||||
gutter: { x: 24, y: 24 },
|
||||
breakpoints: { value: Constants.deviceDpi,
|
||||
reference: BreakpointsReference.WindowSize },
|
||||
direction: GridRowDirection.Row
|
||||
}) {
|
||||
GridCol({ span: { xs: 0, sm: 0, md: 2, lg: 2 } })
|
||||
.visibility(Visibility.Hidden)
|
||||
GridCol({
|
||||
span: { xs: 8, sm: 8, md: 4, lg: 4 },
|
||||
span: { xs: 4, sm: 4, md: 4, lg: 6 },
|
||||
offset: { md: 2, lg: 3 },
|
||||
}) {
|
||||
Column() {
|
||||
if (this.pinSubType !== Constants.pinSix) {
|
||||
@@ -155,7 +158,7 @@ export default struct PasswordAuth {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
})
|
||||
.id('cancelBtnDialogPwd')
|
||||
}.width('50%')
|
||||
@@ -197,7 +200,7 @@ export default struct PasswordAuth {
|
||||
})
|
||||
Button($r('app.string.unified_authwidget_cancel'), { stateEffect: true })
|
||||
.onClick(() => {
|
||||
globalThis.session?.terminateSelf?.();
|
||||
this.handleCancel();
|
||||
this.textValue = '';
|
||||
this.inputValue = ' ';
|
||||
})
|
||||
|
||||
@@ -1,18 +1,3 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"module": {
|
||||
"name": "entry",
|
||||
@@ -40,7 +25,6 @@
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
// 新增key值,定义垂域服务业务细分类型
|
||||
"name": "ohos.extension.servicetype",
|
||||
"value": "commonDialog"
|
||||
}
|
||||
@@ -56,7 +40,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.SUPPORT_USER_AUTH"
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* 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 hilog from '@ohos.hilog';
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('ActsAbilityTest', function () {
|
||||
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
|
||||
beforeAll(function () {
|
||||
// Presets an action, which is performed only once before all test cases of the test suite start.
|
||||
// This API supports only one parameter: preset action function.
|
||||
})
|
||||
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('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';
|
||||
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
|
||||
expect(a).assertContain(b);
|
||||
expect(a).assertEqual(a);
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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, it } from '@ohos/hypium';
|
||||
|
||||
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;
|
||||
})
|
||||
|
||||
it('clickEventCancal_Input', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayms);
|
||||
await driver.findComponent(ON.id('pinSix'));
|
||||
await driver.delayMs(delayms);
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* 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';
|
||||
import TimeUtils from '../../../../../main/ets/common/utils/TimeUtils';
|
||||
import WindowPrivacyUtils from '../../../../../main/ets/common/utils/WindowPrivacyUtils';
|
||||
|
||||
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, 'userAuthInstance callback result = ' + JSON.stringify(result));
|
||||
}
|
||||
});
|
||||
userAuthInstance.start();
|
||||
})
|
||||
|
||||
it('getUint8PWFunc_test', 0, function (done) {
|
||||
const data1 = FuncUtils.getUint8PW('111111');
|
||||
const data2 = FuncUtils.getUint8PW('11111111');
|
||||
FuncUtils.getWindowHeight();
|
||||
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, 4]);
|
||||
const data3 = FuncUtils.getDialogType([]);
|
||||
const data4 = FuncUtils.getDialogType(null);
|
||||
const data5 = FuncUtils.getDialogType(undefined);
|
||||
const data6 = FuncUtils.getDialogType([1, 2]);
|
||||
const data7 = FuncUtils.getDialogType([1, 4]);
|
||||
const data8 = FuncUtils.getDialogType([2]);
|
||||
const data9 = FuncUtils.getDialogType([4]);
|
||||
expect(data1).assertEqual(1);
|
||||
expect(data2).assertEqual(10);
|
||||
expect(data3).assertEqual(1);
|
||||
expect(data4).assertEqual(1);
|
||||
expect(data5).assertEqual(1);
|
||||
expect(data6).assertEqual(6);
|
||||
expect(data7).assertEqual(7);
|
||||
expect(data8).assertEqual(2);
|
||||
expect(data9).assertEqual(3);
|
||||
done();
|
||||
})
|
||||
|
||||
it('getWindowHeightFunc_test', 0, function (done) {
|
||||
FuncUtils.getWindowHeight();
|
||||
done();
|
||||
})
|
||||
|
||||
it('sendNoticeFunc_test', 0, async function (done) {
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_READY', ['pin']);
|
||||
AuthUtils.getInstance().sendNotice('EVENT_AUTH_TYPE_START', ['pin']);
|
||||
done();
|
||||
})
|
||||
|
||||
it('logFunc_test', 0, async function (done) {
|
||||
LogUtils.d(TAG, 'debug log test');
|
||||
LogUtils.i(TAG, 'info log test');
|
||||
LogUtils.w(TAG, 'warning log test');
|
||||
LogUtils.e(TAG, 'error log test');
|
||||
LogUtils.f(TAG, 'fatal log test');
|
||||
done();
|
||||
})
|
||||
|
||||
it('getFreezingTimeNmFunc_test', 0, async function (done) {
|
||||
TimeUtils.getFreezingTimeNm(10000, globalThis.context);
|
||||
TimeUtils.getFreezingTimeNm(100000, globalThis.context);
|
||||
done();
|
||||
})
|
||||
|
||||
it('setWindowPrivacyModeFunc_test', 0, async function (done) {
|
||||
WindowPrivacyUtils.setWindowPrivacyMode(null, false);
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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');
|
||||
expect(Constants.noticeTypePin).assertEqual('pin');
|
||||
expect(Constants.noticeTypeFace).assertEqual('face');
|
||||
expect(Constants.noticeTypeFinger).assertEqual('fingerprint');
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* 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';
|
||||
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
|
||||
|
||||
const delayTime: number = 1000;
|
||||
|
||||
export default function CustomPasswordTest() {
|
||||
describe('customPasswordTest', function () {
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
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;
|
||||
sleep(1000);
|
||||
|
||||
let want = {
|
||||
bundleName: bundleName,
|
||||
abilityName: "EntryAbility"
|
||||
}
|
||||
await delegator.startAbility(want);
|
||||
sleep(1000);
|
||||
})
|
||||
|
||||
it('cancelIcon_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('mainIndex'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('cancelImgCustomPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelImgCustomPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('textPrompt_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelIconCustomPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('forgotBtn_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('forgotBtnCustomPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('numKeyBord_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('numKeyBordCustomPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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_NUMBER",
|
||||
"title": "",
|
||||
"type": ["pin", "face"],
|
||||
"widgetContextId": 6711153399710207000,
|
||||
"windowModeType": "FULLSCREEN"
|
||||
};
|
||||
globalThis.wantParams = wantDefault;
|
||||
globalThis.themeType = 2;
|
||||
})
|
||||
|
||||
it('input_full_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('pinInputNumber'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('faceImg_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('faceImgCustomPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* 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 CustomPasswordFingerTest() {
|
||||
describe('CustomPasswordFingerTest', function () {
|
||||
beforeAll(async function () {
|
||||
const wantDefault = {
|
||||
"cmd": [{
|
||||
"event": "CMD_NOTIFY_AUTH_START", "payload": {
|
||||
"lockoutDuration": 0, "remainAttempts": 5, "type": "pin", "sensorInfo": ""
|
||||
}, "version": "1"
|
||||
}],
|
||||
"pinSubType": "PIN_MIXED",
|
||||
"title": "",
|
||||
"type": ["pin", "fingerprint"],
|
||||
"widgetContextId": 6711153399710207000,
|
||||
"windowModeType": "FULLSCREEN"
|
||||
};
|
||||
globalThis.wantParams = wantDefault;
|
||||
})
|
||||
|
||||
it('pinInput_full_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('pinInput'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
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('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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* 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';
|
||||
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
|
||||
|
||||
const delayTime: number = 1000;
|
||||
|
||||
export default function faceAuthJsTest() {
|
||||
describe('faceAuthJsTest', function () {
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
beforeAll(async function () {
|
||||
const data = {
|
||||
"cmd": [{
|
||||
"event": "CMD_NOTIFY_AUTH_START", "payload": {
|
||||
"lockoutDuration": 0, "remainAttempts": 4, "type": "face"
|
||||
}, "version": "1"
|
||||
}],
|
||||
"navigationButtonText": "确认",
|
||||
"title": "",
|
||||
"type": ["face"],
|
||||
"widgetContextId": 1590859524489244200,
|
||||
"windowModeType": "DIALOG_BOX"
|
||||
}
|
||||
globalThis.wantParams = data;
|
||||
sleep(1000);
|
||||
|
||||
let want = {
|
||||
bundleName: bundleName,
|
||||
abilityName: "EntryAbility"
|
||||
}
|
||||
await delegator.startAbility(want);
|
||||
sleep(1000);
|
||||
})
|
||||
|
||||
it('promptText_resetPin_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('promptTextResetPinFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('cancelBtn_pin_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelBtnPinFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('usePwd_pin_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('usePwdPinFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('cancelImg_all_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelImgAllFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('usePwdBtn_all_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('usePwdBtnAllFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('resetPromptText_all_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('resetPromptTextAllFaceAuth'));
|
||||
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('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('errFaceImg_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('errFaceImgFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('blueFingerprintImg_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('blueFingerprintImgFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('cancelBtn_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelBtnFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('usePwdBtn_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('usePwdBtnFaceAuth'));
|
||||
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('okBtn_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('okBtnFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('cancelBtn_sixPin_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelBtnSixPinFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('promptText_reset_faceAuth_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('promptTextResetFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* 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';
|
||||
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
|
||||
|
||||
const delayTime: number = 1000;
|
||||
|
||||
export default function fingerprintAuthTest() {
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
describe('fingerprintAuthTest', function () {
|
||||
beforeAll(async function () {
|
||||
const data = {
|
||||
"cmd": [{
|
||||
"event": "CMD_NOTIFY_AUTH_START", "payload": {
|
||||
"lockoutDuration": 0,
|
||||
"remainAttempts": 5,
|
||||
"sensorInfo": "{\"sensorType\":\"SensorType1\",\"udSensorCenterXInThousandth\":500,\"udSensorCenterYInThousandth\":500,\"udSensorRadiusInPx\":30}",
|
||||
"type": "fingerprint"
|
||||
}, "version": "1"
|
||||
}],
|
||||
"navigationButtonText": "确定",
|
||||
"title": "",
|
||||
"type": ["fingerprint"],
|
||||
"widgetContextId": 13682225748840628000,
|
||||
"windowModeType": "DIALOG_BOX"
|
||||
}
|
||||
globalThis.wantParams = data;
|
||||
|
||||
sleep(1000);
|
||||
|
||||
let want = {
|
||||
bundleName: bundleName,
|
||||
abilityName: "EntryAbility"
|
||||
}
|
||||
await delegator.startAbility(want);
|
||||
sleep(1000);
|
||||
|
||||
})
|
||||
|
||||
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);
|
||||
await driver.findComponent(ON.id('blueFingerprintState1FingerprintAuth'));
|
||||
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);
|
||||
await driver.findComponent(ON.id('usePwdBtnState1FingerprintAuth'));
|
||||
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();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* 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 userAuth from '@ohos.userIAM.userAuth';
|
||||
import LogUtils from '../../../../../main/ets/common/utils/LogUtils';
|
||||
|
||||
const TAG = 'PageComTest';
|
||||
|
||||
export default function PageComTest() {
|
||||
describe('pageComTest', function () {
|
||||
it('clickEventOk_Input', 0, async function (done) {
|
||||
let userAuthInstance = null;
|
||||
const authParam = {
|
||||
challenge: new Uint8Array([49, 49, 49, 49, 49, 49]),
|
||||
authType: [4],
|
||||
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));
|
||||
}
|
||||
});
|
||||
expect(userAuthInstance).not().assertNull();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* 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';
|
||||
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
const delayTime: number = 1000;
|
||||
|
||||
const delegator = abilityDelegatorRegistry.getAbilityDelegator()
|
||||
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
|
||||
|
||||
export default function PasswordAuthTest() {
|
||||
describe('passwordAuthTest', function () {
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
sleep(1000);
|
||||
let want = {
|
||||
bundleName: bundleName,
|
||||
abilityName: "EntryAbility"
|
||||
}
|
||||
await delegator.startAbility(want);
|
||||
sleep(1000);
|
||||
})
|
||||
|
||||
it('cancelBtn_dialog_pwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelBtnDialogPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('okBtn_dialog_pwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('okBtn'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('input_dialog_pwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('pinInputMix'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* 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';
|
||||
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
|
||||
|
||||
const delayTime: number = 1000;
|
||||
|
||||
export default function passwordAuthSixTest() {
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
describe('passwordAuthSixTest', function () {
|
||||
beforeAll(async function () {
|
||||
|
||||
})
|
||||
|
||||
it('cancelBtn_dialog_sixPwd_test', 0, async function (done) {
|
||||
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;
|
||||
sleep(1000);
|
||||
|
||||
let want = {
|
||||
bundleName: bundleName,
|
||||
abilityName: "EntryAbility"
|
||||
}
|
||||
await delegator.startAbility(want);
|
||||
sleep(1000);
|
||||
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelBtnDialogSixPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* 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 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": "FULLSCREEN",
|
||||
};
|
||||
globalThis.wantParams = data;
|
||||
})
|
||||
|
||||
it('cancelIcon_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelIconCustomPwd'));
|
||||
expect(driver).not().assertNull();
|
||||
done();
|
||||
})
|
||||
|
||||
it('textPrompt_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelIconCustomPwd'));
|
||||
expect(driver).not().assertNull();
|
||||
done();
|
||||
})
|
||||
|
||||
it('forgotBtn_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('forgotBtnCustomPwd'));
|
||||
expect(driver).not().assertNull();
|
||||
done();
|
||||
})
|
||||
|
||||
it('numKeyBord_customPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('numKeyBordCustomPwd'));
|
||||
expect(driver).not().assertNull();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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 delays: number = 1000;
|
||||
|
||||
export default function CustomPasswordAttrTest() {
|
||||
describe('CustomPasswordAttrTest', 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": "FULLSCREEN",
|
||||
};
|
||||
globalThis.wantParams = data;
|
||||
})
|
||||
|
||||
it('clickEventCancal_Input', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delays);
|
||||
await driver.findComponent(ON.type('Text'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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 delays: number = 1000;
|
||||
|
||||
export default function FaceAuthTest() {
|
||||
describe('FaceAuthTest', function () {
|
||||
beforeAll(async function () {
|
||||
const data = {
|
||||
"cmd": [{
|
||||
"event": "CMD_NOTIFY_AUTH_START", "payload": {
|
||||
"lockoutDuration": 0, "remainAttempts": 4, "type": "face"
|
||||
}, "version": "1"
|
||||
}],
|
||||
"navigationButtonText": "确认",
|
||||
"title": "",
|
||||
"type": ["face"],
|
||||
"widgetContextId": 1590859524489244200,
|
||||
"windowModeType": "DIALOG_BOX",
|
||||
}
|
||||
globalThis.wantParams = data;
|
||||
})
|
||||
|
||||
it('clickEventCancal_face', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delays);
|
||||
await driver.findComponent(ON.clickable(true));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
|
||||
it('clickEventError_face', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delays);
|
||||
await driver.findComponent(ON.id('okBtnFaceAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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 delays: 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,
|
||||
"sensorInfo": "{\"sensorType\":\"SensorType1\",\"udSensorCenterXInThousandth\":500,\"udSensorCenterYInThousandth\":500,\"udSensorRadiusInPx\":30}",
|
||||
"type": "fingerprint"
|
||||
}, "version": "1"
|
||||
}],
|
||||
"navigationButtonText": "确定",
|
||||
"title": "",
|
||||
"type": ["fingerprint"],
|
||||
"widgetContextId": 13682225748840628000,
|
||||
"windowModeType": "DIALOG_BOX"
|
||||
}
|
||||
globalThis.wantParams = data;
|
||||
})
|
||||
|
||||
it('clickEventCancal_finger', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delays);
|
||||
await driver.findComponent(ON.id('cancelBthState3FingerprintAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('clickEventError_finger', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delays);
|
||||
await driver.findComponent(ON.id('usePwdBtnState1FingerprintAuth'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* 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';
|
||||
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
|
||||
|
||||
const delayTime: number = 1000;
|
||||
|
||||
export default function PasswordAuthTest() {
|
||||
describe('PasswordAuthTest', function () {
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
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": "please input",
|
||||
"type": ["pin"],
|
||||
"widgetContextId": 7932856209793250000,
|
||||
"windowModeType": "DIALOG_BOX"
|
||||
};
|
||||
globalThis.wantParams = data;
|
||||
sleep(1000);
|
||||
|
||||
let want = {
|
||||
bundleName: bundleName,
|
||||
abilityName: "EntryAbility"
|
||||
}
|
||||
await delegator.startAbility(want);
|
||||
sleep(1000);
|
||||
})
|
||||
|
||||
it('pinInputMix_ui_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('pinInputMix'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('cancelBtn_dialog_pwd_ui_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelBtnDialogPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('okBtn_dialog_pwd_ui_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('okBtn'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('titlePwdAuth_ui_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('titlePwdAuth'));
|
||||
await driver.delayMs(delayTime);
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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';
|
||||
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
|
||||
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
|
||||
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
|
||||
|
||||
const delayTime: number = 1000;
|
||||
|
||||
export default function passwordAuthSixUiTest() {
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
describe('passwordAuthSixUiTest', 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;
|
||||
sleep(1000);
|
||||
|
||||
let want = {
|
||||
bundleName: bundleName,
|
||||
abilityName: "EntryAbility"
|
||||
}
|
||||
await delegator.startAbility(want);
|
||||
sleep(1000);
|
||||
})
|
||||
|
||||
it('pinSix_ui_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('pinSix'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('cancelBtn_dialog_sixPwd_test', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delayTime);
|
||||
await driver.findComponent(ON.id('cancelBtnDialogSixPwd'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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 delays: number = 1000;
|
||||
|
||||
export default function PinFingerPrintTest() {
|
||||
describe('PinFingerPrintTest', 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;
|
||||
})
|
||||
|
||||
it('clickEventCancal_finger', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delays);
|
||||
await driver.findComponent(ON.clickable(true).isAfter(ON.type('Image')));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
it('clickEventError_finger', 0, async function (done) {
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(delays);
|
||||
await driver.findComponent(ON.clickable(true).text('未识别成功,点击此处重试'));
|
||||
expect(true).assertTrue();
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,18 +1,3 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"module": {
|
||||
"name": "entry_test",
|
||||
@@ -222,7 +207,6 @@
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
// 新增key值,定义垂域服务业务细分类型
|
||||
"name": "ohos.extension.servicetype",
|
||||
"value": "commonDialog"
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// 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
|
||||
@@ -18,4 +18,3 @@
|
||||
"@ohos/hvigor": "1.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user