diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-account_os_account.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-account_os_account.md new file mode 100644 index 0000000000000000000000000000000000000000..4ef6169a1e412d95b7ea091c17459ebd2bcc7b44 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-account_os_account.md @@ -0,0 +1,36 @@ +# 帐号子系统changeLog + +## cl.account_os_account.1 createOsAccountForDomain错误码变更 + +使用createOsAccountForDomain重复创建域帐号时,变更前返回的错误码为12300001,变更后返回的错误码为12300004。 +错误信息由通用系统报错细化为帐号已存在报错。 + +**变更影响** + +基于此前版本开发的应用,需适配变更后的错误码,否则会影响原有业务逻辑。 + +**关键接口/组件变更** +- AccountManager + - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>); + - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo>; + +**适配指导** + +重复创建域帐号的示例代码如下: + +```ts +import account_osAccount from "@ohos.account.osAccount" +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +let accountMgr = account_osAccount.getAccountManager(); +let domainInfo = { + accountName: "zhangsan", + domain: "china.example.com" +}; +try { + await accountMgr.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo); + await accountMgr.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo); +} catch (err) { + expect(err.code).assertEqual(12300004); +} +``` diff --git a/zh-cn/release-notes/changelogs/v3.1-Release/changelogs-account_os_account.md b/zh-cn/release-notes/changelogs/v3.1-Release/changelogs-account_os_account.md new file mode 100644 index 0000000000000000000000000000000000000000..b8baef9aa857112649ac8dec9b388be3624f4bd8 --- /dev/null +++ b/zh-cn/release-notes/changelogs/v3.1-Release/changelogs-account_os_account.md @@ -0,0 +1,57 @@ +# 帐号子系统changeLog + +## cl.account_os_account.1 系统帐号OsAccountInfo.type取值类型变更 + +变更前,OsAccountInfo.type取值的实际类型为Object,与d.ts中声明的OsAccountType枚举类型不一致;变更后,OsAccountInfo.type取值的实际类型为OsAccountType枚举。 + +**变更影响** + +基于此前版本开发的应用,需变更OsAccountInfo.type值的读取方式,否则影响原因业务逻辑。 + +**关键接口/组件变更** + +涉及的接口: +- 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>; + +**适配指导** +```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(); +}); +```