1# Account Subsystem Changelog 2 3## cl.account_os_account.1 createOsAccountForDomain Error Code Change 4 5Changed the error code returned when the domain account created by **createOsAccountForDomain()** already exists from **12300001** to **12300004**. 6Changed the error information from "common system error" to "The account already exists". 7 8**Change Impact** 9 10The application developed based on earlier versions needs to adapt the new error code. Otherwise, the original service logic will be affected. 11 12**Key API/Component Changes** 13- AccountManager 14 - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>); 15 - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo>; 16 17**Adaptation Guide** 18 19The sample code is as follows: 20 21```ts 22import account_osAccount from "@ohos.account.osAccount" 23 24let accountMgr = account_osAccount.getAccountManager(); 25let domainInfo = { 26 accountName: "zhangsan", 27 domain: "china.example.com" 28}; 29try { 30 await accountMgr.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo); 31 await accountMgr.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo); 32} catch (err) { 33 console.log("activateOsAccount err: " + JSON.stringify(err)); // error.code = 12300004; 34} 35``` 36 37## cl.account_os_account.2 App Account getAllAccounts() Permission Change 38 39Removed the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission that is originally required for an application to call **getAllAccounts()** to obtain accessible accounts. 40 41**Change Impact** 42 43From this version, applications do not need the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission when calling **getAllAccounts()**. 44 45**Key API/Component Changes** 46- AccountManager 47 - getAllAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void; 48 - getAllAccounts(): Promise<Array<AppAccountInfo>>; 49 50**Adaptation Guide** 51 52The following is the sample code for an application to obtain the accessible accounts without the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission: 53 54```ts 55import account_appAccount from "@ohos.account.appAccount" 56 57let accountMgr = account_appAccount.createAppAccountManager(); 58try { 59 await accountMgr.addAccount("accessibleAccount_promise_nopermission"); 60 var data = await accountMgr.getAllAccounts(); 61 if (data[0].name == "accessibleAccount_promise_nopermission") { 62 console.log("getAllAccounts successfully"); 63 } 64} catch (err) { 65 console.log("getAllAccounts err: " + JSON.stringify(err)); 66} 67``` 68 69## cl.account_os_account.3 App Account getAccountsByOwner() Permission Change 70 71Removed the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission that is originally required for an application to call **getAccountsByOwner()** to obtain the accessible accounts based on the account owner . 72 73**Change Impact** 74 75From this version, applications do not need the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission when calling **getAccountsByOwner()**. 76 77**Key API/Component Changes** 78- AccountManager 79 - getAccountsByOwner(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void; 80 - getAccountsByOwner(owner: string): Promise<Array<AppAccountInfo>>; 81 82**Adaptation Guide** 83 84The following is the sample code for an application to obtain the accessible accounts based on the account owner without the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission: 85 86```ts 87import account_appAccount from "@ohos.account.appAccount" 88 89let accountMgr = account_appAccount.createAppAccountManager(); 90try { 91 var ownerName = "com.example.owner"; 92 var data = await accountMgr.getAllAccounts(ownerName); 93} catch (err) { 94 console.log("getAllAccounts err: " + JSON.stringify(err)); 95} 96``` 97