1# Account Subsystem ChangeLog 2 3## cl.account_os_account.1 Change of Definition and Return Mode of Error Codes 4 5To solve the issues that error code definitions of the account subsystem APIs were inconsistent and that the return mode of the error codes did not comply with relevant specifications of OpenHarmony, the following changes are made and take effect in API version 9 and later: 6 7- Added the following unified error code definitions: 8 - [Account Error Codes](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/errorcodes/errorcode-account.md) 9 - [App Account Error Codes](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/errorcodes/errorcode-account.md) 10 11- Returned an error code in either of the following ways, according to the API type: 12 - Asynchronous API: An error message is returned via **AsyncCallback** or the **error** object of **Promise**. An error message related to the parameter type or quantity is returned via an exception. 13 - Synchronous API: An error message is returned via an exception. 14 15**Change Impacts** 16 17The application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected. 18 19**Key API/Component Changes** 20 21The mentioned changes involve the following APIs: 22 - class AccountManager 23 - activateOsAccount(localId: number, callback: AsyncCallback<void>): void; 24 - removeOsAccount(localId: number, callback: AsyncCallback<void>): void; 25 - setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean, callback: AsyncCallback<void>): void; 26 - setOsAccountName(localId: number, localName: string, callback: AsyncCallback<void>): void; 27 - queryMaxOsAccountNumber(callback: AsyncCallback<number>): void; 28 - queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>>): void; 29 - createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback<OsAccountInfo>): void; 30 - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void; 31 - queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>): void; 32 - getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>): void; 33 - setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback<void>): void; 34 - on(type: 'activate' | 'activating', name: string, callback: Callback<number>): void; 35 - off(type: 'activate' | 'activating', name: string, callback?: Callback<number>): void; 36 - isMainOsAccount(callback: AsyncCallback<boolean>): void; 37 - queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback<Array<ConstraintSourceTypeInfo>>): void; 38 - class UserAuth 39 - constructor(); 40 - getVersion(): number; 41 - getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number; 42 - getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProperty>): void; 43 - setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void; 44 - auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; 45 - authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; 46 - cancelAuth(contextID: Uint8Array): number; 47 - class PINAuth 48 - constructor(); 49 - registerInputer(inputer: IInputer): boolean; 50 - unregisterInputer(authType: AuthType): void; 51 - class UserIdentityManager 52 - constructor(); 53 - openSession(callback: AsyncCallback<Uint8Array>): void; 54 - addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; 55 - updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; 56 - closeSession(): void; 57 - cancel(challenge: Uint8Array): number; 58 - delUser(token: Uint8Array, callback: IIdmCallback): void; 59 - delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void; 60 - getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void; 61 - interface IInputData 62 - onSetData: (authSubType: AuthSubType, data: Uint8Array) => void; 63 64**Adaptation Guide** 65 66The following uses **activateOsAccount** as an example to illustrate the error information processing logic of an asynchronous API: 67 68```ts 69import account_osAccount from "@ohos.account.osAccount" 70let accountMgr = account_osAccount.getAccountManager() 71let callbackFunc = (err) => { 72 if (err != null) { // Handle the business error. 73 console.log("account_osAccount failed, error: " + JSON.stringify(err)); 74 } else { 75 console.log("account_osAccount successfully"); 76 } 77} 78try { 79 accountMgr.activateOsAccount("100", callbackFunc); 80} catch (err) { // Process the error that is related to the parameter type. 81 console.log("account_osAccount failed for incorrect parameter type, error: " + JSON.stringify(err)); 82} 83try { 84 accountMgr.activateOsAccount(); 85} catch (err) { // Process the error that is related to the parameter quantity. 86 console.log("account_osAccount failed for incorrect parameter number, error: " + JSON.stringify(err)); 87} 88``` 89 90The following uses **registerInputer** as an example to illustrate the error information processing logic of a synchronous API: 91 92```ts 93import account_osAccount from "@ohos.account.osAccount" 94let pinAuth = new account_osAccount.PINAuth() 95try { 96 pinAuth.registerInputer({}) 97} catch (err) { // Process the error that is related to the parameter type. 98 console.log("account_osAccount failed for incorrect parameter type, error: " + JSON.stringify(err)); 99} 100try { 101 pinAuth.registerInputer() 102} catch (err) { // Process the error that is related to the parameter quantity. 103 console.log("account_osAccount failed for incorrect parameter number, error: " + JSON.stringify(err)); 104} 105``` 106