diff --git a/UserAuthentication/README.md b/UserAuthentication/README.md
index b995722a700d0678b4ec1428e81f3b5e886c9204..7a66c0cc92ec06248f99ebd6667004b6f53c701d 100644
--- a/UserAuthentication/README.md
+++ b/UserAuthentication/README.md
@@ -7,8 +7,8 @@
### 效果预览
| 首页 | 实例1 | 用户验证窗口 |
-| -------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------ |
-|
|
|
|
+| ------------------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
+|
|
|
|
使用说明:
@@ -57,21 +57,17 @@
### 约束与限制
-1.本示例仅支持标准系统上运行,支持设备:华为手机。
+1.本示例仅支持标准系统上运行,支持设备:RK3568。
-2.HarmonyOS系统:HarmonyOS 5.1.0 Release及以上。
+2.本示例为Stage模型,支持API18版本SDK。
-3.HarmonyOS SDK版本:HarmonyOS 5.1.0 Release及以上。
+3.本示例需要使用DevEco Studio Release(5.0.5.306)及以上版本才可编译运行。
-4.本示例为Stage模型,支持API18版本SDK。
+4.HH-SCDAYU200开发套件不支持生物特征识别,建议将认证方式更改为个人识别码(PIN),并确保在切换自定义功能时采用至少两种身份验证方法。
-5.本示例需要使用DevEco Studio Release(5.0.5.306)及以上版本才可编译运行。
+5.自动化测试中非自动化的相关测试点需要手动输入密码或手动录入人脸或指纹。
-6.HH-SCDAYU200开发套件不支持生物特征识别,建议将认证方式更改为个人识别码(PIN),并确保在切换自定义功能时采用至少两种身份验证方法。
-
-7.自动化测试中非自动化的相关测试点需要手动输入密码或手动录入人脸或指纹。
-
-8.在运行测试前需要修改启动页面为`testPage`,具体修改方式为:将`src/main/ets/entryability/EntryAbility.ets`中的`windowStage.loadContent('pages/Index', ...)`修改为`windowStage.loadContent('pages/testPage', ...)` 。
+6.在运行测试前需要修改启动页面为`testPage`,具体修改方式为:将`src/main/ets/entryability/EntryAbility.ets`中的`windowStage.loadContent('pages/Index', ...)`修改为`windowStage.loadContent('pages/testPage', ...)` 。
### 下载
@@ -80,8 +76,8 @@
```
git init
git config core.sparsecheckout true
-echo UserAuthentication > .git/info/sparse-checkout
-git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+echo code/DocsSample/UserAuthentication > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
git pull origin master
```
diff --git a/UserAuthentication/entry/src/main/ets/pages/Index.ets b/UserAuthentication/entry/src/main/ets/pages/Index.ets
index 181eaeaf1897654bd2af98167c4be6a72a8cd83e..b3ac8c2df756a564017649a121011833ec233534 100644
--- a/UserAuthentication/entry/src/main/ets/pages/Index.ets
+++ b/UserAuthentication/entry/src/main/ets/pages/Index.ets
@@ -67,7 +67,7 @@ enum PageIndex {
EXAMPLE_TAB_4 = 5, // 自定义页面的索引值
CREDENTIAL_QUERIES = 6, // 查询凭据页面的索引值
SIMULATION_VALIDATION = 7, // 模拟认证页面的索引值
-
+ AUTH_LOCK_STATE_QUERIES = 8, // 查询认证冻结状态页面的索引值
};
enum ResultIndex {
@@ -90,6 +90,7 @@ struct Index {
@State credentialDigest: string = '';
@State whetherSupport: Resource = $r('app.string.waitQuery');
@State credentialValue: string = '';
+ @State authLockStateContent : string = '';
SPACE_GAP: number = 5; // Row组件间隙
/*
@@ -557,6 +558,30 @@ struct Index {
}
// [End obtain_enrolled_capabilities]
+
+ /*
+ * obtain-auth-lock-state-capabilities.md
+ * 以查询用户PIN码认证类型的认证冻结状态为例
+ * */
+ // [Start obtain_auth_lock_state_capabilities]
+ async obtainingAuthLockState() : Promise {
+ try {
+ Logger.info(`get auth lock state start`);
+ const authLockState : userAuth.AuthLockState = await userAuth.getAuthLockState(userAuth.UserAuthType.PIN);
+ if (authLockState.lockoutDuration === userAuth.PERMANENT_LOCKOUT_DURATION) {
+ Logger.info('the authentication of given authType is permanent locked');
+ }
+ const authLockStateContent : string = JSON.stringify(authLockState);
+ Logger.info(`get auth lock state success, authLockState is: ${authLockStateContent}`);
+ return authLockStateContent;
+ } catch (error) {
+ const errorMessage : string = `get auth lock state failed, err code is : ${error?.code}, err message is : ${error?.message}`;
+ Logger.error(errorMessage);
+ return errorMessage;
+ }
+ }
+
+ // [End obtain_auth_lock_state_capabilities]
comprehensiveFeatures() {
let reuseUnlockResult: userAuth.ReuseUnlockResult = {
reuseMode: userAuth.ReuseMode.AUTH_TYPE_RELEVANT,
@@ -806,6 +831,24 @@ struct Index {
}
.tabBar(this.tabBuilder($r('app.string.simulationValidation'), PageIndex.SIMULATION_VALIDATION,
'simulationValidation'))
+
+ TabContent() {
+ Column() {
+ Text($r('app.string.queryAuthLockState'))
+ .width('70%')
+ .textAlign(TextAlign.Center)
+ .fontSize($r('app.float.size_20'))
+ Button($r('app.string.query'))
+ .onClick(() => {
+ this.obtainingAuthLockState().then((result : string) => {
+ this.authLockStateContent = result;
+ })
+ })
+ Text(this.authLockStateContent)
+ .fontSize($r('app.float.size_40'))
+ .textAlign(TextAlign.Center)
+ }
+ }.tabBar(this.tabBuilder($r('app.string.queryAuthLockStateTitle'), PageIndex.AUTH_LOCK_STATE_QUERIES, 'queryAuthLockState'))
}
.vertical(false)
.barMode(BarMode.Fixed)
diff --git a/UserAuthentication/entry/src/main/ets/pages/testPage.ets b/UserAuthentication/entry/src/main/ets/pages/testPage.ets
index 121b3a584a712d84e404cde04311d5d61f158734..0a41c8cf174dd1bad1eb82b7392f17c3c3ac202a 100644
--- a/UserAuthentication/entry/src/main/ets/pages/testPage.ets
+++ b/UserAuthentication/entry/src/main/ets/pages/testPage.ets
@@ -437,6 +437,27 @@ function obtainingEnrolledCredentialInformation() {
}
}
+/*
+ * obtain-enrolled-state-capabilities.md
+ * 以查询用户PIN码认证类型的认证冻结状态为例
+ * */
+async function obtainingAuthLockState() : Promise {
+ try {
+ Logger.info(`get auth lock state start`);
+ const authLockState : userAuth.AuthLockState = await userAuth.getAuthLockState(userAuth.UserAuthType.PIN);
+ if (authLockState.lockoutDuration === userAuth.PERMANENT_LOCKOUT_DURATION) {
+ Logger.info('the authentication of given authType is permanent locked');
+ }
+ const authLockStateContent : string = JSON.stringify(authLockState);
+ Logger.info(`get auth lock state success, authLockState is: ${authLockStateContent}`);
+ return authLockStateContent;
+ } catch (error) {
+ const errorMessage : string = `get auth lock state failed, err code is : ${error?.code}, err message is : ${error?.message}`;
+ Logger.error(errorMessage);
+ return errorMessage;
+ }
+}
+
async function comprehensiveFeatures() {
let reuseUnlockResult: userAuth.ReuseUnlockResult = {
reuseMode: userAuth.ReuseMode.AUTH_TYPE_RELEVANT,
@@ -478,7 +499,8 @@ enum PageIndex {
EXAMPLE_TAB_3 = 3, // 实例3页面的索引值
EXAMPLE_TAB_4 = 4, // 实例4页面的索引值
CREDENTIAL_QUERIES = 5, // 能力查询页面的索引值
- SIMULATION_VALIDATION = 6 // 模拟认证页面的索引值
+ SIMULATION_VALIDATION = 6, // 模拟认证页面的索引值
+ AUTH_LOCK_STATE_QUERIES = 7,
}
enum TextIdIndex {
@@ -500,6 +522,7 @@ struct Index {
@State credentialDigest: string = '';
@State whetherSupport: Resource = $r('app.string.waitQuery');
@State credentialValue: string = '';
+ @State authLockStateContent : string = '';
SPACE_GAP: number = 5;
@Builder
@@ -753,6 +776,24 @@ struct Index {
}
.tabBar(this.tabBuilder($r('app.string.simulationValidation'), PageIndex.SIMULATION_VALIDATION,
'simulationValidation'))
+
+ TabContent() {
+ Column() {
+ Text($r('app.string.queryAuthLockState'))
+ .width('70%')
+ .textAlign(TextAlign.Center)
+ .fontSize($r('app.float.size_20'))
+ Button($r('app.string.query'))
+ .onClick(() => {
+ obtainingAuthLockState().then((result : string) => {
+ this.authLockStateContent = result;
+ })
+ })
+ Text(this.authLockStateContent)
+ .fontSize($r('app.float.size_40'))
+ .textAlign(TextAlign.Center)
+ }
+ }.tabBar(this.tabBuilder($r('app.string.queryAuthLockStateTitle'), PageIndex.AUTH_LOCK_STATE_QUERIES, 'queryAuthLockState'))
}
.vertical(false)
.barMode(BarMode.Fixed)
diff --git a/UserAuthentication/entry/src/main/resources/base/element/string.json b/UserAuthentication/entry/src/main/resources/base/element/string.json
index 8b63d0ea9fe9d01224ffe2b56a2c6313f3faec8c..1b7dfbcc2b9a09b06918e2b06b9bd038354002b4 100644
--- a/UserAuthentication/entry/src/main/resources/base/element/string.json
+++ b/UserAuthentication/entry/src/main/resources/base/element/string.json
@@ -64,6 +64,14 @@
"name": "queryCredentials",
"value": "Query the status of the user's registration credentials, and when the authentication method is disabled and then enabled, the query credentials will change again"
},
+ {
+ "name": "queryAuthLockState",
+ "value": "Retrieve the lock status of the specified authentication type, including current lock status, remaining retry attempts, and lockout duration"
+ },
+ {
+ "name": "queryAuthLockStateTitle",
+ "value": "Query auth lock state"
+ },
{
"name": "customLogin",
"value": "Impersonate a custom login"
diff --git a/UserAuthentication/entry/src/main/resources/zh_CN/element/string.json b/UserAuthentication/entry/src/main/resources/zh_CN/element/string.json
index 3cf58f08a4ced6545b498eb7c7cd68d85976436f..a11b384468cb8ff59e0599059f0f63638a71a13f 100644
--- a/UserAuthentication/entry/src/main/resources/zh_CN/element/string.json
+++ b/UserAuthentication/entry/src/main/resources/zh_CN/element/string.json
@@ -64,6 +64,14 @@
"name": "queryCredentials",
"value": "查询用户注册凭据的状态,当认证方式被关闭再开启后,再次查询凭据会变化"
},
+ {
+ "name": "queryAuthLockStateTitle",
+ "value": "查询认证冻结状态"
+ },
+ {
+ "name": "queryAuthLockState",
+ "value": "查询认证冻结状态,包含了认证类型是否被锁定,未锁定时的剩余可尝试次数以及锁定时的冻结时间。"
+ },
{
"name": "customLogin",
"value": "模拟自定义登录"
diff --git a/UserAuthentication/screenshots/example1.jpeg b/UserAuthentication/screenshots/example1.jpeg
deleted file mode 100644
index 27155f76abedf3fbc505523ea7580c02791c3e25..0000000000000000000000000000000000000000
Binary files a/UserAuthentication/screenshots/example1.jpeg and /dev/null differ
diff --git a/UserAuthentication/screenshots/example1.jpg b/UserAuthentication/screenshots/example1.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..54d7119f4af201a21e9e5338d92c96901a523041
Binary files /dev/null and b/UserAuthentication/screenshots/example1.jpg differ
diff --git a/UserAuthentication/screenshots/mockLogin.jpeg b/UserAuthentication/screenshots/mockLogin.jpeg
deleted file mode 100644
index baf5322b0977ce641e70962272eddc7cd2e562e1..0000000000000000000000000000000000000000
Binary files a/UserAuthentication/screenshots/mockLogin.jpeg and /dev/null differ
diff --git a/UserAuthentication/screenshots/mockLogin.jpg b/UserAuthentication/screenshots/mockLogin.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..de9a5e8c00156243353fe672015ffd9bc79d646d
Binary files /dev/null and b/UserAuthentication/screenshots/mockLogin.jpg differ
diff --git a/UserAuthentication/screenshots/query.jpeg b/UserAuthentication/screenshots/query.jpeg
deleted file mode 100644
index f804373a9ad7463e9315e0eb2f9004091517844b..0000000000000000000000000000000000000000
Binary files a/UserAuthentication/screenshots/query.jpeg and /dev/null differ
diff --git a/UserAuthentication/screenshots/query.jpg b/UserAuthentication/screenshots/query.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..a2db50f9575c5fb1082758189f226b3e3ce8f198
Binary files /dev/null and b/UserAuthentication/screenshots/query.jpg differ