帐号子系统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>;

适配指导

import account_osAccount from "@ohos.account.osAccount"

let accountMgr = account_osAccount.getAccountManager();
accountMgr.createOsAccount("account_test", account_osAccount.OsAccountType.GUEST).then((accountInfo) => {
  if (accountInfo.type == account_osAccount.OsAccountType.GUEST) {
    console.log("createOsAccount successfully");
  }
  accountMgr.activateOsAccount(accountInfo.localId).then(() => {
    console.log("activateOsAccount successfully");
    accountMgr.getOsAccountTypeFromProcess().then((accountType) => {
      if (accountType == account_osAccount.OsAccountType.GUEST) {
        console.log("getOsAccountTypeFromProcess successfully");
      }
    }).catch((err) => {
      console.log("activateOsAccount err: " + JSON.stringify(err));
    });
  }).catch((err) => {
    console.log("activateOsAccount err: " + JSON.stringify(err));
  });
}).catch((err) => {
  console.log("createOsAccount err: " + JSON.stringify(err));
});