提交 7a9e8b0d 编写于 作者: J jidong

add account changelogs and modify account docs

Signed-off-by: Njidong <jidong4@huawei.com>
Change-Id: I0e663c0a600d45b0df94e867d642e958d32394c8
上级 0ea71d88
...@@ -2130,7 +2130,7 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback ...@@ -2130,7 +2130,7 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback
| -------- | ------------------------- | ---- | ------------ | | -------- | ------------------------- | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 | | localId | number | 是 | 系统帐号ID。 |
| photo | string | 是 | 头像信息。 | | photo | string | 是 | 头像信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。如果设置成功,err为null,否则为错误对象。 |
**错误码:** **错误码:**
...@@ -3985,7 +3985,7 @@ getProperty(request: GetPropertyRequest): Promise&lt;ExecutorProperty&gt;; ...@@ -3985,7 +3985,7 @@ getProperty(request: GetPropertyRequest): Promise&lt;ExecutorProperty&gt;;
### setProperty<sup>8+</sup> ### setProperty<sup>8+</sup>
setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;): void; setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;void&gt;): void;
设置可用于初始化算法的属性。使用callback异步回调。 设置可用于初始化算法的属性。使用callback异步回调。
...@@ -4000,7 +4000,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;): ...@@ -4000,7 +4000,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- | | -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- |
| request | [SetPropertyRequest](#setpropertyrequest8)| 是 | 请求信息,包括认证类型和要设置的密钥值。 | | request | [SetPropertyRequest](#setpropertyrequest8)| 是 | 请求信息,包括认证类型和要设置的密钥值。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数。如果设置成功,err为null,data为一个[数值](#resultcode8),指示属性设置是否成功;否则为错误对象。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。如果设置成功,err为null,否则为错误对象。 |
**错误码:** **错误码:**
...@@ -4018,9 +4018,12 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;): ...@@ -4018,9 +4018,12 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;):
setInfo: new Uint8Array([0]) setInfo: new Uint8Array([0])
}; };
try { try {
userAuth.setProperty(request, (err, result) => { userAuth.setProperty(request, (err) => {
console.log('setProperty error = ' + JSON.stringify(err)); if (err) {
console.log('setProperty result = ' + JSON.stringify(result)); console.log('setProperty failed, error = ' + JSON.stringify(err));
} else {
console.log('setProperty successfully');
}
}); });
} catch (e) { } catch (e) {
console.log('setProperty exception = ' + JSON.stringify(e)); console.log('setProperty exception = ' + JSON.stringify(e));
...@@ -4029,7 +4032,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;): ...@@ -4029,7 +4032,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;):
### setProperty<sup>8+</sup> ### setProperty<sup>8+</sup>
setProperty(request: SetPropertyRequest): Promise&lt;number&gt;; setProperty(request: SetPropertyRequest): Promise&lt;void&gt;;
设置可用于初始化算法的属性。使用Promise异步回调。 设置可用于初始化算法的属性。使用Promise异步回调。
...@@ -4049,7 +4052,7 @@ setProperty(request: SetPropertyRequest): Promise&lt;number&gt;; ...@@ -4049,7 +4052,7 @@ setProperty(request: SetPropertyRequest): Promise&lt;number&gt;;
| 类型 | 说明 | | 类型 | 说明 |
| :-------------------- | :------------------------------------------------------------ | | :-------------------- | :------------------------------------------------------------ |
| Promise&lt;number&gt; | Promise对象,返回一个[数值](#resultcode8),指示属性设置是否成功。 | | Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
**错误码:** **错误码:**
...@@ -4067,10 +4070,10 @@ setProperty(request: SetPropertyRequest): Promise&lt;number&gt;; ...@@ -4067,10 +4070,10 @@ setProperty(request: SetPropertyRequest): Promise&lt;number&gt;;
setInfo: new Uint8Array([0]) setInfo: new Uint8Array([0])
}; };
try { try {
userAuth.setProperty(request).then((result) => { userAuth.setProperty(request).then(() => {
console.log('setProperty result = ' + JSON.stringify(result)); console.log('setProperty successfully');
}).catch((err) => { }).catch((err) => {
console.log('setProperty error = ' + JSON.stringify(err)); console.log('setProperty failed, error = ' + JSON.stringify(err));
}); });
} catch (e) { } catch (e) {
console.log('setProperty exception = ' + JSON.stringify(e)); console.log('setProperty exception = ' + JSON.stringify(e));
......
# 帐号子系统ChangeLog
## cl.account_os_account.1 帐号SystemAPI错误信息返回方式变更
已发布的部分帐号SystemAPI使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更:
异步接口:通过AsyncCallback或Promise的error对象返回错误信息。
同步接口:通过抛出异常的方式返回错误信息。
**变更影响**
基于此前版本开发的应用,需适配变更接口的错误信息返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
变更前:
- class UserAuth
- setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;): void;
- setProperty(request: SetPropertyRequest): Promise&lt;number&gt;;
- cancelAuth(contextID: Uint8Array): number;
- class PINAuth
- registerInputer(inputer: Inputer): boolean;
- UserIdentityManager
- cancel(challenge: Uint8Array): number;
变更后:
- class UserAuth
- setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;void&gt;): void;
- setProperty(request: SetPropertyRequest): Promise&lt;void&gt;;
- cancelAuth(contextID: Uint8Array): void;
- class PINAuth
- registerInputer(inputer: Inputer): void;
- UserIdentityManager
- cancel(challenge: Uint8Array): void;
**适配指导**
异步接口以setProperty为例,示例代码如下:
```
import account_osAccount from "@ohos.account.osAccount"
userAuth.setProperty({
authType: account_osAccount.AuthType.PIN,
key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
setInfo: new Uint8Array([0])
}, (err) => {
if (err) {
console.log("setProperty failed, error: " + JSON.stringify(err));
} else {
console.log("setProperty successfully");
}
});
userAuth.setProperty({
authType: account_osAccount.AuthType.PIN,
key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
setInfo: new Uint8Array([0])
}).catch((err) => {
if (err) {
console.log("setProperty failed, error: " + JSON.stringify(err));
} else {
console.log("setProperty successfully");
}
});
```
同步接口以registerInputer为例,示例代码如下:
```
import account_osAccount from "@ohos.account.osAccount"
let pinAuth = new account_osAccount.PINAuth()
let inputer = {
onGetData: (authType, passwordRecipient) => {
let password = new Uint8Array([0]);
passwordRecipient.onSetData(authType, password);
}
}
try {
pinAuth.registerInputer(inputer);
} catch (err) {
console.log("registerInputer failed, error: " + JSON.stringify(err));
}
```
## cl.account_os_account.2 应用帐号鉴权服务ACTION定义变更
**变更影响**
基于此前版本开发的应用,需适配修改应用配置文件(FA模型为config.json或Stage模型为module.json5)中的ACTION才能正常对外提供应用鉴权服务。
**关键接口/组件变更**
涉及的常量:
@ohos.ability.wantConstant.ACTION_APP_ACCOUNT_AUTH
变更前:
ACTION_APP_ACCOUNT_AUTH = "account.appAccount.action.auth"
变更后:
ACTION_APP_ACCOUNT_AUTH = "ohos.appAccount.action.auth"
**适配指导**
提供应用帐号鉴权服务的三方应用,需要在相关ServiceAbility的配置文件(FA模型为config.json或Stage模型为module.json5)中适配变更后的应用帐号认证ACTION,示例如下:
```
"abilities": [
{
"name": "ServiceAbility",
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
...
"visible": true,
"skills": {
{
"actions": [
"ohos.appAccount.action.auth"
]
}
}
}]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册