• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 帐号子系统changeLog
2
3## cl.account_os_account.1 变更错误码定义及其返回方式
4
5针对帐号子系统API存在错误码定义不统一和抛出方式不符合OpenHarmony错误码规范的问题,从API9开始作以下变更:
6
7- 新增统一的错误码定义:
8  [帐号公共错误码](../../../application-dev/reference/errorcodes/errorcode-account.md)
9
10- 按以下方式返回错误码:
11  - 异步接口:错误信息通过AsyncCallback或Promise的error对象返回。其中,参数类型和数量错误信息,通过抛出异常的方式返回。
12  - 同步接口:错误信息通过抛出异常的方式返回。
13
14**变更影响**
15
16基于此前版本开发的应用,需适配变更后的新错误码和错误信息返回方式,否则会影响原有业务逻辑。
17
18**关键接口/组件变更**
19
20以下接口涉及新错误码和错误信息返回方式变更:
21  - class AccountManager
22    - activateOsAccount(localId: number, callback: AsyncCallback<void>): void;
23    - removeOsAccount(localId: number, callback: AsyncCallback<void>): void;
24    - setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean, callback: AsyncCallback<void>): void;
25    - setOsAccountName(localId: number, localName: string, callback: AsyncCallback<void>): void;
26    - queryMaxOsAccountNumber(callback: AsyncCallback<number>): void;
27    - queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>>): void;
28    - createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback<OsAccountInfo>): void;
29    - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void;
30    - queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>): void;
31    - getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>): void;
32    - setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback<void>): void;
33    - on(type: 'activate' | 'activating', name: string, callback: Callback<number>): void;
34    - off(type: 'activate' | 'activating', name: string, callback?: Callback<number>): void;
35    - isMainOsAccount(callback: AsyncCallback<boolean>): void;
36    - queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback<Array<ConstraintSourceTypeInfo>>): void;
37  - class UserAuth
38    - constructor();
39    - getVersion(): number;
40    - getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number;
41    - getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProperty>): void;
42    - setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void;
43    - auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
44    - authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
45    - cancelAuth(contextID: Uint8Array): number;
46  - class PINAuth
47    - constructor();
48    - registerInputer(inputer: IInputer): boolean;
49    - unregisterInputer(authType: AuthType): void;
50  - class UserIdentityManager
51    - constructor();
52    - openSession(callback: AsyncCallback<Uint8Array>): void;
53    - addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
54    - updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
55    - closeSession(): void;
56    - cancel(challenge: Uint8Array): number;
57    - delUser(token: Uint8Array, callback: IIdmCallback): void;
58    - delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void;
59    - getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void;
60  - interface IInputData
61    - onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
62
63**适配指导**
64
65异步接口的错误信息处理逻辑以activateOsAccount为例,示例代码如下:
66
67```ts
68import account_osAccount from "@ohos.account.osAccount"
69let accountMgr = account_osAccount.getAccountManager()
70let callbackFunc = (err) => {
71  if (err != null) {  // handle the bussiness error
72    console.log("account_osAccount failed, error: " + JSON.stringify(err));
73  } else {
74    console.log("account_osAccount successfully");
75  }
76}
77try {
78  accountMgr.activateOsAccount("100", callbackFunc);
79} catch (err) {  // handle the parameter type error
80  console.log("account_osAccount failed for incorrect parameter type, error: " + JSON.stringify(err));
81}
82try {
83  accountMgr.activateOsAccount();
84} catch (err) {  // handle the parameter number error
85  console.log("account_osAccount failed for incorrect parameter number, error: " + JSON.stringify(err));
86}
87```
88
89同步接口的错误信息处理以registerInputer为例,示例代码如下:
90
91```ts
92import account_osAccount from "@ohos.account.osAccount"
93let pinAuth = new account_osAccount.PINAuth()
94try {
95    pinAuth.registerInputer({})
96} catch (err) {  // handle the parameter type error
97  console.log("account_osAccount failed for incorrect parameter type, error: " + JSON.stringify(err));
98}
99try {
100    pinAuth.registerInputer()
101} catch (err) {  // handle the parameter number error
102  console.log("account_osAccount failed for incorrect parameter number, error: " + JSON.stringify(err));
103}
104```
105
106# 帐号子系统ChangeLog
107
108## cl.account_os_account.2 帐号SystemAPI错误信息返回方式变更
109
110已发布的部分帐号SystemAPI使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更:
111
112异步接口:通过AsyncCallback或Promise的error对象返回错误信息。
113
114同步接口:通过抛出异常的方式返回错误信息。
115
116**变更影响**
117
118基于此前版本开发的应用,需适配变更接口的错误信息返回方式,否则会影响原有业务逻辑。
119
120**关键接口/组件变更**
121
122变更前:
123
124  - class UserAuth
125    - setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void;
126    - setProperty(request: SetPropertyRequest): Promise<number>;
127    - cancelAuth(contextID: Uint8Array): number;
128  - class PINAuth
129    - registerInputer(inputer: Inputer): boolean;
130  - UserIdentityManager
131    - cancel(challenge: Uint8Array): number;
132
133变更后:
134
135  - class UserAuth
136    - setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): void;
137    - setProperty(request: SetPropertyRequest): Promise<void>;
138    - cancelAuth(contextID: Uint8Array): void;
139  - class PINAuth
140    - registerInputer(inputer: Inputer): void;
141  - UserIdentityManager
142    - cancel(challenge: Uint8Array): void;
143
144**适配指导**
145
146异步接口以setProperty为例,示例代码如下:
147
148```
149import account_osAccount from "@ohos.account.osAccount"
150userAuth.setProperty({
151    authType: account_osAccount.AuthType.PIN,
152    key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
153    setInfo: new Uint8Array([0])
154}, (err) => {
155    if (err) {
156        console.log("setProperty failed, error: " + JSON.stringify(err));
157    } else {
158        console.log("setProperty successfully");
159    }
160});
161
162userAuth.setProperty({
163    authType: account_osAccount.AuthType.PIN,
164    key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
165    setInfo: new Uint8Array([0])
166}).catch((err) => {
167    if (err) {
168        console.log("setProperty failed, error: " + JSON.stringify(err));
169    } else {
170        console.log("setProperty successfully");
171    }
172});
173```
174
175同步接口以registerInputer为例,示例代码如下:
176
177```
178import account_osAccount from "@ohos.account.osAccount"
179let pinAuth = new account_osAccount.PINAuth()
180let inputer = {
181    onGetData: (authType, passwordRecipient) => {
182        let password = new Uint8Array([0]);
183        passwordRecipient.onSetData(authType, password);
184    }
185}
186try {
187    pinAuth.registerInputer(inputer);
188} catch (err) {
189    console.log("registerInputer failed, error: " + JSON.stringify(err));
190}
191```
192
193## cl.account_os_account.3 应用帐号鉴权服务ACTION定义变更
194
195**变更影响**
196
197基于此前版本开发的应用,需适配修改应用配置文件(FA模型为config.json或Stage模型为module.json5)中的ACTION才能正常对外提供应用鉴权服务。
198
199**关键接口/组件变更**
200
201涉及的常量:
202
203@ohos.ability.wantConstant.ACTION_APP_ACCOUNT_AUTH
204
205变更前:
206
207ACTION_APP_ACCOUNT_AUTH = "account.appAccount.action.auth"
208
209变更后:
210
211ACTION_APP_ACCOUNT_AUTH = "ohos.appAccount.action.auth"
212
213**适配指导**
214
215提供应用帐号鉴权服务的三方应用,需要在相关ServiceAbility的配置文件(FA模型为config.json或Stage模型为module.json5)中适配变更后的应用帐号认证ACTION,示例如下:
216
217```
218"abilities": [
219    {
220        "name": "ServiceAbility",
221        "srcEnty": "./ets/ServiceAbility/ServiceAbility.ts",
222        ...
223        "visible": true,
224        "skills": {
225            {
226                "actions": [
227                    "ohos.appAccount.action.auth"
228                ]
229            }
230        }
231    }]
232}
233
234```
235