未验证 提交 364dace6 编写于 作者: O openharmony_ci 提交者: Gitee

!14383 [翻译完成】#I6AIRI

Merge pull request !14383 from Annie_wang/PR13319
# 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();
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册