diff --git a/en/release-notes/changelogs/v3.1-Release/changelogs-account_os_account.md b/en/release-notes/changelogs/v3.1-Release/changelogs-account_os_account.md new file mode 100644 index 0000000000000000000000000000000000000000..1eb84215498004fe05d46715ac02236ee28d5e58 --- /dev/null +++ b/en/release-notes/changelogs/v3.1-Release/changelogs-account_os_account.md @@ -0,0 +1,57 @@ +# Account Subsystem ChangeLog + +## cl.account_os_account.1 OsAccountInfo.type Value Type Change + +Changed the value type of **OsAccountInfo.type** from **Object** to **OsAccountType** enumeration. + +**Change Impacts** + +The mode for reading the **OsAccountInfo.type** value needs to be changed for the application developed based on earlier versions. Otherwise, the original service logic will be affected. + +**Key API/Component Changes** + +The following APIs are involved: +- AccountManager + - queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>>): void; + - queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>>; + - createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback<OsAccountInfo>): void; + - createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInfo>; + - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void; + - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo>; + - queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void; + - queryCurrentOsAccount(): Promise<OsAccountInfo>; + - getCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void; + - getCurrentOsAccount(): Promise<OsAccountInfo>; + - queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>): void; + - queryOsAccountById(localId: number): Promise<OsAccountInfo>; + + - getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void; + - getOsAccountTypeFromProcess(): Promise<OsAccountType>; + - getOsAccountType(callback: AsyncCallback<OsAccountType>): void; + - getOsAccountType(): Promise<OsAccountType>; + +**Adaptation Guide** +```ts +import account_osAccount from "@ohos.account.osAccount" +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +let accountMgr = account_osAccount.getAccountManager(); +accountMgr.createOsAccount('account_test', account_osAccount.OsAccountType.GUEST).then((accountInfo) => { + expect(accountInfo.type).assertEqual(account_osAccount.OsAccountType.GUEST); + accountMgr.activateOsAccount(accountInfo.localId).then(() => { + console.log('activateOsAccount successfully'); + accountMgr.getOsAccountTypeFromProcess().then((accountType) => { + expect(accountType).assertEqual(account_osAccount.OsAccountType.GUEST); + }).catch((err) => { + console.log('activateOsAccount err: ' + JSON.stringify(err)); + expect().assertFail(); + }); + }).catch((err) => { + console.log('activateOsAccount err: ' + JSON.stringify(err)); + expect().assertFail(); + }); +}).catch((err) => { + console.log('createOsAccount err: ' + JSON.stringify(err)); + expect().assertFail(); +}); +```