openharmony 鸿蒙 changelogs-account_os_account

2022-12-05 浏览 (1144)

帐号子系统ChangeLog

cl.account_os_account.1 帐号SystemAPI错误信息返回方式变更

已发布的部分帐号SystemAPI使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更:

异步接口:通过AsyncCallback或Promise的error对象返回错误信息。

同步接口:通过抛出异常的方式返回错误信息。

变更影响

基于此前版本开发的应用,需适配变更接口的错误信息返回方式,否则会影响原有业务逻辑。

关键接口/组件变更

变更前:

  • class UserAuth
    • setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void;
    • setProperty(request: SetPropertyRequest): Promise<number>;
    • cancelAuth(contextID: Uint8Array): number;
  • class PINAuth
    • registerInputer(inputer: Inputer): boolean;
  • UserIdentityManager
    • cancel(challenge: Uint8Array): number;

变更后:

  • class UserAuth
    • setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): void;
    • setProperty(request: SetPropertyRequest): Promise<void>;
    • cancelAuth(contextID: Uint8Array): void;
  • class PINAuth
    • registerInputer(inputer: Inputer): void;
  • UserIdentityManager
    • cancel(challenge: Uint8Array): void;

适配指导

异步接口以setProperty为例,示例代码如下:

import account_osAccount from "@ohos.account.osAccount"
userAuth.setProperty({
    authType: account_osAccount.AuthType.PIN,
    key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
    setInfo: new Uint8Array([0])
}, (err) => {
    if (err) {
        console.log("setProperty failed, error: " + JSON.stringify(err));
    } else {
        console.log("setProperty successfully");
    }
});

userAuth.setProperty({
    authType: account_osAccount.AuthType.PIN,
    key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
    setInfo: new Uint8Array([0])
}).catch((err) => {
    if (err) {
        console.log("setProperty failed, error: " + JSON.stringify(err));
    } else {
        console.log("setProperty successfully");
    }
});

同步接口以registerInputer为例,示例代码如下:

import account_osAccount from "@ohos.account.osAccount"
let pinAuth = new account_osAccount.PINAuth()
let inputer = {
    onGetData: (authType, passwordRecipient) => {
        let password = new Uint8Array([0]);
        passwordRecipient.onSetData(authType, password);
    }
}
try {
    pinAuth.registerInputer(inputer);
} catch (err) {
    console.log("registerInputer failed, error: " + JSON.stringify(err));
}

cl.account_os_account.2 应用帐号鉴权服务ACTION定义变更

变更影响

基于此前版本开发的应用,需适配修改应用配置文件(FA模型为config.json或Stage模型为module.json5)中的ACTION才能正常对外提供应用鉴权服务。

关键接口/组件变更

涉及的常量:

@ohos.ability.wantConstant.ACTION_APP_ACCOUNT_AUTH

变更前:

ACTION_APP_ACCOUNT_AUTH = "account.appAccount.action.auth"

变更后:

ACTION_APP_ACCOUNT_AUTH = "ohos.appAccount.action.auth"

适配指导

提供应用帐号鉴权服务的三方应用,需要在相关ServiceAbility的配置文件(FA模型为config.json或Stage模型为module.json5)中适配变更后的应用帐号认证ACTION,示例如下:

"abilities": [
    {
        "name": "ServiceAbility",
        "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
        ...
        "visible": true,
        "skills": {
            {
                "actions": [
                    "ohos.appAccount.action.auth"
                ]
            }
        }
    }]
}

## 你可能感兴趣的鸿蒙文章

[harmony 鸿蒙分布式调度子系统ChangeLog](/blog/5e539a30865e43c297381f0733c784e4) 

[harmony 鸿蒙基础通信WIFI子系统ChangeLog](/blog/02edde1405234614a3ed33068cb9d779) 

[harmony 鸿蒙元能力子系统ChangeLog](/blog/8ba20a1b731947dc84cbc89e061b9418) 

[harmony 鸿蒙定制子系统ChangeLog](/blog/046cf60ec20f4751908c0c1f97c0624c) 

[harmony 鸿蒙位置服务子系统ChangeLog](/blog/7863e6a86604455cb92e6c4a16d2f88b) 

[harmony 鸿蒙多媒体子系统ChangeLog](/blog/8c46897d7c784a8c9448bbd933e562ee) 

[harmony 鸿蒙事件通知子系统ChangeLog](/blog/5ddfcd09e70d4402ad317b0c1fe58ddd) 

[harmony 鸿蒙用户IAM子系统Changelog](/blog/685e1dcb4b864785892f01232053ba8a) 

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/815d469a363949da93e42f02221f73ee