未验证 提交 4e63ecc0 编写于 作者: O openharmony_ci 提交者: Gitee

!15114 修改changelog目录

Merge pull request !15114 from ningning/OpenHarmony-3.2-Beta5
# 分布式调度子系统ChangeLog
## cl.DistributedManagerService.1 continuationManager事件监听接口on/off变更
- continuationManager事件监听接口on/off传入的参数事件类型名,命名不符合OpenHarmony的API接口规范。
- continuationManager.on对于不同的事件接口返回值未进行统一,不符合OpenHarmony的API接口规范。
已做出以下变更:
- continuationManager.on和continuationManager.off的设备选择事件名由原来的"deviceConnect"变更为"deviceSelected",设备取消选择事件名由原来的"deviceDisconnect"变更为"deviceUnselected"。
- continuationManager.on对于不同事件统一callback返回值类型"Callback<Array<ContinuationResult>>"。
**变更影响**
基于此前版本开发的应用,需适配变更接口,否则会影响原有业务逻辑。
**关键的接口/组件变更**
- 涉及接口
continuationManager.on;
continuationManager.off;
- 变更前:
```js
function on(type: "deviceConnect", token: number, callback: Callback<Array<ContinuationResult>>): void;
function off(type: "deviceConnect", token: number): void;
function on(type: "deviceDisconnect", token: number, callback: Callback<Array<string>>): void;
function off(type: "deviceDisconnect", token: number): void;
```
- 变更后:
```js
function on(type: "deviceSelected", token: number, callback: Callback<Array<ContinuationResult>>): void;
function off(type: "deviceSelected", token: number): void;
function on(type: "deviceUnselected", token: number, callback: Callback<Array<ContinuationResult>>): void;
function off(type: "deviceUnselected", token: number): void;
```
**适配指导**
修改事件名称,示例代码如下:
continuationManager.on 设备选择事件
```ts
let token = 1;
try {
continuationManager.on("deviceSelected", token, (data) => {
console.info('onDeviceSelected len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('onDeviceSelected deviceId: ' + JSON.stringify(data[i].id));
console.info('onDeviceSelected deviceType: ' + JSON.stringify(data[i].type));
console.info('onDeviceSelected deviceName: ' + JSON.stringify(data[i].name));
}
});
} catch (err) {
console.error('on failed, cause: ' + JSON.stringify(err));
}
```
continuationManager.off 设备选择事件
```ts
let token = 1;
try {
continuationManager.off("deviceSelected", token);
} catch (err) {
console.error('off failed, cause: ' + JSON.stringify(err));
}
```
continuationManager.on 设备取消选择事件
```ts
let token = 1;
try {
continuationManager.on("deviceUnselected", token, (data) => {
console.info('onDeviceUnselected len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('onDeviceUnselected deviceId: ' + JSON.stringify(data[i].id));
console.info('onDeviceUnselected deviceType: ' + JSON.stringify(data[i].type));
console.info('onDeviceUnselected deviceName: ' + JSON.stringify(data[i].name));
}
console.info('onDeviceUnselected finished.');
});
} catch (err) {
console.error('on failed, cause: ' + JSON.stringify(err));
}
```
continuationManager.off 设备取消选择事件
```ts
let token = 1;
try {
continuationManager.off("deviceUnselected", token);
} catch (err) {
console.error('off failed, cause: ' + JSON.stringify(err));
}
```
## cl.DistributedManagerService.2 continuationManager接口新增DATASYNC权限校验
此前版本continuationManager接口未对调用方进行校验,不符合OpenHarmony的API接口规范。
已做出以下变更:调用方使用continuationManager前需提前申请"ohos.permission.DISTRIBUTED_DATASYNC"权限。
**变更影响**
基于此前版本开发的应用,需提前申请"ohos.permission.DISTRIBUTED_DATASYNC"权限,否则会影响原有业务逻辑。
**关键的接口/组件变更**
涉及接口
- continuationManager.registerContinuation;
- continuationManager.on;
- continuationManager.off;
- continuationManager.unregisterContinuation;
- continuationManager.updateContinuationState;
- continuationManager.startContinuationDeviceManager;
\ No newline at end of file
# web子系统ChangeLog
OpenHarmony 3.2.9.1 sp8版本相较于OpenHarmony 3.2.8.1版本,web的API变更如下
## cl.web.1 删除无用错误码
web子系统webviewController接口存在变更:
- 去除forward,backward和backOrForward接口的@throws { BusinessError } 17100007 - Invalid back or forward operation.
- 去除zoom,zoomIn和zoomOut接口的@throws { BusinessError } 17100009 - Cannot zoom in or zoom out.
开发者需要根据以下说明对应用进行适配。
**变更影响**
影响已发布的JS接口,应用无需进行适配即可在新版本SDK环境正常编译通过。
**关键的接口/组件变更**
涉及接口: forward, backward, backOrForward, zoom, zoomIn, zoomOut;
涉及组件: web;
**适配指导**
无需适配
## cl.web.2 setWebController入参修改
已发布的部分web子系统controller迁移至webviewController,老的webController做废弃处理。从API9开始做出以下变更:
setWebController入参由老controller替换为新的webviewController
**变更影响**
基于此前版本开发的应用,需适配变更js接口的入参,否则会影响原有功能。
**关键的接口/组件变更**
- 涉及接口
setWebController(controller: WebviewController): void;
- 变更前:
```js
setWebController(controller: WebController): void;
```
- 变更后:
```js
setWebController(controller: WebviewController): void;
```
**适配指导**
示例代码如下:
变更前:
```js
// xxx.ets
@Entry
@Component
struct WebComponent {
controller:WebController = new WebController()
build() {
Column() {
Web({ src:'www.example.com', controller: this.controller })
.multiWindowAccess(true)
.onWindowNew((event) => {
console.log("onWindowNew...")
var popController: WebController = new WebController()
event.handler.setWebController(popController)
})
}
}
}
```
变更后:
```js
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src:'www.example.com', controller: this.controller })
.multiWindowAccess(true)
.onWindowNew((event) => {
console.log("onWindowNew...")
var popController: web_webview.WebviewController = new web_webview.WebviewController()
event.handler.setWebController(popController)
})
}
}
}
```
## cl.web.3 getUnfilterendLinkUrl接口名修改
getUnfilterendLinkUrl接口拼写错误,应改为getUnfilteredLinkUrl
**变更影响**
基于此前版本开发的应用,需适配变更js接口名,否则会影响原有功能。
**关键的接口/组件变更**
- 涉及接口
getUnfilteredLinkUrl(): string;
- 变更前:
```js
getUnfilterendLinkUrl(): string;
```
- 变更后:
```js
getUnfilteredLinkUrl(): string;
```
**适配指导**
基于此前版本开发的应用,需适配变更js接口名,使用新的接口名替换旧的接口名,否则会影响原有功能。
\ No newline at end of file
# 基础通信WIFI子系统ChangeLog
## cl.wifi.1 系统API和API9接口迁移到新增的@ohos.wifiManager.d.ts
@ohos.wifi.d.ts接口不支持抛出错误码,而API9以及SystemAPI都需要支持错误码抛出,为支持该功能,将@ohos.wifi.d.ts中的所有SystemAPI以及API9接口迁移到新增的@ohos.wifiManager.d.ts当中,并添加错误码描述。
后续需要import @ohos.wifiManager.d.ts才能够使用wifi的系统API以及API9接口:
import wifiManager from '@ohos.wifiManager';
**变更影响**
仅对系统API以及API9所有接口的使用有影响,需要import @ohos.wifiManager才能使用wifi的系统API和API9接口
import wifiManager from '@ohos.wifiManager';
对于其他接口无影响
**关键的接口/组件变更**
| 类名 | 接口类型 | 接口声明 | 变更类型 |
| -- | -- | -- | -- |
| wifi | namespace | declare namespace wifi | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function enableWifi(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值改为void |
| wifi | method | function disableWifi(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值改为void |
| wifi | method | function scan(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值改为void |
| wifi | method | function getScanResults(): Promise&lt;Array&lt;WifiScanInfo&gt;&gt; | API9接口变更,迁移到@ohos.wifiManager.d.ts,由getScanInfos修改为getScanResults |
| wifi | method | function getScanResults(callback: AsyncCallback&lt;Array&lt;WifiScanInfo&gt;&gt;): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,由getScanInfos修改为getScanResults |
| wifi | method | function getScanResultsSync(): &nbsp;Array&lt;[WifiScanInfo]&gt; | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function addCandidateConfig(config: WifiDeviceConfig): Promise&lt;number&gt; | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback&lt;number&gt;): void | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function removeCandidateConfig(networkId: number): Promise&lt;void&gt; | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function removeCandidateConfig(networkId: number, callback: AsyncCallback&lt;void&gt;): void | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function addUntrustedConfig(config: WifiDeviceConfig): Promise&lt;boolean&gt; | API9接口变更,该接口删除 |
| wifi | method | function addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback&lt;boolean&gt;): void | API9接口变更,该接口删除 |
| wifi | method | function removeUntrustedConfig(config: WifiDeviceConfig): Promise&lt;boolean&gt; | API9接口变更,该接口删除 |
| wifi | method | function removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback&lt;boolean&gt;): void | API9接口变更,该接口删除 |
| wifi | method | function getCandidateConfigs(): &nbsp;Array&lt;[WifiDeviceConfig]&gt; | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function connectToCandidateConfig(networkId: number): void | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function connectToNetwork(networkId: number): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function connectToDevice(config: WifiDeviceConfig): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function disconnect(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function reassociate(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function reconnect(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function disableNetwork(netId: number): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function removeAllNetwork(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function removeDevice(id: number): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function enableHotspot(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function disableHotspot(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function setHotspotConfig(config: HotspotConfig): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function getP2pLocalDevice(): Promise&lt;WifiP2pDevice&gt; | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function getP2pLocalDevice(callback: AsyncCallback&lt;WifiP2pDevice&gt;): void | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function getP2pGroups(): Promise&lt;Array&lt;WifiP2pGroupInfo&gt;&gt; | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function getP2pGroups(callback: AsyncCallback&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;): void | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | method | function createGroup(config: WifiP2PConfig): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function removeGroup(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function p2pConnect(config: WifiP2PConfig): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function p2pCancelConnect(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function startDiscoverDevices(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function stopDiscoverDevices(): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function deletePersistentGroup(netId: number): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | method | function setDeviceName(devName: string): void | API9接口变更,迁移到@ohos.wifiManager.d.ts,返回值修改为void |
| wifi | interface | export interface WifiEapConfig | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | enum | export enum EapMethod | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | enum | export enum Phase2Method | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | interface | export interface WifiDeviceConfig | API9接口变更,迁移到@ohos.wifiManager.d.ts,增加eapConfig参数 |
| wifi | interface | export interface IpConfig | API9接口变更,迁移到@ohos.wifiManager.d.ts,增加prefixLength参数 |
| wifi | interface | export interface WifiInfoElem | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | enum | export enum WifiChannelWidth | API9接口变更,迁移到@ohos.wifiManager.d.ts |
| wifi | interface | export interface WifiScanInfo | API9接口变更,迁移到@ohos.wifiManager.d.ts,增加centerFrequency0、centerFrequency1、infoElems三个参数 |
| wifi | enum | export enum WifiSecurityType | API9接口变更,迁移到@ohos.wifiManager.d.ts,增加4种加密类型 |
| wifi | interface | export interface WifiLinkedInfo | API9接口变更,迁移到@ohos.wifiManager.d.ts,增加MacType参数 |
**适配指导(可选,不涉及则可以删除)**
以getLinkedInfo为例,在新版本中需要使用如下方式进行调用:
```
import wifiManager from '@ohos.wifiManager'
wifiManager.getLinkedInfo((err, data) => {
if (err) {
console.error("get linked info error");
return;
}
console.info("get linked info: " + JSON.stringify(data));
});
wifiManager.getLinkedInfo().then(data => {
console.info("get linked info: " + JSON.stringify(data));
}).catch(error => {
console.info("get linked info error");
});
```
## cl.wifiext.1 系统API和API9接口迁移到新增的@ohos.wifiManagerExt.d.ts
@ohos.wifiext.d.ts接口不支持抛出错误码,而API9以及SystemAPI都需要支持错误码抛出,为支持该功能,将@ohos.wifiext.d.ts中的所有SystemAPI以及API9接口迁移到新增的@ohos.wifiManagerExt.d.ts当中,并添加错误码描述
后续需要import @ohos.wifiManagerExt.d.ts才能够使用wifi的系统API以及API9接口:
import wifiManagerExt from '@ohos.wifiManagerExt';
**变更影响**
仅对系统API以及API9所有接口的使用有影响,需要import @ohos.wifiManagerExt才能使用wifi的系统API和API9接口,与wifiManager配套使用
import wifiManagerExt from '@ohos.wifiManagerExt';
对于其他接口无影响
......@@ -228,7 +228,7 @@
**关键接口/组件变更**
为适配统一的API异常处理方式,对元能力相关接口进行废弃(下表中 原接口 列内容),并新增对应接口(下表中 新接口 列内容)。新增接口支持统一的错误码异常处理规范,功能上与原接口保持一致。
为适配统一的API异常处理方式,对元能力相关接口进行废弃(下表中 原接口 列内容,其中的API9接口将被删除,API8及以前的接口将被标注为废弃),并新增对应接口(下表中 新接口 列内容)。新增接口支持统一的错误码异常处理规范,功能上与原接口保持一致。
| 原接口 | 新接口 |
| ----------------------------------------------- | ----------------------------------------------- |
......
# 帐号子系统changeLog
## cl.account_os_account.1 变更错误码定义及其返回方式
针对帐号子系统API存在错误码定义不统一和抛出方式不符合OpenHarmony错误码规范的问题,从API9开始作以下变更:
- 新增统一的错误码定义:
- [帐号公共错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errorcode-account.md)
- [应用帐号错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errorcode-app-account.md)
- 按以下方式返回错误码:
- 异步接口:错误信息通过AsyncCallback或Promise的error对象返回。其中,参数类型和数量错误信息,通过抛出异常的方式返回。
- 同步接口:错误信息通过抛出异常的方式返回。
**变更影响**
基于此前版本开发的应用,需适配变更后的新错误码和错误信息返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
以下接口涉及新错误码和错误信息返回方式变更:
- class AccountManager
- activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void;
- removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void;
- setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean, callback: AsyncCallback&lt;void&gt;): void;
- setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;void&gt;): void;
- queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void;
- queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&gt;): void;
- createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&lt;OsAccountInfo&gt;): void;
- createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;): void;
- queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;): void;
- getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;): void;
- setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback&lt;void&gt;): void;
- on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&gt;): void;
- off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number&gt;): void;
- isMainOsAccount(callback: AsyncCallback&lt;boolean&gt;): void;
- queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback&lt;Array&lt;ConstraintSourceTypeInfo&gt;&gt;): void;
- class UserAuth
- constructor();
- getVersion(): number;
- getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number;
- getProperty(request: GetPropertyRequest, callback: AsyncCallback&lt;ExecutorProperty&gt;): void;
- setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;): void;
- auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
- authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
- cancelAuth(contextID: Uint8Array): number;
- class PINAuth
- constructor();
- registerInputer(inputer: IInputer): boolean;
- unregisterInputer(authType: AuthType): void;
- class UserIdentityManager
- constructor();
- openSession(callback: AsyncCallback&lt;Uint8Array&gt;): void;
- addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
- updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
- closeSession(): void;
- cancel(challenge: Uint8Array): number;
- delUser(token: Uint8Array, callback: IIdmCallback): void;
- delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void;
- getAuthInfo(callback: AsyncCallback&lt;Array&lt;EnrolledCredInfo&gt;&gt;): void;
- interface IInputData
- onSetData: (authSubType: AuthSubType, data: Uint8Array) =&gt; void;
**适配指导**
异步接口的错误信息处理逻辑以activateOsAccount为例,示例代码如下:
```ts
import account_osAccount from "@ohos.account.osAccount"
let accountMgr = account_osAccount.getAccountManager()
let callbackFunc = (err) => {
if (err != null) { // handle the bussiness error
console.log("account_osAccount failed, error: " + JSON.stringify(err));
} else {
console.log("account_osAccount successfully");
}
}
try {
accountMgr.activateOsAccount("100", callbackFunc);
} catch (err) { // handle the parameter type error
console.log("account_osAccount failed for incorrect parameter type, error: " + JSON.stringify(err));
}
try {
accountMgr.activateOsAccount();
} catch (err) { // handle the parameter number error
console.log("account_osAccount failed for incorrect parameter number, error: " + JSON.stringify(err));
}
```
同步接口的错误信息处理以registerInputer为例,示例代码如下:
```ts
import account_osAccount from "@ohos.account.osAccount"
let pinAuth = new account_osAccount.PINAuth()
try {
pinAuth.registerInputer({})
} catch (err) { // handle the parameter type error
console.log("account_osAccount failed for incorrect parameter type, error: " + JSON.stringify(err));
}
try {
pinAuth.registerInputer()
} catch (err) { // handle the parameter number error
console.log("account_osAccount failed for incorrect parameter number, error: " + JSON.stringify(err));
}
```
# 帐号子系统ChangeLog
## cl.account_os_account.1 帐号SystemAPI错误信息返回方式变更
## cl.account_os_account.2 帐号SystemAPI错误信息返回方式变更
已发布的部分帐号SystemAPI使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更:
......@@ -15,6 +121,7 @@
**关键接口/组件变更**
变更前:
- class UserAuth
- setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;number&gt;): void;
- setProperty(request: SetPropertyRequest): Promise&lt;number&gt;;
......@@ -25,6 +132,7 @@
- cancel(challenge: Uint8Array): number;
变更后:
- class UserAuth
- setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;void&gt;): void;
- setProperty(request: SetPropertyRequest): Promise&lt;void&gt;;
......@@ -83,7 +191,7 @@ try {
}
```
## cl.account_os_account.2 应用帐号鉴权服务ACTION定义变更
## cl.account_os_account.3 应用帐号鉴权服务ACTION定义变更
**变更影响**
......@@ -106,6 +214,7 @@ ACTION_APP_ACCOUNT_AUTH = "ohos.appAccount.action.auth"
**适配指导**
提供应用帐号鉴权服务的三方应用,需要在相关ServiceAbility的配置文件(FA模型为config.json或Stage模型为module.json5)中适配变更后的应用帐号认证ACTION,示例如下:
```
"abilities": [
{
......@@ -122,3 +231,5 @@ ACTION_APP_ACCOUNT_AUTH = "ohos.appAccount.action.auth"
}
}]
}
```
......@@ -65,4 +65,62 @@ ArkUI子系统alertDialog, actionSheet, customDialog组件及prompt, promptActio
**适配指导**
无需适配
\ No newline at end of file
无需适配
## cl.arkui.3 自定义组件成员变量初始化的方式与约束校验场景补全
[自定义组件成员变量初始化规则](../../../application-dev/quick-start/arkts-restrictions-and-extensions.md#自定义组件成员变量初始化的方式与约束)请参考文档,此版本修复了某些遗漏场景的校验。
**变更影响**
如果未按照文档规范,进行自定义组件成员变量初始化赋值,编译报错。
**关键的接口/组件变更**
不涉及。
**适配指导**
按文档提示修改。
## cl.arkui.4 自定义父子组件成员变量赋值约束校验场景补全
[自定义父子组件成员变量赋值规则](../../../application-dev/quick-start/arkts-restrictions-and-extensions.md#自定义组件成员变量初始化的方式与约束)请参考文档,此版本修复了某些遗漏场景的校验。
**变更影响**
如果自定义父子组件成员变量初始化未按照文档规范,编译报错。
**关键的接口/组件变更**
不涉及。
**适配指导**
按文档提示修改,使用其它装饰器变量或常规变量赋值。
## cl.arkui.5 单一子组件校验补全
对 'Button', 'FlowItem','GridItem','GridCol','ListItem','Navigator','Refresh','RichText','ScrollBar','StepperItem','TabContent'等只支持一个子组件的开启校验。
**变更影响**
如果上述组件内有超过一个子组件,编译报错。
**关键的接口/组件变更**
```js
RichText('RichText') {
Text('Text1')
Text('Text2')
}
/* ArkTS:ERROR File: /root/newOH/developtools/ace-ets2bundle/compiler/sample/pages/home.ets:25:7
The component 'RichText' can only have a single child component. */
```
**适配指导**
按报错提示修改,指定组件内只能有一个子组件。
# 设备管理changeLog
## cl.device_manager.1 API错误信息返回方式变更
设备管理接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更:
异步接口:通过AsyncCallback或Promise的error对象返回错误信息。
同步接口:通过抛出异常的方式返回错误信息。
**变更影响**
基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
在以下接口增加错误码处理:
- createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager&gt;): void;
- release(): void;
- getTrustedDeviceListSync(): Array&lt;DeviceInfo&gt;
- getTrustedDeviceList(callback:AsyncCallback&lt;Array&lt;DeviceInfo&gt;&gt;): void;
- getTrustedDeviceList(): Promise&lt;Array&lt;DeviceInfo&gt;&gt;
- getLocalDeviceInfoSync(): DeviceInfo;
- getLocalDeviceInfo(callback:AsyncCallback&lt;DeviceInfo&gt;): void;
- getLocalDeviceInfo(): Promise&lt;DeviceInfo&gt;
- startDeviceDiscovery(subscribeInfo: SubscribeInfo): void;
- startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void;
- stopDeviceDiscovery(subscribeId: number): void;
- publishDeviceDiscovery(publishInfo: PublishInfo): void;
- unPublishDeviceDiscovery(publishId: number): void;
- authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback&lt;{deviceId: string, pinToken ?: number}&gt;): void;
- unAuthenticateDevice(deviceInfo: DeviceInfo): void;
- verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback&lt;{deviceId: string, level: number}&gt;): void;
- setUserOperation(operateAction: number, params: string): void;
- on(type: 'uiStateChange', callback: Callback&lt;{ param: string}&gt;): void;
- off(type: 'uiStateChange', callback?: Callback&lt;{ param: string}&gt;): void;
- on(type: 'deviceStateChange', callback: Callback&lt;{ action: DeviceStateChangeAction, device: DeviceInfo }&gt;): void;
- off(type: 'deviceStateChange', callback?: Callback&lt;{ action: DeviceStateChangeAction, device: DeviceInfo }&gt;): void;
- on(type: 'deviceFound', callback: Callback&lt;{ subscribeId: number, device: DeviceInfo }&gt;): void;
- off(type: 'deviceFound', callback?: Callback&lt;{ subscribeId: number, device: DeviceInfo }&gt;): void;
- on(type: 'discoverFail', callback: Callback&lt;{ subscribeId: number, reason: number }&gt;): void;
- off(type: 'discoverFail', callback?: Callback&lt;{ subscribeId: number, reason: number }&gt;): void;
- on(type: 'publishSuccess', callback: Callback&lt;{ publishId: number }&gt;): void;
- off(type: 'publishSuccess', callback?: Callback&lt;{ publishId: number }&gt;): void;
- on(type: 'publishFail', callback: Callback&lt;{ publishId: number, reason: number }&gt;): void;
- off(type: 'publishFail', callback?: Callback&lt;{ publishId: number, reason: number }&gt;): void;
- on(type: 'serviceDie', callback: () =&gt; void): void;
- off(type: 'serviceDie', callback?: () =&gt; void): void;
**适配指导**
异步接口以getTrustedDeviceList为例,示例代码如下:
```ts
import account_osAccount from "@ohos.distributedHardware.deviceManager"
dmInstance.getTrustedDeviceList((err, data) => {
console.log("getTrustedDeviceList err: " + JSON.stringify(err));
console.log('get trusted device info: ' + JSON.stringify(data));
});
try {
dmInstance.getTrustedDeviceList((err, data) => {
if (err) {
console.error("getTrustedDeviceList errCode:" + err.code + ",errMessage:" + err.message);
return;
}
console.log('get trusted device info: ' + JSON.stringify(data));
});
} catch (err) {
console.error("getTrustedDeviceList errCode:" + err.code + ",errMessage:" + err.message);
}
```
同步接口以startDeviceDiscovery为例,示例代码如下:
```ts
// 生成发现标识,随机数确保每次调用发现接口的标识不一致
var subscribeId = Math.floor(Math.random() * 10000 + 1000);
var subscribeInfo = {
"subscribeId": subscribeId,
"mode": 0xAA, // 主动模式
"medium": 0, // 自动发现类型,同时支持多种发现类型
"freq": 2, // 高频率
"isSameAccount": false,
"isWakeRemote": false,
"capability": 1
};
dmInstance.startDeviceDiscovery(subscribeInfo); // 当有设备发现时,通过deviceFound回调通知给应用程序
// 生成发现标识,随机数确保每次调用发现接口的标识不一致
var subscribeId = Math.floor(Math.random() * 10000 + 1000);
var subscribeInfo = {
"subscribeId": subscribeId,
"mode": 0xAA, // 主动模式
"medium": 0, // 自动发现类型,同时支持多种发现类型
"freq": 2, // 高频率
"isSameAccount": false,
"isWakeRemote": false,
"capability": 1
};
try {
dmInstance.startDeviceDiscovery(subscribeInfo); // 当有设备发现时,通过deviceFound回调通知给应用程序
} catch (err) {
console.error("startDeviceDiscovery errCode:" + err.code + ",errMessage:" + err.message);
}
```
# USB管理 changeLog
## cl.usb_manager.1 API错误信息返回方式变更
USB管理接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作出变更,选择通过抛出异常的方式返回错误信息。
**变更影响**
基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
USB模块名由@ohos.usb.d.ts 变更为 @ohos.usbV9.d.ts,模块内所有接口均增加错误码处理。
**适配指导**
接口以getDevices为例,示例代码如下:
```ts
import usbV9 from '@ohos.usbV9'
try {
usbV9.getDevices(); // 如果给该接口传入不合适的参数,则会抛出异常
} catch (err) {
console.error("getDevices errCode:" + err.code + ",errMessage:" + err.message);
}
```
\ No newline at end of file
# 软总线子系统Changelog
## IPC&RPC API支持异常处理方式和支持传入布尔值与数值选择同步或异步方式发送信息变更
1. 软总线IPC&RPC部分接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误规范;
2. 支持传入布尔值选择同步或异步方式发送信息。
#### 变更影响
此版本兼容之前的应用开发,不需要适配,后续可调用新增接口支持以下两个变更:
1. 支持异常处理并返回错误码;
2. 提供通过布尔值或通过0与非0数字选择同步或异步发消息。
#### 关键接口/组件变更
为适配统一的API异常处理方式,对IPC&RPC相关接口进行废弃,并新增对应接口和方法。新增接口支持统一的错误码异常处理规范,功能上与原接口保持一致。
| 类名 | 废弃接口 | 新增替换类名 | 新增替代接口 |
| ------------ | ------------ | ------------ | ------------ |
| MessageParcel | static create(): MessageParcel | MessageSequence | static create(): MessageSequence |
| MessageParcel | reclaim(): void | MessageSequence | reclaim(): void |
| MessageParcel | writeRemoteObject(object: IRemoteObject): boolean| MessageSequence |writeRemoteObject(object: IRemoteObject): void|
| MessageParcel | readRemoteObject(): IRemoteObject | MessageSequence | readRemoteObject(): IRemoteObject |
| MessageParcel | writeInterfaceToken(token: string): boolean | MessageSequence | writeInterfaceToken(token: string): void |
| MessageParcel | readInterfaceToken(): string | MessageSequence | readInterfaceToken(): string |
| MessageParcel | getSize(): number | MessageSequence | getSize(): number |
| MessageParcel | getCapacity(): number | MessageSequence | getCapacity(): number|
| MessageParcel | setSize(size: number): boolean | MessageSequence | setCapacity(size: number): void |
| MessageParcel | getReadableBytes(): number | MessageSequence | getReadableBytes(): number |
| MessageParcel | getReadPosition(): number | MessageSequence | getReadPosition(): number |
| MessageParcel | getWritePosition(): number | MessageSequence | getWritePosition(): number |
| MessageParcel | rewindRead(pos: number): boolean | MessageSequence | rewindRead(pos: number): void |
| MessageParcel | rewindWrite(pos: number): boolean | MessageSequence | rewindWrite(pos: number): void |
| MessageParcel | writeNoException(): void | MessageSequence | writeNoException(): void |
| MessageParcel | readException(): void | MessageSequence | readException(): void |
| MessageParcel | writeByte(val: number): boolean | MessageSequence | writeByte(val: number): void |
| MessageParcel | writeShort(val: number): boolean | MessageSequence | writeShort(val: number): void |
| MessageParcel | writeInt(val: number): boolean | MessageSequence | writeInt(val: number): void |
| MessageParcel | writeLong(val: number): boolean | MessageSequence | writeLong(val: number): void |
| MessageParcel | writeFloat(val: number): boolean | MessageSequence | writeFloat(val: number): void |
| MessageParcel | writeDouble(val: number): boolean | MessageSequence | writeDouble(val: number): void |
| MessageParcel | writeBoolean(val: boolean): boolean | MessageSequence | writeBoolean(val: boolean): void |
| MessageParcel | writeChar(val: number): boolean | MessageSequence | writeChar(val: number): void |
| MessageParcel | writeString(val: string): boolean | MessageSequence | writeString(val: string): void |
| MessageParcel | writeSequenceable(val: Sequenceable): boolean | MessageSequence | writeParcelable(val: Parcelable): void |
| MessageParcel | writeByteArray(byteArray: number[]): boolean | MessageSequence | writeByteArray(byteArray: number[]): void |
| MessageParcel | writeShortArray(shortArray: number[]): boolean | MessageSequence | writeShortArray(shortArray: number[]): void |
| MessageParcel | writeIntArray(intArray: number[]): boolean | MessageSequence | writeIntArray(intArray: number[]): void |
| MessageParcel | writeLongArray(longArray: number[]): boolean | MessageSequence | writeLongArray(longArray: number[]): void |
| MessageParcel | writeFloatArray(floatArray: number[]): boolean | MessageSequence | writeFloatArray(floatArray: number[]): void |
| MessageParcel | writeDoubleArray(doubleArray: number[]): boolean | MessageSequence | writeDoubleArray(doubleArray: number[]): void |
| MessageParcel | writeBooleanArray(booleanArray: boolean[]): boolean | MessageSequence | writeBooleanArray(booleanArray: boolean[]): void |
| MessageParcel | writeCharArray(charArray: number[]): boolean | MessageSequence | writeCharArray(charArray: number[]): void |
| MessageParcel | writeStringArray(stringArray: string[]): boolean | MessageSequence | writeStringArray(stringArray: string[]): void |
| MessageParcel | writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean | MessageSequence | writeParcelableArray(sequenceableArray: Parcelable[]): void |
| MessageParcel | writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean | MessageSequence | writeRemoteObjectArray(objectArray: IRemoteObject[]): void |
| MessageParcel | readByte(): number | MessageSequence | readByte(): number |
| MessageParcel | readShort(): number | MessageSequence | readShort(): number |
| MessageParcel | readLong(): number | MessageSequence | readLong(): number |
| MessageParcel | readFloat(): number | MessageSequence | readFloat(): number |
| MessageParcel | readDouble(): number | MessageSequence | readDouble(): number |
| MessageParcel | readBoolean(): boolean | MessageSequence | readBoolean(): boolean |
| MessageParcel | readChar(): number | MessageSequence | readChar(): number |
| MessageParcel | readString(): string | MessageSequence | readString(): string |
| MessageParcel | readSequenceable(dataIn: Sequenceable) : boolean | MessageSequence | readSequenceable(dataIn: Parcelable) : void |
| MessageParcel | readByteArray(dataIn: number[]) : void | MessageSequence | readByteArray(dataIn: number[]) : void |
| MessageParcel | readByteArray(): number[] | MessageSequence | readByteArray(): number[] |
| MessageParcel | readShortArray(dataIn: number[]) : void | MessageSequence | readShortArray(dataIn: number[]) : void |
| MessageParcel | readShortArray(): number[] | MessageSequence | readShortArray(): number[] |
| MessageParcel | readIntArray(dataIn: number[]) : void | MessageSequence | readIntArray(dataIn: number[]) : void |
| MessageParcel | readIntArray() : number[] | MessageSequence | readIntArray() : number[] |
| MessageParcel | readLongArray(dataIn: number[]) : void | MessageSequence | readLongArray(dataIn: number[]) : void |
| MessageParcel | readLongArray(): number[] | MessageSequence | readLongArray(): number[] |
| MessageParcel | readFloatArray(dataIn: number[]) : void | MessageSequence | readFloatArray(dataIn: number[]) : void |
| MessageParcel | readFloatArray(): number[] | MessageSequence | readFloatArray(): number[] |
| MessageParcel | readDoubleArray(dataIn: number[]) : void | MessageSequence | readDoubleArray(dataIn: number[]) : void |
| MessageParcel | readDoubleArray(): number[] | MessageSequence | readDoubleArray(): number[] |
| MessageParcel | readBooleanArray(dataIn: boolean[]) : void | MessageSequence | readBooleanArray(dataIn: boolean[]) : void |
| MessageParcel | readBooleanArray(): boolean[] | MessageSequence | readBooleanArray(): boolean[] |
| MessageParcel | readCharArray(dataIn: number[]) : void | MessageSequence | readCharArray(dataIn: number[]) : void |
| MessageParcel | readCharArray(): number[] | MessageSequence | readCharArray(): number[] |
| MessageParcel | readStringArray(dataIn: string[]) : void | MessageSequence | readStringArray(dataIn: string[]) : void |
| MessageParcel | readStringArray(): string[] | MessageSequence | readStringArray(): string[] |
| MessageParcel | readSequenceableArray(sequenceableArray: Sequenceable[]): void | MessageSequence | readSequenceableArray(sequenceableArray: Parcelable[]): void |
| MessageParcel | readRemoteObjectArray(objects: IRemoteObject[]): void | MessageSequence | readRemoteObjectArray(objects: IRemoteObject[]): void |
| MessageParcel | readRemoteObjectArray(): IRemoteObject[] | MessageSequence | readRemoteObjectArray(): IRemoteObject[] |
| MessageParcel | static closeFileDescriptor(fd: number): void | MessageSequence | static closeFileDescriptor(fd: number): void |
| MessageParcel | static dupFileDescriptor(fd: number) :number | MessageSequence | static dupFileDescriptor(fd: number) :number |
| MessageParcel | containFileDescriptors(): boolean | MessageSequence | containFileDescriptors(): boolean |
| MessageParcel | writeFileDescriptor(fd: number): boolean | MessageSequence | writeFileDescriptor(fd: number): void |
| MessageParcel | readFileDescriptor(): number | MessageSequence | readFileDescriptor(): number |
| MessageParcel | writeAshmem(ashmem: Ashmem): boolean | MessageSequence | writeAshmem(ashmem: Ashmem): void |
| MessageParcel | readAshmem(): Ashmem | MessageSequence | readAshmem(): Ashmem |
| MessageParcel | writeRawData(rawData: number[], size: number): boolean | MessageSequence | writeRawData(rawData: number[], size: number): void |
| MessageParcel | readRawData(size: number): number[] | MessageSequence | readRawData(size: number): number[] |
| Sequenceable | marshalling(dataOut: MessageParcel): boolean | Parcelable | marshalling(dataOut: MessageSequence): boolean |
| Sequenceable | unmarshalling(dataIn: MessageParcel) : boolean | Parcelable | unmarshalling(dataIn: MessageSequence) : boolean |
| SendRequestResult | errCode: number | RequestResult | errCode: number |
| SendRequestResult | code: number | RequestResult | code: number |
| SendRequestResult | data: MessageParcel | RequestResult | data: MessageSequence |
| SendRequestResult | reply: MessageParcel | RequestResult | reply: MessageSequence |
| IRemoteObject | queryLocalInterface(descriptor: string): IRemoteBroker | NA | getLocalInterface(descriptor: string): IRemoteBroker |
| IRemoteObject | getInterfaceDescriptor(): string | NA | getDescriptor(): string |
| IRemoteObject | addDeathRecipient(recipient: DeathRecipient, flags: number): boolean | NA | registerDeathRecipient(recipient: DeathRecipient, flags: number): void |
| IRemoteObject | removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean | NA | unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void |
| IRemoteObject | NA | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult> |
| IRemoteObject | sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption,callback: AsyncCallback<RequestResult>): void |
| MessageOption | NA | NA | isAsync(): boolean |
| MessageOption | NA | NA | setAsync(async: boolean): void |
| MessageOption | NA | NA | constructor(async?: boolean) |
| RemoteObject | queryLocalInterface(descriptor: string): IRemoteBroker | NA | getLocalInterface(descriptor: string): IRemoteBroker |
| RemoteObject | attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void | NA | modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void |
| RemoteObject | getInterfaceDescriptor(): string | NA | getDescriptor(): string |
| RemoteObject | onRemoteRequestEx(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean&nbsp;\|&nbsp;Promise<boolean> | NA | onRemoteMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): boolean&nbsp;\|&nbsp;Promise<boolean> |
| RemoteObject | sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise<SendRequestResult> | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult> |
| RemoteObject | sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void |
| RemoteProxy | queryLocalInterface(interface: string): IRemoteBroker | NA | getLocalInterface(descriptor: string): IRemoteBroker |
| RemoteProxy | getInterfaceDescriptor(): string | NA | getDescriptor(): string |
| RemoteProxy | addDeathRecipient(recipient: DeathRecipient, flags: number): boolean | NA | registerDeathRecipient(recipient: DeathRecipient, flags: number): void |
| RemoteProxy | removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean | NA | unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void |
| RemoteProxy | NA | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult> |
| RemoteProxy | sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void |
| IPCSkeleton | static flushCommands(object: IRemoteObject): number | NA | static flushCmdBuffer(object: IRemoteObject): void |
| IPCSkeleton | static setCallingIdentity(identity: string): boolean | NA | static restoreCallingIdentity(identity: string): void |
| Ashmem | static createAshmem(name: string, size: number): Ashmem | NA | static create(name: string, size: number): Ashmem |
| Ashmem | static createAshmemFromExisting(ashmem: Ashmem): Ashmem | NA | static create(ashmem: Ashmem): Ashmem |
| Ashmem | mapAshmem(mapType: number): boolean | NA | mapTypedAshmem(mapType: number): void |
| Ashmem | mapReadAndWriteAshmem(): boolean | NA | mapReadWriteAshmem(): void |
| Ashmem | mapReadOnlyAshmem(): boolean | NA | mapReadonlyAshmem(): void |
| Ashmem | setProtection(protectionType: number): boolean | NA | setProtectionType(protectionType: number): void |
| Ashmem | writeToAshmem(buf: number[], size: number, offset: number): boolean | NA | writeAshmem(buf: number[], size: number, offset: number): void |
| Ashmem | readFromAshmem(size: number, offset: number): number[] | NA | readAshmem(size: number, offset: number): number[] |
#### 适配指导
新增的接口以抛异常的方式返回错误码及对应的错误信息,以MessageParcel中的create接口为例,使用示例代码如下:
```js
import rpc from '@ohos.rpc'
try {
var data = rpc.MessageParcel.create();
data.reclaim();
} catch (error) {
console.info("create meassageParcel failed, errorCode = " + error.errCode);
console.info("create meassageParcel failed, errorMessage = " + error.errorMessage);
}
```
更多接口的示例代码可参考[RPC通信API文档](../../../application-dev/reference/apis/js-apis-rpc.md)
\ No newline at end of file
# 定制子系统ChangeLog
OpenHarmony 3.2.8.3 版本相较于OpenHarmony 3.2.8.1版本,定制子系统的API变更如下:
## cl.Customization.1 企业设备管理模块名称变更
从Opeharmonny 3.2.8.3版本开始,将"@ohos.enterpriseDeviceManager.d.ts"改为"@ohos.enterprise.adminManager.d.ts",开发者需要根据以下说明对应用进行适配。
**变更影响**
在Opeharmonny 3.2.8.3之前版本已开发的应用,需要进行适配动才可以在新版本SDK环境正常编译通过。
**关键的接口/组件变更**
| 原接口 | 新接口 |
| --------------------------------- | ---------------------------------- |
| @ohos.enterpriseDeviceManager.d.ts | @ohos.enterprise.adminManager.d.ts |
**适配指导**
如上所述,仅将老接口平移到了新的namespace中,所以可以通过修改import来解决适配问题:
如原先接口使用了@ohos.enterpriseDeviceManager:
```js
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager';
```
可以通过直接修改import,来切换到新的namespace上:
```js
import enterpriseDeviceManager from '@ohos.enterprise.adminManager';
```
## cl.Customization.2 enterpriseDeviceManager/DeviceSettingsManager.d.ts模块变更
从Opeharmonny 3.2.8.3版本开始,将enterpriseDeviceManager/DeviceSettingsManager.d.ts更改为"ohos.enterprise.dateTimeManager.d.ts"。
**变更影响**
在Opeharmonny 3.2.8.3之前版本已开发的应用,需要进行适配动才可以在新版本SDK环境正常编译通过。
**关键的接口/组件变更**
| 原接口 | 原接口类型 | 新接口 | 新接口类型 |
| --------------------------------- | --------- | ---------------------------------- | ----- |
| enterpriseDeviceManager/DeviceSettingsManager.d.ts | interface | @ohos.enterprise.dateTimeManager.d.ts | namespace |
**适配指导**
若原先使用的enterpriseDeviceManager/DeviceSettingsManager.d.ts的setDateTime接口。
```js
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => {
if (error) {
console.log("error code:" + error.code + " error message:" + error.message);
return;
}
mgr.setDateTime(wantTemp, 1526003846000, (error) => {
if (error) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
});
```
需要import新的namespace进行适配。
```js
import dateTimeManager from '@ohos.enterprise.dateTimeManager'
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
dateTimeManager.setDateTime(wantTemp, 1526003846000, (error) => {
if (error) {
console.log("error code:" + error.code + " error message:" + error.message);
}
})
```
## cl.Customization.3 systemapi变更
从Opeharmonny 3.2.8.3版本开始,企业设备管理所有接口变更为systemapi。
**变更影响**
所有接口只允许系统应用调用,非系统应用无法调用接口。
**关键的接口/组件变更**
| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 |
| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
| @ohos.enterprise.adminManager | adminManager | **function** enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise<**void**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** disableAdmin(admin: Want, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** disableAdmin(admin: Want, userId: number, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** disableAdmin(admin: Want, userId?: number): Promise<**void**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** disableSuperAdmin(bundleName: String, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** disableSuperAdmin(bundleName: String): Promise<**void**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** isAdminEnabled(admin: Want, callback: AsyncCallback<**boolean**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback<**boolean**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** isAdminEnabled(admin: Want, userId?: number): Promise<**boolean**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** getEnterpriseInfo(admin: Want, callback: AsyncCallback<**EnterpriseInfo**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** getEnterpriseInfo(admin: Want): Promise<**EnterpriseInfo**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<**void**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** isSuperAdmin(bundleName: String, callback: AsyncCallback<**boolean**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** isSuperAdmin(bundleName: String): Promise<**boolean**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** subscribeManagedEvent(admin: Want, managedEvents: Array<**ManagedEvent**>, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** subscribeManagedEvent(admin: Want, managedEvents: Array<**ManagedEvent**>): Promise<**void**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** unsubscribeManagedEvent(admin: Want, managedEvents: Array<**ManagedEvent**>, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **function** unsubscribeManagedEvent(admin: Want, managedEvents: Array<**ManagedEvent**>): Promise<**void**>; | systemapi |
| @ohos.enterprise.adminManager | adminManager | **interface** EnterpriseInfo | systemapi |
| @ohos.enterprise.adminManager | adminManager | **enum** AdminType | systemapi |
| @ohos.enterprise.adminManager | adminManager | **enum** ManagedEvent | systemapi |
| @ohos.enterprise.dataTimeManager | dateTimeManager | **function** setDateTime(admin: Want, time: number, callback: AsyncCallback<**void**>): void; | systemapi |
| @ohos.enterprise.dataTimeManager | dateTimeManager | **function** setDateTime(admin: Want, time: number): Promise<**void**>; | systemapi |
## cl.Customization.4 接口权限变更
从Opeharmonny 3.2.8.3版本开始,部分接口新增权限校验。
**变更影响**
在Opeharmonny 3.2.8.3之前版本已开发的应用,需要持有相应权限,否则无法正常调用接口。
**关键的接口/组件变更**
| 模块名 | 类名 | 方法/属性/枚举/常量 | 新增权限 |
| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
| @ohos.enterprise.adminManager | adminManager | **function** enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback<**void**>): void; | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN |
| @ohos.enterprise.adminManager | adminManager | **function** enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback<**void**>): void; | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN |
| @ohos.enterprise.adminManager | adminManager | **function** enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise<**void**>; | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN |
| @ohos.enterprise.adminManager | adminManager | **function** disableAdmin(admin: Want, callback: AsyncCallback<**void**>): void; | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN |
| @ohos.enterprise.adminManager | adminManager | **function** disableAdmin(admin: Want, userId: number, callback: AsyncCallback<**void**>): void; | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN |
| @ohos.enterprise.adminManager | adminManager | **function** disableAdmin(admin: Want, userId?: number): Promise<**void**>; | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN |
| @ohos.enterprise.adminManager | adminManager | **function** disableSuperAdmin(bundleName: String, callback: AsyncCallback<**void**>): void; | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN |
| @ohos.enterprise.adminManager | adminManager | **function** disableSuperAdmin(bundleName: String): Promise<**void**>; | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN |
| @ohos.enterprise.adminManager | adminManager | **function** setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback<**void**>): void; | ohos.permission.SET_ENTERPRISE_INFO |
| @ohos.enterprise.adminManager | adminManager | **function** setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<**void**>; | ohos.permission.SET_ENTERPRISE_INFO |
| @ohos.enterprise.adminManager | adminManager | **function** subscribeManagedEvent(admin: Want, managedEvents: Array<**ManagedEvent**>, callback: AsyncCallback<**void**>): void; | ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT |
| @ohos.enterprise.adminManager | adminManager | **function** subscribeManagedEvent(admin: Want, managedEvents: Array<**ManagedEvent**>): Promise<**void**>; | ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT |
| @ohos.enterprise.adminManager | adminManager | **function** unsubscribeManagedEvent(admin: Want, managedEvents: Array<**ManagedEvent**>, callback: AsyncCallback<**void**>): void; | ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT |
| @ohos.enterprise.adminManager | adminManager | **function** unsubscribeManagedEvent(admin: Want, managedEvents: Array<**ManagedEvent**>): Promise<**void**>; | ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT |
| @ohos.enterprise.dataTimeManager | dateTimeManager | **function** setDateTime(admin: Want, time: number, callback: AsyncCallback<**void**>): void; | ohos.permission.ENTERPRISE_SET_DATETIME |
| @ohos.enterprise.dataTimeManager | dateTimeManager | **function** setDateTime(admin: Want, time: number): Promise<**void**>; | ohos.permission.ENTERPRISE_SET_DATETIME |
**适配指导**
调用以上接口,需要申请相应的权限才能正常调用。
# 文件管理子系统ChangeLog
## cl.filemanagement.1 fileio相关接口异常处理方式变更
file_api部件fileio接口返回值不包含错误码error.code,现进行错误码整改,废弃原有相关接口,新增相关接口。
**变更影响**
基于此前版本开发的应用,需注意废弃接口的迭代更新。新接口在接口规格上进行了微调,需注意新接口使用方法。
**关键接口/组件变更**
为适配统一的API异常处理方式,对fileio相关接口进行废弃,并新增对应接口,原接口位于@ohos.fileio,新接口位于@ohos.file.fs。新增接口支持统一的错误码异常处理规范,功能上与原接口保持一致,参数上有微调。
| 模块名 | 方法/属性/枚举/常量 | 变更类型 |
| ------------------------- | ------------------------------------------------------------ | -------- |
| @ohos.fileio | **function** open(path: string, flags?: number, mode?: number, callback?: AsyncCallback<number>): void \| Promise<number>; | 废弃 |
| @ohos.fileio | **function** openSync(path: string, flags?: number, mode?: number): number; | 废弃 |
| @ohos.file.fs | **function** open(path: string, mode?: number, callback?: AsyncCallback<File>): void \| Promise<File>; | 新增 |
| @ohos.file.fs | **function** openSync(path: string, mode?: number): File; | 新增 |
| @ohos.fileio | **function** read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: number; position?: number; }, callback?: AsyncCallback<ReadOut>): void \| Promise<ReadOut>; | 废弃 |
| @ohos.fileio | **function** readSync(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: number; position?: number; }): number; | 废弃 |
| @ohos.file.fs | **function** read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: number; }, callback?: AsyncCallback<number>): void \| Promise<number>; | 新增 |
| @ohos.file.fs | **function** readSync(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: number; }): number; | 新增 |
| @ohos.fileio | **function** stat(path: string, callback?: AsyncCallback<Stat>): void \| Promise<Stat>; | 废弃 |
| @ohos.fileio | **function** statSync(path: string): Stat; | 废弃 |
| @ohos.fileio | **function** fstat(fd: number, callback?: AsyncCallback<Stat>): void \| Promise<Stat>; | 废弃 |
| @ohos.fileio | **function** fstatSync(fd: number): Stat; | 废弃 |
| @ohos.file.fs | **function** stat(file: string \| number, callback?: AsyncCallback<Stat>): void \| Promise<Stat>; | 新增 |
| @ohos.file.fs | **function** statSync(file: string \| number): Stat; | 新增 |
| @ohos.fileio | **function** truncate(path: string, len?: number, callback?: AsyncCallback<void>): void \| Promise<void>; | 废弃 |
| @ohos.fileio | **function** truncateSync(path: string, len?: number): void; | 废弃 |
| @ohos.fileio | **function** ftruncate(fd: number, len?: number, callback?: AsyncCallback<void>): void \| Promise<void>; | 废弃 |
| @ohos.fileio | **function** ftruncateSync(fd: number, len?: number): void; | 废弃 |
| @ohos.file.fs | **function** truncate(file: string \| number, len?: number, callback?: AsyncCallback<void>): void \| Promise<void>; | 新增 |
| @ohos.file.fs | **function** truncateSync(file: string \| number, len?: number): void; | 新增 |
| @ohos.fileio | **function** write(fd: number, buffer: ArrayBuffer \| string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }, callback?: AsyncCallback<number>): void \| Promise<void>; | 废弃 |
| @ohos.fileio | **function** writeSync(fd: number, buffer: ArrayBuffer \| string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): number; | 废弃 |
| @ohos.file.fs | **function** write(fd: number, buffer: ArrayBuffer \| string, options?: { offset?: number; length?: number; encoding?: string; }, callback?: AsyncCallback<number>): void \| Promise<void>; | 新增 |
| @ohos.file.fs | **function** writeSync(fd: number, buffer: ArrayBuffer \| string, options?: { offset?: number; length?: number; encoding?: string; }): number; | 新增 |
**适配指导**
原接口使用的是@ohos.fileio,以以下方式import:
```js
import fileio from '@ohos.fileio';
```
现新接口使用的是@ohos.file.fs,以以下方式import:
```js
import fs from '@ohos.file.fs';
```
此外还需要适配异常处理,同步接口异常处理示例代码:
```js
import fs from '@ohos.file.fs'
try {
let file = fs.openSync(path, fs.OpenMode.READ_ONLY);
} catch (err) {
console.error("openSync errCode:" + err.code + ", errMessage:" + err.message);
}
```
异步接口promise方法异常处理示例代码:
```js
import fs from '@ohos.file.fs'
try {
let file = await fs.open(path, fs.OpenMode.READ_ONLY);
} catch (err) {
console.error("open promise errCode:" + err.code + ", errMessage:" + err.message);
}
```
异步接口callback方法异常处理示例代码:
```js
import fs from '@ohos.file.fs'
try {
fs.open(path, fs.OpenMode.READ_ONLY, function(e, file){ //异步线程的错误(如系统调用等)在回调中获取
if (e) {
console.error("open in async errCode:" + e.code + ", errMessage:" + e.message);
}
});
} catch (err) { //主线程的错误(如非法参数等)通过try catch获取
console.error("open callback errCode:" + err.code + ", errMessage:" + err.message);
}
```
# 位置服务子系统ChangeLog
## cl.location.1 系统API和API9接口迁移到新增的@ohos.geoLocationManager.d.ts
@ohos.geolocation.d.ts接口不支持抛出错误码,而API9和systemApi都需要支持抛出错误码,为了支持该功能,把@ohos.geolocation.d.ts中systemApi和API9所有接口,迁移到新增的@ohos.geoLocationManager.d.ts中,并增加错误码描述。
后续需要import @ohos.geoLocationManager才能使用位置服务的系统API和API9接口:
import geoLocationManager from '@ohos.geoLocationManager';
**变更影响**
仅对系统API和API9所有接口的使用有影响,需要import @ohos.geoLocationManager才能使用位置服务的系统API和API9接口:
import geoLocationManager from '@ohos.geoLocationManager';
对于其他接口无影响。
**关键的接口/组件变更**
| 类名 | 接口类型 | 接口声明 | 变更类型 |
| -- | -- | -- | -- |
|geolocation| namespace | declare namespacegeolocation| API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation | interface | export interface ReverseGeocodingMockInfo | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation | interface | export interface LocationMockConfig | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation | interface | export interface CountryCode | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation | enum | export enum CountryCodeType | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation.GeoAddress | field | isFromMock?: Boolean; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation.Location | field | isFromMock?: Boolean; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation.GeoLocationErrorCode | field | NOT_SUPPORTED = 100 | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation.GeoLocationErrorCode | field | QUERY_COUNTRY_CODE_ERROR | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function on(type: 'countryCodeChange', callback: Callback&lt;CountryCode&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function off(type: 'countryCodeChange', callback?: Callback&lt;CountryCode&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function getCountryCode(callback: AsyncCallback&lt;CountryCode&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function getCountryCode(): Promise&lt;CountryCode&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function enableLocationMock(scenario: LocationRequestScenario, callback: AsyncCallback&lt;void&gt;): void; | API9接口变更,该接口删除。 |
|geolocation| method | function enableLocationMock(callback: AsyncCallback&lt;void&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function enableLocationMock(scenario: LocationRequestScenario): Promise&lt;void&gt;; | API9接口变更,该接口删除。 |
|geolocation| method | function enableLocationMock(): Promise&lt;void&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function disableLocationMock(scenario: LocationRequestScenario, callback: AsyncCallback&lt;void&gt;): void; | API9接口变更,该接口删除。 |
|geolocation| method | function disableLocationMock(callback: AsyncCallback&lt;void&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function disableLocationMock(scenario: LocationRequestScenario): Promise&lt;void&gt;; | API9接口变更,该接口删除。 |
|geolocation| method | function disableLocationMock(): Promise&lt;void&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function setMockedLocations(config: LocationMockConfig, callback: AsyncCallback&lt;void&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function setMockedLocations(config: LocationMockConfig): Promise&lt;void&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function enableReverseGeocodingMock(callback: AsyncCallback&lt;void&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function enableReverseGeocodingMock(): Promise&lt;void&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function disableReverseGeocodingMock(callback: AsyncCallback&lt;void&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function disableReverseGeocodingMock(): Promise&lt;void&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;, callback: AsyncCallback&lt;void&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;): Promise&lt;void&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback&lt;boolean&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType): Promise&lt;boolean&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts |
|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback&lt;boolean&gt;): void; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts,callback返回值改为void。 |
|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise&lt;boolean&gt;; | API9接口变更,迁移到@ohos.geoLocationManager.d.ts,promise返回值改为void。 |
**适配指导(可选,不涉及则可以删除)**
以enableLocation为例,在新版本上需要使用如下方式进行调用:
```ts
import geoLocationManager from '@ohos.geoLocationManager';
try {
geoLocationManager.enableLocation((err, data) => {
if (err) {
console.log('enableLocation: err=' + JSON.stringify(err));
}
});
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
}
```
## cl.location.2 位置服务权限变更
从API9开始,增加ohos.permission.APPROXIMATELY_LOCATION,表示模糊位置权限。
如果应用开发者使用的API版本大于等于9,则需要同时申请ohos.permission.LOCATION和ohos.permission.APPROXIMATELY_LOCATION,单独申请ohos.permission.LOCATION会失败。
**变更影响**
如果是存量应用(使用的API版本小于9),则无影响。如果使用的API版本大于等于9,位置服务权限申请方式有变更,详情如下:
应用在使用系统能力前,需要检查是否已经获取用户授权访问设备位置信息。如未获得授权,可以向用户申请需要的位置权限,申请方式请参考下文。
系统提供的定位权限有:
- ohos.permission.LOCATION
- ohos.permission.APPROXIMATELY_LOCATION
- ohos.permission.LOCATION_IN_BACKGROUND
访问设备的位置信息,必须申请权限,并且获得用户授权。
API9之前的版本,申请ohos.permission.LOCATION即可。
API9及之后的版本,需要申请ohos.permission.APPROXIMATELY_LOCATION或者同时申请ohos.permission.APPROXIMATELY_LOCATION和ohos.permission.LOCATION;无法单独申请ohos.permission.LOCATION。
| 使用的API版本 | 申请位置权限 | 申请结果 | 位置的精确度 |
| -------- | -------- | -------- | -------- |
| 小于9 | ohos.permission.LOCATION | 成功 | 获取到精准位置,精准度在米级别。 |
| 大于等于9 | ohos.permission.LOCATION | 失败 | 无法获取位置。 |
| 大于等于9 | ohos.permission.APPROXIMATELY_LOCATION | 成功 | 获取到模糊位置,精确度为5公里。 |
| 大于等于9 | ohos.permission.APPROXIMATELY_LOCATION和ohos.permission.LOCATION | 成功 | 获取到精准位置,精准度在米级别。 |
如果应用在后台运行时也需要访问设备位置,除需要将应用声明为允许后台运行外,还必须申请ohos.permission.LOCATION_IN_BACKGROUND权限,这样应用在切入后台之后,系统可以继续上报位置信息。
开发者可以在应用配置文件中声明所需要的权限,具体可参考[授权申请指导](../../../application-dev/security/accesstoken-guidelines.md)
**关键的接口/组件变更**
如果是存量应用(使用的API版本小于9),则无影响。
如果使用的API版本大于等于9,则在使用@ohos.geolocation和@ohos.geoLocationManager中需要ohos.permission.LOCATION权限的接口时,都需要按照上文所述方式申请对应权限。
# 全球化子系统ChangeLog
## cl.global.1 国际化模块接口支持错误码
全球化子系统国际化组件在如下场景中提供的接口修改为支持错误码。从API9开始作以下变更:
- 获取国家、语言的本地化显示
- 获取系统支持的语言列表、语言支持的地区列表
- 判断语言与地区是否匹配
- 获取、设置系统语言、系统国家或地区、系统区域
- 获取、设置系统24小时制
- 获取、添加、移除系统偏好语言
- 获取、设置本地化数字
开发者需要根据以下说明对应用进行适配。
**变更影响**
上述接口修改为System类的静态方法,调用时需要在模块名后加上类名。
设置类接口,返回值由boolean类型修改为void类型。例如,setSystemLanguage接口。
接口调用失败时会根据失败原因抛出相应的错误码。例如,当应用未正确配置权限时,抛出201错误码。
**关键的接口/组件变更**
- 涉及接口
- getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string;
- getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string;
- getSystemLanguages(): Array<string>;
- getSystemCountries(language: string): Array<string>;
- isSuggested(language: string, region?: string): boolean;
- getSystemLanguage(): string;
- setSystemLanguage(language: string): void;
- getSystemRegion(): string;
- setSystemRegion(region: string): void;
- getSystemLocale(): string;
- setSystemLocale(locale: string): void;
- is24HourClock(): boolean;
- set24HourClock(option: boolean): void;
- addPreferredLanguage(language: string, index?: number): void;
- removePreferredLanguage(index: number): void;
- getPreferredLanguageList(): Array<string>;
- getFirstPreferredLanguage(): string;
- getAppPreferredLanguage(): string;
- setUsingLocalDigit(flag: boolean): void;
- getUsingLocalDigit(): boolean;
**适配指导**
使用try-catch块捕获接口抛出的日常。
```
import I18n from '@ohos.i18n'
try {
I18n.System.setSystemLanguage('zh');
} catch(error) {
console.error(`call System.setSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`)
}
```
\ No newline at end of file
# 输入法框架changeLog
## cl.inputmethod_frameworks.1 API错误信息返回方式变更
下列模块内部接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。在API9进行变更。
- 输入法框架模块:系统接口,@ohos.inputmethod.d.ts
- 输入法服务模块:系统接口,@ohos.inputmethodengine.d.ts
- 输入法ExtentionAbility模块:系统接口,@ohos.inputmethodextensionability.d.ts
- 输入法ExtentionContext模块:系统接口,@ohos.inputmethodextensioncontext.d.ts
- 输入法子类型模块:系统接口,@ohos.inputMethodSubtype.d.ts
异步接口:通过AsyncCallback或Promise的error对象返回错误信息。
同步接口:通过抛出异常的方式返回错误信息。
**变更影响**
基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
在以下接口增加错误码处理:
- getSetting(): InputMethodSetting;
- getController(): InputMethodController;
- switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolean>): void;
- switchInputMethod(target: InputMethodProperty): Promise<boolean>;
- switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback<boolean>): void;
- switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean>;
- switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype, callback: AsyncCallback<boolean>): void;
- switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype): Promise<boolean>;
- listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback<Array<InputMethodSubtype>>): void;
- listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Array<InputMethodSubtype>>;
- listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSubtype>>): void;
- listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>>;
- getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void;
- getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>;
- showOptionalInputMethods(callback: AsyncCallback<boolean>): void;
- showOptionalInputMethods(): Promise<boolean>;
- stopInputSession(callback: AsyncCallback<boolean>): void;
- stopInputSession(): Promise<boolean>;
- showSoftKeyboard(callback: AsyncCallback<void>): void;
- showSoftKeyboard():Promise<void>;
- hideSoftKeyboard(callback: AsyncCallback<void>): void;
- hideSoftKeyboard():Promise<void>;
- hide(callback: AsyncCallback<void>): void;
- hide(): Promise<void>;
- onCreate(want: Want): void;
- onDestroy(): void;
InputClient 接口下:
- sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void;
- sendKeyFunction(action: number): Promise<boolean>;
- deleteForward(length: number, callback: AsyncCallback<boolean>): void;
- deleteForward(length: number): Promise<boolean>;
- deleteBackward(length: number, callback: AsyncCallback<boolean>): void;
- deleteBackward(length: number): Promise<boolean>;
- insertText(text: string, callback: AsyncCallback<boolean>): void;
- insertText(text: string): Promise<boolean>;
- getForward(length: number, callback: AsyncCallback<string>): void;
- getForward(length: number): Promise<string>;
- getBackward(length: number, callback: AsyncCallback<string>): void;
- getBackward(length: number): Promise<string>;
- getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void;
- getEditorAttribute(): Promise<EditorAttribute>;
- moveCursor(direction: number, callback: AsyncCallback<void>): void;
- moveCursor(direction: number): Promise<void>;
InputMethodExtensionAbility 类下:
- onCreate(want: Want): void;
- onDestroy(): void;
**适配指导**
异步接口以showOptionalInputMethods为例,示例代码如下:
callback回调:
```js
import inputMethod from '@ohos.inputmethod';
let inputMethodSetting = inputMethod.getSetting();
try {
inputMethodSetting.showOptionalInputMethods((err, data) => {
if (err !== undefined) {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing optionalInputMethods.');
});
} catch (err) {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
}
```
Promise回调:
```js
import inputMethod from '@ohos.inputmethod';
let inputMethodSetting = inputMethod.getSetting();
inputMethodSetting.showOptionalInputMethods().then((data) => {
console.info('Succeeded in showing optionalInputMethods.');
}).catch((err) => {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
})
```
## cl.inputmethod_frameworks.2 API部分接口废弃
以下接口标记废除:
- getInputMethodSetting(): InputMethodSetting;
- getInputMethodController(): InputMethodController;
- listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>): void;
- listInputMethod(): Promise<Array<InputMethodProperty>>;
- displayOptionalInputMethod(callback: AsyncCallback<void>): void;
- displayOptionalInputMethod(): Promise<void>;
- stopInput(callback: AsyncCallback<boolean>): void;
- stopInput(): Promise<boolean>;
interface InputMethodProperty:
- readonly packageName: string;
- readonly methodId: string;
- getInputMethodEngine(): InputMethodEngine;
- createKeyboardDelegate(): KeyboardDelegate;
- hideKeyboard(callback: AsyncCallback<void>): void;
- hideKeyboard(): Promise<void>;
替代接口如下:
- getSetting(): InputMethodSetting;
- getController(): InputMethodController;
- getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void;
- getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>;
- showOptionalInputMethods(callback: AsyncCallback<boolean>): void;
- showOptionalInputMethods(): Promise<boolean>;
- stopInputSession(callback: AsyncCallback<boolean>): void;
- stopInputSession(): Promise<boolean>;
interface InputMethodProperty:
- readonly name: string;
- readonly id: string;
- getInputMethodAbility(): InputMethodAbility;
- getKeyboardDelegate(): KeyboardDelegate;
- hide(callback: AsyncCallback<void>): void;
- hide(): Promise<void>;
**特别注意:**
使用getInputMethodAbility()接口获取到InputMethodAbility对象,代替使用getInputMethodEngine()接口获取InputMethodEngine对象。
使用InputMethodAbility中的方法,不要再使用InputMethodEngine中的方法。
使用InputMethodAbility中的on('inputStart')方法,获取到KeyboardController实例与InputClient实例,不要再使用InputMethodEngine中的on('inputStart')方法去获取TextInputClient实例。
之前:
```js
inputMethodEngine.getInputMethodEngine().on('inputStart', (kbController, textClient) => {
let keyboardController = kbController;
let textInputClient = textClient; // 获取到TextInputClient实例
});
```
之后:
```js
inputMethodEngine.getInputMethodAbility().on('inputStart', (kbController, client) => {
let keyboardController = kbController;
let inputClient = client; // // 获取到InputClient实例
});
```
## cl.inputmethod_frameworks.3 API部分接口变更
变更前:
- listInputMethod(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void;
- listInputMethod(enable: boolean): Promise<Array<InputMethodProperty>>;
- terminateSelf(callback: AsyncCallback<void>): void;
- terminateSelf(): Promise<void>;
变更后:
- getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void;
- getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>;
- destroy(callback: AsyncCallback<void>): void;
- destroy(): Promise<void>;
删除API9接口:
- startAbility(want: Want, callback: AsyncCallback<void>): void;
- startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void;
- startAbility(want: Want, options?: StartOptions): Promise<void>;
其他新增接口:
- on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void;
- off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void;
- interface InputMethodProperty:
- readonly label?: string;
- readonly icon?: string;
- readonly iconId?: number;
- extra: object;
- interface InputMethodAbility:
- on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => void): void;
- off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void;
\ No newline at end of file
# 多媒体子系统ChangeLog
## cl.multimedia.audio.001 getRoutingManager()调用方式变更
getRoutingManager()接口的调用方法由异步变为同步。
**变更影响**
如不符合上述调用规则,将会在编译执行时出错。
**关键的接口/组件变更**
变更前
```js
getRoutingManager(callback: AsyncCallback<AudioRoutingManager>): void;
getRoutingManager(): Promise<AudioRoutingManager>;
```
变更后
```js
getRoutingManager(): AudioRoutingManager;
```
## cl.multimedia.audio.002 getStreamManager()调用方式变更
getStreamManager()接口的调用方法由异步变为同步。
**变更影响**
如不符合上述调用规则,将会在编译执行时出错。
**关键的接口/组件变更**
变更前
```js
getStreamManager(callback: AsyncCallback<AudioStreamManager>): void;
getStreamManager(): Promise<AudioStreamManager>;
```
变更后
```js
getStreamManager(): AudioStreamManager;
```
## cl.multimedia.audio.003 原AudioRoutingManager中micStateChange监听注册方式变更
原AudioRoutingManager中,on()函数的micStateChange监听注册方式变更。
**变更影响**
如不符合上述调用规则,将会在编译执行时出错。
**关键的接口/组件变更**
变更前
```js
interface AudioRoutingManager {
on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void;
}
```
变更后
```js
interface AudioVolumeGroupManager {
on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void;
}
```
## cl.multimedia.audio.004 getVolumeGroups()调用方式变更
getVolumeGroups()接口的调用方式变更。
**变更影响**
如不符合上述调用规则,将会在编译执行时出错。
**关键的接口/组件变更**
变更前
```js
getVolumeGroups(networkId: string, callback:AsyncCallback<VolumeGroupInfos>): void;
getVolumeGroups(networkId: string): Promise<VolumeGroupInfos>;
```
变更后
```js
getVolumeManager(): AudioVolumeManager;
interface AudioVolumeManager{
getVolumeGroupInfos(networkId: string, callback: AsyncCallback<VolumeGroupInfos>): void;
getVolumeGroupInfos(networkId: string): Promise<VolumeGroupInfos>;
}
```
## cl.multimedia.audio.005 getGroupManager()调用方式变更
getGroupManager()接口的调用方式变更。
**变更影响**
如不符合上述调用规则,将会在编译执行时出错。
**关键的接口/组件变更**
变更前
```js
getGroupManager(groupId: number, callback: AsyncCallback<AudioGroupManager>): void;
getGroupManager(groupId: number): Promise<AudioGroupManager>;
```
变更后
```js
getVolumeManager(): AudioVolumeManager;
interface AudioVolumeManager{
getVolumeGroupManager(groupId: number, callback: AsyncCallback<AudioVolumeGroupManager>): void;
getVolumeGroupManager(groupId: number): Promise<AudioVolumeGroupManager>;
}
```
## cl.multimedia.audio.006 枚举FocusType成员名变更
枚举FocusType中,成员FOCUS_TYPE_RECORDING重命名为FOCUS_TYPE_DEFAULT。
**变更影响**
如不符合上述调用规则,将会在编译执行时出错。
**关键的接口/组件变更**
变更前
```js
enum FocusType {
FOCUS_TYPE_RECORDING = 0,
}
```
变更后
```js
enum InterruptRequestType {
INTERRUPT_REQUEST_TYPE_DEFAULT = 0,
}
```
## cl.multimedia.audio.007 AudioRenderer中interrupt监听注册名称变更
AudioRenderer中on()函数的interrupt监听注册名称变更。
**变更影响**
如不符合上述调用规则,将会在编译执行时出错。
**关键的接口/组件变更**
变更前
```js
interface AudioRenderer {
on(type: 'interrupt', callback: Callback<InterruptEvent>): void;
}
```
变更后
```js
interface AudioRenderer {
on(type: 'audioInterrupt', callback: Callback<InterruptEvent>): void;
}
```
## cl.multimedia.media.001 VideoRecorder相关接口变更为systemapi
录制在MR版本会提供正式的AVRecorder(音视频合一)的接口给外部用户使用。
VideoRecorder相关的api9接口变更为systemapi,当前只提供给系统用户使用,未来等内部用户都切换为AVRecorder之后,废弃VideoRecorder相关接口。
**变更影响**
如果VideoRecorder的调用者非系统用户,会调用失败。
涉及接口以及枚举如下:
function createVideoRecorder(callback: AsyncCallback<VideoRecorder>): void;
function createVideoRecorder(): Promise<VideoRecorder>;
type VideoRecordState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error';
interface VideoRecorder{
prepare(config: VideoRecorderConfig, callback: AsyncCallback<void>): void;
prepare(config: VideoRecorderConfig): Promise<void>;
getInputSurface(callback: AsyncCallback<string>): void;
getInputSurface(): Promise<string>;
start(callback: AsyncCallback<void>): void;
start(): Promise<void>;
pause(callback: AsyncCallback<void>): void;
pause(): Promise<void>;
resume(callback: AsyncCallback<void>): void;
resume(): Promise<void>;
stop(callback: AsyncCallback<void>): void;
stop(): Promise<void>;
release(callback: AsyncCallback<void>): void;
release(): Promise<void>;
reset(callback: AsyncCallback<void>): void;
reset(): Promise<void>;
on(type: 'error', callback: ErrorCallback): void;
readonly state: VideoRecordState;
}
interface VideoRecorderProfile {
readonly audioBitrate: number;
readonly audioChannels: number;
readonly audioCodec: CodecMimeType;
readonly audioSampleRate: number;
readonly fileFormat: ContainerFormatType;
readonly videoBitrate: number;
readonly videoCodec: CodecMimeType;
readonly videoFrameWidth: number;
readonly videoFrameHeight: number;
readonly videoFrameRate: number;
}
enum AudioSourceType {
AUDIO_SOURCE_TYPE_DEFAULT = 0,
AUDIO_SOURCE_TYPE_MIC = 1,
}
enum VideoSourceType {
VIDEO_SOURCE_TYPE_SURFACE_YUV = 0,
VIDEO_SOURCE_TYPE_SURFACE_ES = 1,
}
enum VideoRecorderConfig {
audioSourceType?: AudioSourceType;
videoSourceType: VideoSourceType;
profile: VideoRecorderProfile;
url: string;
rotation?: number;
location?: Location;
}
## cl.multimedia.media.002 VideoPlayer中不对外提供多码率选择接口
VideoPlayer在API9中不对外提供多码率选择相关接口,相关接口会在MR版本中由AvPlayer提供。
**变更影响**
VideoPlayer多码率场景无法进行码率选择,相关功能由AVPlayer提供
**关键的接口/组件变更**
删除如下接口
interface VideoPlayer {
selectBitrate(bitrate: number): Promise<number>;
selectBitrate(bitrate: number, callback: AsyncCallback<number>): void;
on(type: 'availableBitratesCollect', callback: (bitrates: Array<number>) => void): void;
}
## cl.multimedia.media.003 VideoRecorder错误信息变更
VideoRecorder原有错误码与整体错误码规则不一致,变更错误码适配规则。
**变更影响**
VideoRecorder返回的错误码发生变更。
**关键的接口/组件变更**
VideoRecorder接口未发生变更,返回的错误码发生变更。
**适配指导**
异常处理具体参考接口文档。
https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-media.md
https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errorcode-media.md
# 电源子系统ChangeLog
## cl.powermgr.1 API错误信息返回方式变更
下列API使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9进行变更。
- 耗电统计:[@ohos.batteryStatistics](../../../application-dev/reference/apis/js-apis-batteryStatistics.md)
- 屏幕亮度:[@ohos.brightness](../../../application-dev/reference/apis/js-apis-brightness.md)
- 系统电源管理:[@ohos.power](../../../application-dev/reference/apis/js-apis-power.md)
- Runninglock锁:[@ohos.runningLock](../../../application-dev/reference/apis/js-apis-runninglock.md)
- 热管理:[@ohos.thermal](../../../application-dev/reference/apis/js-apis-thermal.md)
异步接口:通过AsyncCallback或Promise的error对象返回错误信息。
同步接口:通过抛出异常的方式返回错误信息。
#### 变更影响
基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
#### 关键的接口/组件变更
在以下接口增加错误码处理:
- getBatteryStats(callback: AsyncCallback<Array&lt;BatteryStatsInfo&gt;>): void
- getAppPowerValue(uid: number): number
- getAppPowerPercent(uid: number): number
- getHardwareUnitPowerValue(type: ConsumptionType): number
- getHardwareUnitPowerPercent(type: ConsumptionType): number
- setValue(value: number): void
- shutdown(reason: string): void;
- isActive(): boolean
- wakeup(detail: string): void
- suspend(): void
- getPowerMode(): DevicePowerMode
- setPowerMode(mode: DevicePowerMode, callback: AsyncCallback&lt;void&gt;): void
- setPowerMode(mode: DevicePowerMode): Promise&lt;void&gt;
- hold(timeout: number): void
- isHolding(): boolean
- unhold(): void
- isSupported(type: RunningLockType): boolean
- isSupported(type: RunningLockType): boolean
- create(name: string, type: RunningLockType, callback: AsyncCallback&lt;RunningLock&gt;): void
- create(name: string, type: RunningLockType): Promise&lt;RunningLock&gt;
- registerThermalLevelCallback(callback: Callback&lt;ThermalLevel&gt;): void
- unregisterThermalLevelCallback(callback?: Callback&lt;void&gt;): void
- getLevel(): ThermalLevel
#### 适配指导
请参考各接口的API参考。
## cl.powermgr.2 系统接口变更
#### 变更影响
基于此前版本开发的应用,需适配新接口名和错误信息返回方式,否则会影响原有业务逻辑。
#### 关键的接口/组件变更
| 包名 | 旧接口 | 新接口 |
| ----------- | ------------------------------------ | ------------------------------ |
| @ohos.power | shutdownDevice(reason: string): void | shutdown(reason: string): void |
| @ohos.power | rebootDevice(reason: string): void | reboot(reason: string): void |
| @ohos.power | wakeupDevice(detail: string): void | wakeup(detail: string): void |
| @ohos.power | suspendDevice(): void | suspend(): void |
#### 适配指导
请参考系统电源管理[@ohos.power](../../../application-dev/reference/apis/js-apis-power.md)的API参考。
# 上传下载子系统ChangeLog
OpenHarmony 3.2.8.1版本相较于OpenHarmony 3.2.beta3版本,request子系统的API变更如下
## cl.request.1 错误码定义及API部分接口名称变更
- 新增上传下载接口的[错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errorcode-request.md)处理。
- 错误信息通过AsyncCallback或Promise的error对象返回。其中,参数类型和数量错误信息,通过抛出异常的方式返回。
- API部分接口需要用新的接口替换,参数不变。
**变更影响**
基于此前版本开发的应用,需适配变更后的新错误码和错误信息返回方式,否则会影响原有业务逻辑。
**关键的接口/组件变更**
| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 |
|--------------|--------------|-----------------------------------------------------------------------------------------------------------------------|-----------|
| ohos.request | request | EXCEPTION_PERMISSION | 新增 |
| ohos.request | request | EXCEPTION_PARAMCHECK | 新增 |
| ohos.request | request | EXCEPTION_UNSUPPORTED | 新增 |
| ohos.request | request | EXCEPTION_FILEIO | 新增 |
| ohos.request | request | EXCEPTION_FILEPATH | 新增 |
| ohos.request | request | EXCEPTION_SERVICE | 新增 |
| ohos.request | request | EXCEPTION_OTHERS | 新增 |
| ohos.request | request | ERROR_OFFLINE | 新增 |
| ohos.request | request | ERROR_UNSUPPORTED_NETWORK_TYPE | 新增 |
| ohos.request | request | function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; | 新增 |
| ohos.request | request | function downloadFile(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>; | 新增 |
| ohos.request | request | function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void; | 新增 |
| ohos.request | request | function uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask>; | 新增 |
| ohos.request | DownloadTask | delete(callback: AsyncCallback<boolean>): void; | 新增 |
| ohos.request | DownloadTask | delete(): Promise<boolean>; | 新增 |
| ohos.request | DownloadTask | suspend(callback: AsyncCallback<boolean>): void; | 新增 |
| ohos.request | DownloadTask | suspend(): Promise<boolean>; | 新增 |
| ohos.request | DownloadTask | restore(callback: AsyncCallback<boolean>): void; | 新增 |
| ohos.request | DownloadTask | restore(): Promise<boolean>; | 新增 |
| ohos.request | DownloadTask | getTaskInfo(callback: AsyncCallback<DownloadInfo>): void; | 新增 |
| ohos.request | DownloadTask | getTaskInfo(): Promise<DownloadInfo>; | 新增 |
| ohos.request | DownloadTask | getTaskMimeType(callback: AsyncCallback<string>): void; | 新增 |
| ohos.request | DownloadTask | getTaskMimeType(): Promise<string>; | 新增 |
| ohos.request | UploadTask | delete(callback: AsyncCallback<boolean>): void; | 新增 |
| ohos.request | UploadTask | delete(): Promise<boolean>; | 新增 |
| ohos.request | request | function download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void;<br>代替接口:function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; | 废弃 |
| ohos.request | request | function download(config: DownloadConfig): Promise<DownloadTask>;<br>代替接口:function downloadFile(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>; | 废弃 |
| ohos.request | request | function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void;<br>代替接口:function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; | 废弃 |
| ohos.request | request | function download(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>;<br>代替接口:function downloadFile(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>; | 废弃 |
| ohos.request | request | function upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void;<br>代替接口:function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void; | 废弃 |
| ohos.request | request | function upload(config: UploadConfig): Promise<UploadTask>;<br>代替接口:function uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask>; | 废弃 |
| ohos.request | request | function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void;<br>代替接口:function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void; | 废弃 |
| ohos.request | request | function upload(context: BaseContext, config: UploadConfig): Promise<UploadTask>;<br>代替接口:function uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask>; | 废弃 |
| ohos.request | DownloadTask | remove(callback: AsyncCallback<boolean>): void;<br>代替接口:delete(callback: AsyncCallback<boolean>): void | 废弃 |
| ohos.request | DownloadTask | remove(): Promise<boolean>;<br>代替接口:delete(): Promise<boolean>; | 废弃 |
| ohos.request | DownloadTask | pause(callback: AsyncCallback<boolean>): void;<br>代替接口:suspend(callback: AsyncCallback<boolean>): void; | 废弃 |
| ohos.request | DownloadTask | pause(): Promise<boolean>;<br>代替接口:suspend(): Promise<boolean>; | 废弃 |
| ohos.request | DownloadTask | resume(callback: AsyncCallback<boolean>): void;<br>代替接口:restore(callback: AsyncCallback<boolean>): void; | 废弃 |
| ohos.request | DownloadTask | resume(): Promise<boolean>;<br>代替接口:restore(): Promise<boolean>; | 废弃 |
| ohos.request | DownloadTask | query(callback: AsyncCallback<DownloadInfo>): void;<br>代替接口:getTaskInfo(callback: AsyncCallback<DownloadInfo>): void; | 废弃 |
| ohos.request | DownloadTask | query(): Promise<DownloadInfo>;<br>代替接口:getTaskInfo(): Promise<DownloadInfo>; | 废弃 |
| ohos.request | DownloadTask | queryMimeType(callback: AsyncCallback<string>): void;<br>代替接口:getTaskMimeType(callback: AsyncCallback<string>): void; | 废弃 |
| ohos.request | DownloadTask | queryMimeType(): Promise<string>;<br>代替接口:getTaskMimeType(): Promise<string>; | 废弃 |
| ohos.request | UploadTask | remove(callback: AsyncCallback<boolean>): void;<br>代替接口:delete(callback: AsyncCallback<boolean>): void; | 废弃 |
| ohos.request | UploadTask | remove(): Promise<boolean>;<br>代替接口:delete(): Promise<boolean>; | 废弃 |
| system.request | UploadResponse | code | 废弃 |
| system.request | UploadResponse | data | 废弃 |
| system.request | UploadResponse | headers | 废弃 |
| system.request | DownloadResponse | token | 废弃 |
| system.request | OnDownloadCompleteResponse | uri | 废弃 |
| system.request | RequestFile | filename | 废弃 |
| system.request | RequestFile | name | 废弃 |
| system.request | RequestFile | uri | 废弃 |
| system.request | RequestFile | type | 废弃 |
| system.request | RequestData | name | 废弃 |
| system.request | RequestData | value | 废弃 |
| system.request | UploadRequestOptions | url | 废弃 |
| system.request | UploadRequestOptions | data | 废弃 |
| system.request | UploadRequestOptions | files | 废弃 |
| system.request | UploadRequestOptions | header | 废弃 |
| system.request | UploadRequestOptions | description | 废弃 |
| system.request | UploadRequestOptions | success | 废弃 |
| system.request | UploadRequestOptions | fail | 废弃 |
| system.request | UploadRequestOptions | complete | 废弃 |
| system.request | OnDownloadCompleteOptions | token | 废弃 |
| system.request | OnDownloadCompleteOptions | success | 废弃 |
| system.request | OnDownloadCompleteOptions | fail | 废弃 |
| system.request | OnDownloadCompleteOptions | complete | 废弃 |
| system.request | Request | static upload(options: UploadRequestOptions): void; | 废弃 |
| system.request | Request | static download(options: DownloadRequestOptions): void; | 废弃 |
| system.request | Request | static onDownloadComplete(options: OnDownloadCompleteOptions): void; | 废弃 |
**适配指导**
以downloadFile为例,在新版本上需要使用如下方式进行调用:
```ts
try {
request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
return;
}
});
} catch (err) {
console.log("downloadFile callback fail." + "errCode:" + err.code + ",errMessage:" + err.message);
}
```
\ No newline at end of file
# 资源管理changeLog
## cl.resourceManager.1 资源API9部分多工程接口命名变更
资源管理从API9开始提供接口的错误码和错误信息返回,涉及API9提供的部分多工程接口需要适配。从API9开始作以下变更:
资源API部分多工程接口需要用新的接口替换,参数不变。
**变更影响**
基于此前版本开发的应用,涉及下面多工程接口的JS接口需要替换为新的接口。
**关键接口/组件变更**
| **涉及接口** | **对应替换接口** |
| ---------------- | ------------ |
| getString(resource: Resource, </br>callback: AsyncCallback\<string>): void; | getStringValue(resource: Resource, </br>callback: AsyncCallback\<string>): void; |
| getString(resource: Resource): Promise\<string>; | getStringValue(resource: Resource): Promise\<string>; |
| getStringArray(resource: Resource, </br>callback: AsyncCallback\<Array\<string>>): void; | getStringArrayValue(resource: Resource, </br>callback: AsyncCallback\<Array\<string>>): void; |
| getStringArray(resource: Resource): Promise\<Array\<string>>; | getStringArrayValue(resource: Resource): Promise\<Array\<string>>; |
| getMedia(resource: Resource, </br>callback: AsyncCallback\<Uint8Array>): void; | getMediaContent(resource: Resource, </br>callback: AsyncCallback\<Uint8Array>): void; |
| getMedia(resource: Resource): Promise\<Uint8Array>; | getMediaContent(resource: Resource): Promise\<Uint8Array>; |
| getMediaBase64(resource: Resource, </br>callback: AsyncCallback\<string>): void; | getMediaContentBase64(resource: Resource, </br>callback: AsyncCallback\<string>): void; |
| getMediaBase64(resource: Resource): Promise\<string>; | getMediaContentBase64(resource: Resource): Promise\<string>; |
| getPluralString(resource: Resource, num: number, </br>callback: AsyncCallback<string>): void; | getPluralStringValue(resource: Resource, num: number, </br>callback: AsyncCallback\<string>): void; |
| getPluralString(resource: Resource, num: number): Promise\<string>; | getPluralStringValue(resource: Resource, num: number): Promise\<string>; |
**适配指导**
以getMedia修改为getMediaContent的callback调用为例,其promise方式类似,只需修改函数名,且增加错误码和错误信息返回,其它不变。示例代码如下:
- 变更前:getMedia(resource: Resource, callback: AsyncCallback<Uint8Array>): void;
```ts
let resource = {
bundleName: "com.example.myapplication",
moduleName: "entry",
id: $r('app.media.test').id
};
this.context.resourceManager.getMedia(resource, (error, value) => {
if (error != null) {
console.log("error is " + error);
} else {
let media = value;
}
});
```
- 变更后:getMediaContent(resource: Resource, callback: AsyncCallback<Uint8Array>): void;
```ts
let resource = {
bundleName: "com.example.myapplication",
moduleName: "entry",
id: $r('app.media.test').id
};
try {
this.context.resourceManager.getMediaContent(resource, (error, value) => {
if (error != null) {
console.log("error is " + error);
} else {
let media = value;
}
});
} catch (error) {
console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`)
}
```
......@@ -62,4 +62,4 @@ promise.then(data => {
}).catch(err => {
console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`);
});
```
\ No newline at end of file
```
# 测试子系统ChangeLog
## cl.testfwk_arkxtest.1 On、Driver、Component类接口新增支持异常处理
API8原有接口废弃,API9新增替代接口,API9接口支持异常处理,需使用try catch捕获接口抛出的异常。
## 变更影响
此变更影响@ohos.uitest提供的api9-JS接口。用户此前在测试用例开发中使用了@ohos.uitest-api9接口的,需要进行适配才可以在新版本SDK环境正常编译通过。
## 关键的接口/组件变更
- 废弃API8原有的`By`类,在API9中使用`On`类代替,`On`类接口新增支持异常处理机制;类内接口名称保持不变,**例外**`By#key`接口替换为`On.id`
- 废弃API8原有的`BY`对象,在API9中使用`ON`对象代替。
- 废弃API8原有的`UiDriver`类,在API9中使用`Driver`类代替,`Driver`类接口新增支持异常处理机制;类内接口名称保持不变。
- 废弃API8原有的`UiComponent`类,在API9中使用`Component`类代替,`Component`类接口新增支持异常处理机制;类内接口名称保持不变。
## 适配指导
### 1.适配接口名称变更
可按照如下规则做类名替换:
- `By-->On`
- `BY-->ON`
- `UiDriver-->Driver`
- `UiComponent-->Component`
### 2.捕获处理异常
使用try-catch处理接口捕获可能抛出的异常,例如:
```typescript
import {Driver,ON,Component} from '@ohos.uitest'
try {
let driver = Driver.create();
} catch (error) {
// error handle; error.code为错误码
}
```
\ No newline at end of file
# 主题框架changeLog
## cl.theme.1 API9接口支持异常处理
下列模块内部接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。在API9进行变更。
- 壁纸管理服务:@ohos.wallpaper.d.ts
- 锁屏管理服务:@ohos.screenLock.d.ts
以上模块中的接口变更为:
同步接口:通过抛出异常的方式返回错误信息。
异步接口:参数检查错误同步抛出,业务逻辑错误通过AsyncCallback或Promise的error对象抛出。
**变更影响**
基于此前版本开发的应用,需适配接口的错误信息返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
以下标记为壁纸管理服务接口废除:
- getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<RgbaColor>>): void;
- getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>>;
- getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void;
- getId(wallpaperType: WallpaperType): Promise<number>;
- getMinHeight(callback: AsyncCallback<number>): void;
- getMinHeight(): Promise<number>;
- getMinWidth(callback: AsyncCallback<number>): void;
- getMinWidth(): Promise<number>;
- isChangePermitted(callback: AsyncCallback<boolean>): void;
- isChangePermitted(): Promise<boolean>;
- isOperationAllowed(callback: AsyncCallback<boolean>): void;
- isOperationAllowed(): Promise<boolean>;
- reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
- reset(wallpaperType: WallpaperType): Promise<void>;
- setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
- setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>;
- getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void;
- getFile(wallpaperType: WallpaperType): Promise<number>;
- getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void;
- getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap>;
壁纸管理服务替代接口如下:
- getColorsSync(wallpaperType: WallpaperType): Array<RgbaColor>;
- getIdSync(wallpaperType: WallpaperType): number;
- getMinHeightSync(): number;
- getMinWidthSync(): number;
- isChangeAllowed(): boolean;
- isUserChangeAllowed(): boolean;
- restore(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
- restore(wallpaperType: WallpaperType): Promise<void>;
- setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
- setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>;
- getFileSync(wallpaperType: WallpaperType): number;
- getImage(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void;
- getImage(wallpaperType: WallpaperType): Promise<image.PixelMap>;
以下标记为壁纸管理服务接口变更:
- on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void
- off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void
以下标记为锁屏管理服务接口废除:
- isScreenLocked(callback: AsyncCallback<boolean>): void;
- isScreenLocked(): Promise<boolean>;
- isSecureMode(callback: AsyncCallback<boolean>): void;
- isSecureMode(): Promise<boolean>;
- unlockScreen(callback: AsyncCallback<void>): void;
- unlockScreen(): Promise<void>;
锁屏管理服务替代接口如下:
- isLocked(): boolean;
- isSecure(): boolean;
- unlock(callback: AsyncCallback<boolean>): void;
- unlock():Promise<boolean>;
以下标记为锁屏管理服务接口删除:
- lockScreen(callback: AsyncCallback<void>): void;
- lockScreen(): Promise<void>;
以下标记为锁屏管理服务接口新增:
- lock(callback: AsyncCallback<boolean>): void;
- lock():Promise<boolean>;
以下标记为锁屏管理服务接口变更:
- onSystemEvent(callback: Callback<SystemEvent>): boolean;
- sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void;
- sendScreenLockEvent(event: String, parameter: number): Promise<boolean>;
**壁纸管理服务适配指导**
异步接口以getImage为例,示例代码如下:
```ts
import pointer from '@ohos.wallpaper';
try {
wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getImage: ${JSON.stringify(data)}`);
}).catch((error) => {
console.error(`failed to getImage because: ${JSON.stringify(error)}`);
});
} catch (err) {
console.error(`failed to getImage because: ${JSON.stringify(err)}`);
}
```
同步接口以getFileSync为例,示例代码如下:
```ts
import pointer from '@ohos.wallpaper';
try {
let file = wallpaper.getFileSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM);
} catch (err) {
console.error(`failed to getFileSync because: ${err.message}`);
}
```
**锁屏管理服务适配指导**
异步接口以lock为例,示例代码如下:
```ts
import screenLock from '@ohos.screenlock';
try {
screenLock.lock((err, data) => {
if (err) {
console.error(`Failed to lock the screen, because: ${err.message}`);
return;
}
console.info(`lock the screen successfully. result: ${data}`);
});
} catch (err) {
console.error(`Failed to lock the screen, because: ${err.message}`);
}
```
同步接口以onSystemEvent为例,示例代码如下:
```ts
import screenLock from '@ohos.screenlock';
try {
let isSuccess = screenLock.onSystemEvent((event) => {
console.log(`Register the system event which related to screenlock successfully. eventType: ${event.eventType}`)
});
} catch (err) {
console.error(`Failed to register the system event which related to screenlock, because: ${err.message}`)
}
```
# 用户IAM子系统Changelog
## cl.useriam.1 API异常处理方式变更
用户IAM部分接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。从API9开始作以下变更:
接口通过抛出异常的方式返回错误信息。
**变更影响**
基于此版本以前开发的应用不受影响,以后的需适配变更接口的错误信息返回方式,否则会影响业务逻辑。
**关键接口/组件变更**
为适配统一的API异常处理方式,对用户IAM相关接口进行废弃(下表中 原接口 列内容),并新增对应接口(下表中 新接口 列内容)。新增接口支持统一的错误码异常处理规范,功能上与原接口保持一致。
| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 |
| ---------------------- | ------------------- | ------------------------- | ------------------------ |
| ohos.userIAM.userAuth | UserAuth | constructor() | 废弃 |
| ohos.userIAM.userAuth | UserAuth | getVersion() : number | 废弃 |
| ohos.userIAM.userAuth | UserAuth | getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number | 废弃 |
| ohos.userIAM.userAuth | UserAuth | auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array | 废弃 |
| ohos.userIAM.userAuth | UserAuth | cancelAuth(contextID : Uint8Array) : number | 废弃 |
| ohos.userIAM.userAuth | IUserAuthCallback | onResult: (result : number, extraInfo : AuthResult) => void | 废弃 |
| ohos.userIAM.userAuth | IUserAuthCallback | onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void | 废弃 |
| ohos.userIAM.userAuth | AuthResult | AuthResult {</br>token ?: Uint8Array; </br>remainTimes ?: number; </br>freezingTime ?: number;} | 废弃 |
| ohos.userIAM.userAuth | 枚举 | ResultCode {</br>SUCCESS = 0, </br>FAIL = 1, </br>GENERAL_ERROR = 2, </br>CANCELED = 3, </br>TIMEOUT = 4, </br>TYPE_NOT_SUPPORT = 5, </br>TRUST_LEVEL_NOT_SUPPORT = 6, </br>BUSY = 7, </br>INVALID_PARAMETERS = 8, </br>LOCKED = 9, </br>NOT_ENROLLED = 10,} | 废弃 |
| ohos.userIAM.userAuth | type | AuthEventKey = "result" | 新增 |
| ohos.userIAM.userAuth | type | EventInfo = AuthResultInfo | 新增 |
| ohos.userIAM.userAuth | AuthResultInfo | AuthResultInfo {</br>result : number; </br>token ?: Uint8Array; </br>remainAttempts ?: number; </br>lockoutDuration ?: number;} | 新增 |
| ohos.userIAM.userAuth | TipInfo | TipInfo {</br>module : number; </br>tip : number;} | 新增 |
| ohos.userIAM.userAuth | AuthInstance | AuthInstance {</br>on: (name: AuthEventKey, callback: AuthEvent) => void; </br>off: (name: AuthEventKey) => void; </br>start: () => void; </br>cancel: () => void;} | 新增 |
| ohos.userIAM.userAuth | 枚举 | ResultCodeV9 {</br>SUCCESS = 12500000, </br>FAIL = 12500001, </br>GENERAL_ERROR = 12500002, </br>CANCELED = 12500003, </br>TIMEOUT = 12500004, </br>TYPE_NOT_SUPPORT = 12500005, </br>TRUST_LEVEL_NOT_SUPPORT = 12500006, </br>BUSY = 12500007, </br>LOCKED = 12500009, </br>NOT_ENROLLED = 12500010,} | 新增 |
| ohos.userIAM.userAuth | function | getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel : AuthTrustLevel) : AuthInstance | 新增 |
| ohos.userIAM.userAuth | function | getVersion() : number | 新增 |
| ohos.userIAM.userAuth | function | getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : void | 新增 |
| ohos.userIAM.faceAuth | FaceAuthManager | setSurfaceId(surfaceId : string) : ResultCode | 删除 |
| ohos.userIAM.faceAuth | 枚举 | ResultCode {</br>SUCCESS = 0, </br>FAIL = 1,} | 删除 |
| ohos.userIAM.faceAuth | FaceAuthManager | setSurfaceId(surfaceId: string) : void | 新增 |
**适配指导**
以getVersion接口为例,示例代码如下:
```js
import userIAM_userAuth from '@ohos.userIAM.userAuth';
try {
let version = userIAM_userAuth.getVersion();
console.info("auth version = " + version);
} catch (error) {
console.info("get version failed, error = " + error);
}
```
更多接口的示例代码可参考[用户认证API文档](../../../application-dev/reference/apis/js-apis-useriam-userauth.md)[人脸认证API文档](../../../application-dev/reference/apis/js-apis-useriam-faceauth.md)
## cl.useriam.2 接口调用权限变更
用户IAM部分接口只允许被系统应用调起,需要做系统应用运行时鉴权。从API9开始作以下变更:
人脸认证模块的setSurfaceId接口增加判别是否为系统应用的逻辑,非系统应用无法调用该接口。
**变更影响**
基于此版本以前开发的应用不受影响,以后的需要持有相应权限,否则无法正常调用接口。
**关键接口/组件变更**
setSurfaceId接口的实现中增加系统应用鉴权处理,非系统应用调用将返回202错误码。
**适配指导**
需要修改[应用签名](https://gitee.com/openharmony/developtools_hapsigner/tree/master/dist)相关文件UnsgnedReleasedProfileTemplate.json,其中的app-feature字段要改为"hos_system_app",才可保证签名所得到的应用是系统应用。
# wantAgent的JS API变更Changelog
OpenHarmony 3.2.9.1 sp8版本相较于OpenHarmony 3.2.8.1版本,wantAgent的API变更如下
## cl.url.1.trigger类接口变更
trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void ;
因部分功能未实现,已对其进行删除,应用可调用下面接口进行替代:
trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback<CompleteData>): void
**变更影响**
影响已发布的JS接口,应用需要进行适配,才可以在新版本SDK环境正常编译通过。
**关键的接口/组件变更**
| OpenHarmony 3.2.8.1版本接口 | OpenHarmony 3.2.9.1 sp8版本接口 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void ; | trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback<CompleteData>): void |
**适配指导**
应用中调用替代的trigger接口可参考下列代码
示例:
```ts
import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
// triggerInfo
var triggerInfo = {
code: 0
}
//WantAgentInfo对象
var wantAgentInfo = {
wants: [
{
deviceId: "deviceId",
bundleName: "com.neu.setResultOnAbilityResultTest1",
abilityName: "com.example.test.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
//getWantAgent回调
function getWantAgentCallback(err, data) {
if (err == undefined) {
wantAgent = data;
} else {
console.info('getWantAgent failed' + JSON.stringify(wantAgent));
}
//getUid回调
function triggerCallback(err, data) {
if(err) {
console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
} else {
console.info('getUid ok!' + JSON.stringify(data));
}
}
try {
WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
} catch(err) {
console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
}
}
try{
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err){
console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
}
```
# ArkUI子系统LocalStorage类接口ChangeLog
## cl.LocalStorage.1 get接口返回类型变更
**变更影响**
返回类型从get<T>(propName: string): T变更为get<T>(propName: string): T | undefined
应用不需要进行适配。
## cl.LocalStorage.2 setOrCreate参数newValue变成必选
**变更影响**
原接口声明:
```js
setOrCreate<T>(propName: string, newValue?: T): boolean
```
现接口声明:
```js
setOrCreate<T>(propName: string, newValue: T): boolean
```
第二个参数newValue变为必选。
如果应用调用这个接口没有指定newValue参数,在替换新的sdk后会编译不过,需要手动指定newValue。
**适配指导**
```js
let storage = new LocalStorage();
storage.setOrCreate('propA', 'hello');
```
## cl.LocalStorage.3 link参数和返回类型变更
**变更影响**
原接口声明:
```js
link<T>(propName: string, linkUser?: T, subscribersName?: string): T
```
现接口声明:
```js
link<T>(propName: string): SubscribedAbstractProperty<T>
```
1. link第二三个参数为框架内部调用,不应对外开发,所以将接口变更为一个参数;
2. 返回类型T变更为SubscribedAbstractProperty;
**适配指导**
```js
let storage = new LocalStorage({"PropA": "47"});
let linA = storage.link("PropA");
linA.set(50);
```
## cl.LocalStorage.4 setAndLink参数和返回类型变更
**变更影响**
原接口声明:
```js
setAndLink<T>(propName: string, defaultValue: T, linkUser?: T, subscribersName?: string): T
```
现接口声明:
```js
setAndLink<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>
```
1. setAndLink第三四个参数为框架内部调用,不应对外开发,所以将接口变更为2个参数;
2. 返回类型T变更为SubscribedAbstractProperty;
**适配指导**
```js
let storage = new LocalStorage({"PropA": "47"});
let linA = storage.setAndLink("PropA", "48")
linA.set(50);
```
## cl.LocalStorage.5 prop参数和返回类型变更
**变更影响**
原接口声明:
```js
prop<T>(propName: string, propUser?: T, subscribersName?: string): T
```
现接口声明:
```js
prop<S>(propName: string): SubscribedAbstractProperty<S>
```
1. prop第二三个参数为框架内部调用,不应对外开发,所以将接口变更为1个参数;
2. 返回类型T变更为SubscribedAbstractProperty;
**适配指导**
```js
let storage = new LocalStorage({"PropA": "47"});
let propA = storage.prop("PropA");
propA.set(51); // one-way sync
```
## cl.LocalStorage.6 setAndProp参数和返回类型变更
**变更影响**
原接口声明:
```js
setAndProp<T>(propName: string, defaultValue: T, propUser?: T, subscribersName?: string): T
```
现接口声明:
```js
setAndProp<S>(propName: string, defaultValue: S): SubscribedAbstractProperty<S>
```
1. setAndProp第三四个参数为框架内部调用,不应对外开发,所以将接口变更为2个参数;
2. 返回类型T变更为SubscribedAbstractProperty;
**适配指导**
```js
let storage = new LocalStorage({"PropA": "47"});
let propA = storage.setAndProp("PropA", "48");
propA.set(51); // one-way sync
```
\ No newline at end of file
# 资源调度子系统ChangeLog
## cl.resourceschedule.backgroundTaskManager
对资源调度子系统backgroundTaskManager仓原有接口进行整改,原有@ohos.backgroundTaskManager.d.ts中的API9接口删除,需要使用@ohos.resourceschedule.backgroundTaskManager.d.ts中的API9新接口。新的API9接口符合错误码规范。
**变更影响**
基于OpenHarmony3.2.10.5及之后的SDK版本开发的应用,需适配API9的模块和接口,以及的API异常处理返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
以下方法、属性、枚举和常量均从API9变更。@ohos.backgroundTaskManager.d.ts文件中的接口移植到@ohos.resourceschedule.backgroundTaskManager.d.ts文件。
| 类名 | 接口类型 | 接口声明 | 说明 |
| -- | -- | -- | -- |
| backgroundTaskManager | method | function resetAllEfficiencyResources(): void; | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager | method | function applyEfficiencyResources(request: EfficiencyResourcesRequest): bool; | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts,修改为function applyEfficiencyResources(request: EfficiencyResourcesRequest): void; |
| backgroundTaskManager.ResourceType | enum | export enum ResourceType | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.ResourceType | enum | CPU = 1 | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.ResourceType | enum | COMMON_EVENT = 1 << 1 | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.ResourceType | enum | TIMER = 1 << 2 | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.ResourceType | enum | WORK_SCHEDULER = 1 << 3 | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.ResourceType | enum | BLUETOOTH = 1 << 4 | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.ResourceType | enum | GPS = 1 << 5 | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.ResourceType | enum | AUDIO = 1 << 6 | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.EfficiencyResourcesRequest | interface | export interface EfficiencyResourcesRequest | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.EfficiencyResourcesRequest | field | reason: string | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.EfficiencyResourcesRequest | field | isProcess?: bool | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.EfficiencyResourcesRequest | field | isPersist?: bool | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.EfficiencyResourcesRequest | field | timeOut: number | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.EfficiencyResourcesRequest | field | isApply: bool | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
| backgroundTaskManager.EfficiencyResourcesRequest | field | resourceTypes: number | 接口API9删除,移植到ohos.resourceschedule.backgroundTaskManager.d.ts |
**适配指导**<br>
导入backgroundTaskManager模块。
```
import bundle form '@ohos.resourceschedule.backgroundTaskManager'
```
此外还需要适配异常处理,具体参考[backgroundTaskManager接口文档](../../../application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md)
## c2.resourceschedule.workScheduler
对资源调度子系统workScheduler仓原有接口进行整改,原有@ohos.workScheduler.d.ts中的API9接口删除,需要使用@ohos.resourceschedule.workScheduler.d.ts中的API9新接口。新的API9接口符合错误码规范。
**变更影响**
基于OpenHarmony3.2.10.5及之后的SDK版本开发的应用,需适配API9的模块和接口,以及的API异常处理返回方式,否则会影响原有业务逻辑。
**关键接口/组件变更**
以下方法、属性、枚举和常量均从API9变更。删除@ohos.workScheduler.d.ts文件,相关接口变更至@ohos.resourceschedule.workScheduler.d.ts文件中。
| 类名 | 接口类型 | 接口声明 | 变更类型 |
| -- | -- | -- | -- |
| workScheduler | namespace | declare namespace workScheduler | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | interface | export interface WorkInfo | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | parameters?: {[key: string]: any} | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | idleWaitTime?: number | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | isDeepIdle?: boolean | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | repeatCount?: number | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | isRepeat?: boolean | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | repeatCycleTime?: number | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | storageRequest?: StorageRequest | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | batteryStatus?: BatteryStatus | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | batteryLevel?: number | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | chargerType?: ChargingType | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | isCharging?: boolean | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | networkType?: NetworkType | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | isPersisted?: boolean | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | abilityName: string | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | bundleName: string | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.WorkInfo | field | workId: number | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler | method | function isLastWorkTimeOut(workId: number): Promise; | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler | method | function isLastWorkTimeOut(workId: number, callback: AsyncCallback<void>): boolean; | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler | method | function stopAndClearWorks(): boolean; | 接口API8变更,移植到ohos.resourceschedule.workScheduler.d.ts,修改为function stopAndClearWorks(): boolean; |
| workScheduler | method | function obtainAllWorks(): Promise<Array<WorkInfo>>; | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler | method | function obtainAllWorks(callback: AsyncCallback<void>): Array<WorkInfo>; | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler | method | function getWorkStatus(workId: number): Promise<WorkInfo>; | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler | method | function getWorkStatus(workId: number, callback: AsyncCallback<WorkInfo>): void; | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler | method | function stopWork(work: WorkInfo, needCancel?: boolean): boolean; | 接口API8变更,移植到ohos.resourceschedule.workScheduler.d.ts,修改为function stopWork(work: WorkInfo, needCancel?: boolean): void; |
| workScheduler | method | function startWork(work: WorkInfo): boolean; | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts,修改为function startWork(work: WorkInfo): void; |
| workScheduler.NetworkType | enum | export enum NetworkType | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.NetworkType | enum | NETWORK_TYPE_ANY = 0 | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.NetworkType | enum | NETWORK_TYPE_MOBILE | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.NetworkType | enum | NETWORK_TYPE_WIFI | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.NetworkType | enum | NETWORK_TYPE_BLUETOOTH | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.NetworkType | enum | NETWORK_TYPE_WIFI_P2P | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.NetworkType | enum | NETWORK_TYPE_ETHERNET | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.ChargingType | enum | export enum ChargingType | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.ChargingType | enum | CHARGING_PLUGGED_ANY = 0 | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.ChargingType | enum | CHARGING_PLUGGED_AC | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.ChargingType | enum | CHARGING_PLUGGED_USB | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.ChargingType | enum | CHARGING_PLUGGED_WIRELESS | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.BatteryStatus | enum | export enum BatteryStatus | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.BatteryStatus | enum | BATTERY_STATUS_LOW = 0 | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.BatteryStatus | enum | BATTERY_STATUS_OKAY | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.BatteryStatus | enum | BATTERY_STATUS_LOW_OR_OKAY | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.StorageRequest | enum | export enum StorageRequest | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.BatteryStatus | enum | STORAGE_LEVEL_LOW = 0 | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.BatteryStatus | enum | STORAGE_LEVEL_OKAY | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
| workScheduler.BatteryStatus | enum | STORAGE_LEVEL_LOW_OR_OKAY | 接口API9删除,移植到ohos.resourceschedule.workScheduler.d.ts |
**适配指导**<br>
导入workScheduler模块。
```
import bundle form '@ohos.resourceschedule.workScheduler'
```
此外还需要适配异常处理,具体参考[workScheduler接口文档](../../../application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md)
......@@ -344,3 +344,132 @@ getTbsInfo() : DataBlob;
查看API参考中对应的接口适配指南:
[证书-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-cert.md)
## cl.security.21 HUKS支持No-Hash的签名模式
变更之前,应用传递huks.HuksTag.HUKS_TAG_DIGEST = huks.HuksKeyDigest.HUKS_DIGEST_NONE,HUKS默认使用huks.HuksKeyDigest.HUKS_DIGEST_SHA256进行处理;变更之后,应用传递huks.HuksTag.HUKS_TAG_DIGEST = huks.HuksKeyDigest.HUKS_DIGEST_NONE时,HUKS默认不进行摘要处理,需要业务先对原始数据进行hash操作,再将hash后的摘要传入huks进行签名/验签处理。
**变更影响**
影响已发布的JS接口,接口行为发生变更。
应用需要进行适配,才可以使得变更前后的签名/验签结果通过。
**关键的接口/组件变更**
发布的JS接口不变, 传入接口的参数集合发生变更。
业务使用No-Hash的签名模式,需要先对原始数据进行hash处理,再将hash后的摘要传入huks签名/验签接口。同时huks.HuksTag.HUKS_TAG_DIGEST参数设置为huks.HuksKeyDigest.HUKS_DIGEST_NONE。
**适配指导**
以签名为例,示例代码如下:
```js
import huks from '@ohos.security.huks';
let keyAlias = 'rsa_Key';
/* sha256之后的摘要值 */
let inDataAfterSha256 = new Uint8Array(
0x4B, 0x1E, 0x22, 0x64, 0xA9, 0x89, 0x60, 0x1D, 0xEC, 0x78, 0xC0, 0x5D, 0xBE, 0x46, 0xAD, 0xCF,
0x1C, 0x35, 0x16, 0x11, 0x34, 0x01, 0x4E, 0x9B, 0x7C, 0x00, 0x66, 0x0E, 0xCA, 0x09, 0xC0, 0xF3,
);
/* 签名参数 */
let signProperties = new Array();
signProperties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_RSA,
}
signProperties[1] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value:
huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN
}
signProperties[2] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048,
}
signProperties[3] = {
tag: huks.HuksTag.HUKS_TAG_DIGEST,
value: huks.HuksKeyDigest.HUKS_DIGEST_NONE, // 设置 digest-none
}
let signOptions = {
properties: signProperties,
inData: inDataAfterSha256 // 设置HASH后的值
}
huks.initSession(keyAlias, signOptions);
```
更多接口的示例代码可参考[HUKS-guidelines](../../../application-dev/security/huks-guidelines.md)[HUKS API](../../../application-dev/reference/apis/js-apis-huks.md)
## cl.security.22 HUKS支持在密钥使用时指定密钥运算参数
变更之前,业务在生成密钥的时候,必须指定密钥运算的全部参数;变更之后,在生成密钥时,只需要包含必选参数即可,在密钥使用阶段再传入其他参数。业务使用会更加灵活。
**变更影响**
影响已发布的JS接口,接口行为发生变更。
允许应用在生成密钥阶段传入的参数中包含必选参数即可,在密钥使用阶段再传入其他可选参数。
**关键的接口/组件变更**
发布的JS接口不变, 传入接口的参数集合发生变更,将参数分为必选参数和可选参数,具体可参考[HUKS-guidelines](../../../application-dev/security/huks-guidelines.md),涉及的接口有:
huks.generateKeyItem
huks.importKeyItem
huks.importWrappedKeyItem
huks.initSession
huks.updateSession
huks.finishSession
**适配指导**
以生成密钥为例,示例代码如下:
```js
let keyAlias = 'keyAlias';
let properties = new Array();
//必选参数
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_RSA
};
//必选参数
properties[1] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
};
//必选参数
properties[2] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value:
huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN |
huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
};
//可选参数,如果在生成密钥阶段没有传入,则在使用密钥阶段必须传入。
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_DIGEST,
value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
};
let options = {
properties: properties
};
try {
huks.generateKeyItem(keyAlias, options, function (error, data) {
if (error) {
console.error(`callback: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`);
} else {
console.info(`callback: generateKeyItem key success`);
}
});
} catch (error) {
console.error(`callback: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`);
}
```
更多接口的示例代码可参考[HUKS-guidelines](../../../application-dev/security/huks-guidelines.md)[HUKS API](../../../application-dev/reference/apis/js-apis-huks.md)
# xxx子系统ChangeLog
相比最近一个发布版本(包括不限于LTS、Release、Beta、monthly版本)发生了影响契约兼容性(契约兼容:也称语义兼容,指版本演进后,开发者原有程序行为不发生变化)的变更(包括不限于接口名、参数、返回值、所需要的权限、调用顺序、枚举值、配置参数、路径等),则需要在ChangeLog中对变更进行阐述。
## cl.subsystemname.x xxx功能变更, 例:DeviceType属性变更、相机权限变更(尽量概括,不要超过15个字)
每个变更标题前需要附加编号:cl.subsystemname.x。cl为ChangeLog首字母缩写,subsystemname请填写子系统英文标准名称,x表示变更序号(从低到高逐位增加,起始为1)。
以功能维度对变更点进行概括描述。例如:xxx功能的xxx、xxx等发生了xxx变化,开发者需要根据以下说明对应用进行适配。
如果有此变更有对应的需求或设计文档,可以在描述中附上对应的设计文档编号。
**变更影响**
是否影响已发布的接口或者接口行为发生变更,影响的是JS接口还是Native接口。
是否影响在此前版本已开发的应用,即应用是否需要进行适配动才可以在新版本SDK环境正常编译通过。
**关键的接口/组件变更**
列举此功能变更涉及的接口/组件变更。
**适配指导(可选,不涉及则可以删除)**
提供指导,帮助开发者针对相关变更进行适配,使应用可以与新版本兼容。
例:
在xxx文件中将xxx参数修改为xxx。
```
sample code
```
# 元能力子系统JS API变更Changelog
OpenHarmony 3.2.10.1(Mr)版本相较于OpenHarmony 3.2.beta4版本,元能力子系统的API变更如下
## cl.ability.1 接口迁移
ability子系统UIAbilityContext的接口requestPermissionsFromUser迁移到security子系统:
之前权限弹窗应用是基于UIAbility实现的,需要借助于UIAbilityContext的startAbilityForResult接口把授权结果带回给调用方,故把requestPermissionsFromUser接口暂时放在UIAbilityContext中。现在权限弹窗应用切换为基于ServiceExtensionAbility实现,不再需要借助UIAbilityContext的startAbilityForResult接口,因此把requestPermissionsFromUser接口迁移到security子系统。
开发者需要根据以下说明对应用进行适配。
**变更影响**
影响API9版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
**关键的接口/组件变更**
| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 |
| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
| application/UIAbilityContext | UIAbilityContext | requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>): void; | 删除 |
| application/UIAbilityContext | UIAbilityContext | requestPermissionsFromUser(permissions: Array<string>): Promise<PermissionRequestResult>; | 删除 |
| @ohos.abilityAccessCtrl | AtManager | requestPermissionsFromUser(context: Context, permissions: Array<Permissions>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; | 新增 |
| @ohos.abilityAccessCtrl | AtManager | requestPermissionsFromUser(context: Context, permissions: Array<Permissions>) : Promise<PermissionRequestResult>; | 新增 |
**适配指导**
应用中调用requestPermissionsFromUser拉起权限弹窗应用可参考下列代码
Stage模型下的示例:
```ts
import abilityAccessCtrl from '@ohos.abilityAccessCtrl.d.ts';
//UIAbility的onWindowStageCreate生命周期
onWindowStageCreate() {
let AtManager = abilityAccessCtrl.createAtManager();
//requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
AtManager.requestPermissionsFromUser(this.context, ["ohos.permission.MANAGE_DISPOSED_APP_STATUS"]).then((data) => {
console.log("data type:" + typeof(data));
console.log("data:" + data);
console.log("data permissions:" + data.permissions);
console.log("data result:" + data.authResults);
}).catch((err) => {
console.error('Failed to start ability', err.code);
})
}
```
## cl.ability.2 删除标记为废弃的API9接口
[元能力异常处理整改](../OpenHarmony_3.2.8.3/changelogs-ability.md)将部分API9接口标记为了废弃,根据OpenHarmony接口规范,需要删除标记为废弃的API9接口。
**变更影响**
基于此前版本开发的应用,需要将被删除的接口替换为新接口,否则会影响应用编译。
**关键接口/组件变更**
接口文件被删除:
| 被删除接口 | 新接口 |
| ----------------------------------------------- | ----------------------------------------------- |
| @ohos.application.Ability.d.ts | @ohos.app.ability.UIAbility.d.ts |
| @ohos.application.AbilityConstant.d.ts | @ohos.app.ability.AbilityConstant.d.ts |
| @ohos.application.AbilityLifecycleCallback.d.ts | @ohos.app.ability.AbilityLifecycleCallback.d.ts |
| @ohos.application.AbilityStage.d.ts | @ohos.app.ability.AbilityStage.d.ts |
| @ohos.application.EnvironmentCallback.d.ts | @ohos.app.ability.EnvironmentCallback.d.ts |
| @ohos.application.ExtensionAbility.d.ts | @ohos.app.ability.ExtensionAbility.d.ts |
| @ohos.application.FormExtension.d.ts | @ohos.app.form.FormExtensionAbility.d.ts |
| @ohos.application.ServiceExtensionAbility.d.ts | @ohos.app.ability.ServiceExtensionAbility.d.ts |
| @ohos.application.StartOptions.d.ts | @ohos.app.ability.StartOptions.d.ts |
| @ohos.application.context.d.ts | @ohos.app.ability.common.d.ts |
| @ohos.application.errorManager.d.ts | @ohos.app.ability.errorManager.d.ts |
接口、属性被删除:
- @ohos.application.Configuration.d.ts
- Configuration 的 direction、screenDensity、displayId、hasPointerDevice 被删除。可以使用 @ohos.app.ability.Configuration.d.ts 的 Configuration替换。
- @ohos.application.ConfigurationConstant.d.ts
- 枚举 Direction 和 ScreenDensity 被删除。可以使用 @ohos.app.ability.ConfigurationConstant.d.ts 的枚举 Direction 和 ScreenDensity 替换。
- @ohos.application.abilityManager.d.ts
- 方法 getExtensionRunningInfos 和 getTopAbility 被删除。可以使用 @ohos.app.ability.abilityManager.d.ts 的同名方法替换。
- @ohos.application.appManager.d.ts
- 枚举 ApplicationState 和 ProcessState 被删除。可以使用 @ohos.app.ability.appManager.d.ts 的枚举 ApplicationState 和 ProcessState 替换。
- 方法 registerApplicationStateObserver 和 getProcessRunningInformation被删除。可以使用 @ohos.app.ability.appManager.d.ts 的同名方法替换。
- @ohos.application.formHost.d.ts
- 方法 shareForm 和 notifyFormsPrivacyProtected 被删除。可以使用 @ohos.app.form.formHost.d.ts 的同名方法替换。
- @ohos.application.formInfo.d.ts
- 枚举 FormType 的 eTS 被删除,可以使用 @ohos.app.form.formInfo.d.ts 的 FormType 中的 eTS 替换。
- 枚举 FormParam 的 IDENTITY_KEY、BUNDLE_NAME_KEY、ABILITY_NAME_KEY、DEVICE_ID_KEY 被删除,可以使用 @ohos.app.form.formInfo.d.ts 的 FormParam 中的同名枚举替换。
- 接口 FormInfoFilter 被删除。可以使用 @ohos.app.form.formInfo.d.ts 的 FormInfoFilter 替换。
- 枚举 FormDimension 被删除。可以使用 @ohos.app.form.formInfo.d.ts 的 FormDimension 替换。
- 枚举 VisibilityType 被删除。可以使用 @ohos.app.form.formInfo.d.ts 的 VisibilityType 替换。
- @ohos.wantAgent.d.ts
- 方法 trigger 和 getOperationType 被删除。可以使用 @ohos.app.ability.wantAgent.d.ts 的同名方法替换。
- application/ApplicationContext.d.ts
- 方法 registerAbilityLifecycleCallback、unregisterAbilityLifecycleCallback、registerEnvironmentCallback、unregisterEnvironmentCallback 被删除。可以使用 on、off 替换。
- application/ServiceExtensionContext.d.ts
- 方法 connectAbility、connectAbilityWithAccount、disconnectAbility 被删除。可以使用 connectServiceExtensionAbility、connectServiceExtensionAbilityWithAccount、disconnectServiceExtensionAbility 替换。
- @ohos.application.FormExtension.d.ts
- 生命周期onCreate、onCastToNormal、onUpdate、onVisibilityChange、onEvent、onDestroy、onAcquireFormState、onShare 被删除。可以使用@ohos.app.form.FormExtensionAbility.d.ts的onAddForm、onCastToNormalForm、onUpdateForm、onChangeFormVisibility、onFormEvent、onRemoveForm、onAcquireFormState、onShareForm
- @ohos.application.abilityDelegatorRegistry.d.ts
- 导出类 AbilityDelegator、AbilityDelegatorArgs、AbilityMonitor、ShellCmdResult 被删除。可以使用@ohos.app.ability.abilityDelegatorRegistry.d.ts中的同名导出类替换。
- @ohos.application.abilityManager.d.ts
- 导出类 AbilityRunningInfo、ExtensionRunningInfo 被删除。可以使用@ohos.app.ability.abilityManager.d.ts中的同名导出类替换。
- @ohos.application.appManager.d.ts
- 导出类 AbilityStateData、AppStateData、ApplicationStateObserver、ProcessRunningInfo、ProcessRunningInformation 被删除。可以使用@ohos.app.ability.appManager.d.ts中的同名导出类替换。
- @ohos.application.missionManager.d.ts
- 导出类 MissionInfo、MissionListener、MissionSnapshot 被删除。可以使用@ohos.app.ability.missionManager.d.ts中的同名导出类替换。
- @ohos.wantAgent.d.ts
- 导出类 TriggerInfo、WantAgentInfo 被删除。可以使用@ohos.app.ability.wantAgent.d.ts中的同名导出类替换。
**适配指导**
如上所述,仅少数接口修改了接口名的如注册回调函数(registerAbilityLifecycleCallback、unregisterAbilityLifecycleCallback、registerEnvironmentCallback、unregisterEnvironmentCallback)和连接断开 ServiceExtensionAbility(connectAbility、connectAbilityWithAccount、disconnectAbility),卡片生命周期等需要替换成新的接口名。
绝大多数接口平移到了新的namespace中,所以可以通过修改import来解决适配问题:
如原先接口使用了@ohos.application.Ability
```js
import Ability from '@ohos.application.Ability';
```
可以通过直接修改import,来切换到新的namespace上:
```js
import Ability from '@ohos.app.ability.UIAbility';
```
此外还需要适配异常处理,具体参考新接口的接口文档。
## cl.ability.2 appRecovery接口中RestartFlag属性名称变更,删除了未支持的属性
appRecovery接口中RestartFlag枚举命名从特定故障发生后**不重启**改成了特定故障发生后**重启**
删除了CPP_CRASH_NO_RESTART。
**变更影响**
3.2.10.6版本之前使用CPP_CRASH_NO_RESTART/JS_CRASH_NO_RESTART/APP_FREEZE_NO_RESTART类型开发的应用,在3.2.10.6版本之后行为会发生变化。
**关键接口/组件变更**
**RestartFlag** <sup>9+</sup>
变更前:
| 名称 | 值 | 说明 |
| --------------------- | ------ | -------------------------------- |
| ALWAYS_RESTART | 0 | 总是重启应用。 |
| CPP_CRASH_NO_RESTART | 0x0001 | 发生CPP_CRASH时**不重启**应用。 |
| JS_CRASH_NO_RESTART | 0x0002 | 发生JS_CRASH时**不重启**应用。 |
| APP_FREEZE_NO_RESTART | 0x0004 | 发生APP_FREEZE时**不重启**应用。 |
| NO_RESTART | 0xFFFF | 总是不重启应用。 |
变更后:
| 名称 | 值 | 说明 |
| ----------------------- | ------ | ------------------------------ |
| ALWAYS_RESTART | 0 | 总是重启应用。 |
| CPP_CRASH_NO_RESTART | NA | **删除**,不支持该场景的重启。 |
| RESTART_WHEN_JS_CRASH | 0x0001 | 发生JS_CRASH时**重启**应用。 |
| RESTART_WHEN_APP_FREEZE | 0x0002 | 发生APP_FREEZE时**重启**应用。 |
| NO_RESTART | 0xFFFF | 总是不重启应用。 |
**适配指导**
按新的语义进行适配。
# 帐号子系统changeLog
## cl.account_os_account.1 createOsAccountForDomain错误码变更
使用createOsAccountForDomain重复创建域帐号时,变更前返回的错误码为12300001,变更后返回的错误码为12300004。
错误信息由通用系统报错细化为帐号已存在报错。
**变更影响**
基于此前版本开发的应用,需适配变更后的错误码,否则会影响原有业务逻辑。
**关键接口/组件变更**
- AccountManager
- createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;);
- createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise&lt;OsAccountInfo&gt;;
**适配指导**
重复创建域帐号的示例代码如下:
```ts
import account_osAccount from "@ohos.account.osAccount"
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) {
console.log("activateOsAccount err: " + JSON.stringify(err)); // error.code = 12300004;
}
```
## cl.account_os_account.2 应用帐号getAllAccounts接口权限场景变更
应用使用getAllAccounts接口查询自己可访问的帐号列表时,不需要申请权限ohos.permission.GET_ALL_APP_ACCOUNTS。
**变更影响**
基于此后版本开发的应用,查询自己可访问的帐号列表时,无需申请权限。
**关键接口/组件变更**
- AccountManager
- getAllAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void;
- getAllAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;;
**适配指导**
应用未申请ohos.permission.GET_ALL_APP_ACCOUNTS,查询自己可访问的帐号列表示例代码如下:
```ts
import account_appAccount from "@ohos.account.appAccount"
let accountMgr = account_appAccount.createAppAccountManager();
try {
await accountMgr.addAccount("accessibleAccount_promise_nopermission");
var data = await accountMgr.getAllAccounts();
if (data[0].name == "accessibleAccount_promise_nopermission") {
console.log("getAllAccounts successfully");
}
} catch (err) {
console.log("getAllAccounts err: " + JSON.stringify(err));
}
```
## cl.account_os_account.3 应用帐号getAccountsByOwner接口权限场景变更
应用使用getAccountsByOwner接口查询可访问的指定应用的帐号列表时,不需要申请权限ohos.permission.GET_ALL_APP_ACCOUNTS。
**变更影响**
基于此后版本开发的应用,查询指定应用可访问的帐号列表时,无需申请权限。
**关键接口/组件变更**
- AccountManager
- getAccountsByOwner(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void;
- getAccountsByOwner(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;;
**适配指导**
应用未申请ohos.permission.GET_ALL_APP_ACCOUNTS,查询指定应用可访问的帐号列表示例代码如下:
```ts
import account_appAccount from "@ohos.account.appAccount"
let accountMgr = account_appAccount.createAppAccountManager();
try {
var ownerName = "com.example.owner";
var data = await accountMgr.getAllAccounts(ownerName);
} catch (err) {
console.log("getAllAccounts err: " + JSON.stringify(err));
}
```
\ No newline at end of file
# 包管理子系统ChangeLog
## cl.bundlemanager.1 API9的ApplicationInfo结构体字段变更,删除entryDir字段。
API9的ApplicationInfo结构体[[bundleManager/applicationInfo.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/monthly_20221018/api/bundleManager/applicationInfo.d.ts)]字段变更,删除entryDir字段。
**变更影响**<br>
对使用API version 8及之前版本SDK的应用无影响,使用API version 9的应用需要适配新模块和新接口。
**关键的接口/组件变更**<br>
ApplicationInfo结构体发生变化的字段内容如下表所示。
| 删除 | API9新增或变更 | 类型 |
| --- | --- | --- |
| entryDir | 无 | string |
**适配指导**<br>
导入包管理查询的模块,在API9 version的ApplicationInfo结构体时,使用了entryDir需要进行修改,该字段属于多余字段。
## cl.bundlemanager.2 API9的HapModuleInfo结构体字段变更,删除moduleSourceDir字段。
API9的HapModuleInfo结构体[[bundleManager/hapModuleInfo.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/monthly_20221018/api/bundleManager/hapModuleInfo.d.ts)]字段变更,删除moduleSourceDir字段。
**变更影响**<br>
对使用API version 8及之前版本SDK的应用无影响,使用API version 9的应用需要适配新模块和新接口。
**关键的接口/组件变更**<br>
HapModuleInfo结构体发生变化的字段内容如下表所示。
| 删除 | API9新增或变更 | 类型 |
| --- | --- | --- |
| moduleSourceDir | 无 | string |
**适配指导**<br>
导入包管理查询的模块,在API9 version的HapModuleInfo结构体时不能使用moduleSourceDir字段。使用了moduleSourceDir需要进行修改,该字段属于多余字段。
# commonlibrary子系统JS API变更Changelog
OpenHarmony 3.2.10.1(Mr)版本相较于OpenHarmony 3.2.beta4版本,container子系统的API变更如下
## cl.公共基础类库子系统.1 错误码及信息变更
公共基础类库子系统子系统中ArrayList、List、LinkedList、Stack、Queue、Deque、PlainArray、LightWeightMap、LightWeightSet、HashMap、HashSet、TreeMap、TreeSet类的接口抛出的错误码及信息变更:
变更后的错误码详细介绍请参见[语言基础类库错误码](../../../application-dev/reference/errorcodes/errorcode-utils.md)
已使用相关接口开发的应用无需重新适配。
**关键的接口/组件变更**
各个类中的接口重新定义了错误码抛出的信息,并在对应模块的`*.d.ts`声明文件中通过'@throws'标签进行标示。
示例如下:
ArrayList类变更前:
constructor();
ArrayList类变更后:
@throws { BusinessError } 10200012 - The ArrayList's constructor cannot be directly invoked.
constructor();
**变更影响**
暂无影响。
......@@ -66,11 +66,10 @@ try {
## cl.distributeddatamgr.2 function getRdbStoreV9 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts
**变更影响**
getRdbStoreV9接口标记废弃,应用需要进行适配
应用需要进行适配,才可以在新版本SDK环境正常编译通过
**关键的接口/组件变更**
如下接口:
```ts
function getRdbStoreV9(context: Context, config: StoreConfigV9, version: number, callback: AsyncCallback<RdbStoreV9>): void;
function getRdbStoreV9(context: Context, config: StoreConfigV9, version: number): Promise<RdbStoreV9>;
......@@ -87,11 +86,10 @@ function getRdbStore(context: Context, config: StoreConfig): Promise<RdbStore>;
## cl.distributeddatamgr.3 function deleteRdbStoreV9 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts
**变更影响**
deleteRdbStoreV9接口标记废弃,应用需要进行适配
应用需要进行适配,才可以在新版本SDK环境正常编译通过
**关键的接口/组件变更**
如下接口:
```ts
function deleteRdbStoreV9(context: Context, name: string, callback: AsyncCallback<void>): void;
function deleteRdbStoreV9(context: Context, name: string): Promise<void>;
......@@ -108,7 +106,7 @@ function deleteRdbStoreV9(context: Context, name: string): Promise<void>;
## cl.distributeddatamgr.4 interface StoreConfigV9 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts
**变更影响**
StoreConfigV9接口标记废弃,应用需要进行适配
应用需要进行适配,才可以在新版本SDK环境正常编译通过
**关键的接口/组件变更**
interface StoreConfigV9 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts 改名为interface StoreConfig。
......@@ -119,7 +117,7 @@ interface StoreConfigV9 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalSto
## cl.distributeddatamgr.5 enum SecurityLevel 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts
**变更影响**
SecurityLevel接口标记废弃,应用需要进行适配
应用需要进行适配,才可以在新版本SDK环境正常编译通过
**关键的接口/组件变更**
enum SecurityLevel 从ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts。
......@@ -130,7 +128,7 @@ enum SecurityLevel 从ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.t
## cl.distributeddatamgr.6 interface RdbStoreV9 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts
**变更影响**
RdbStoreV9接口标记废弃,应用需要进行适配
应用需要进行适配,才可以在新版本SDK环境正常编译通过
**关键的接口/组件变更**
interface RdbStoreV9 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts 改名为interface RdbStore。
......@@ -141,7 +139,7 @@ interface RdbStoreV9 从@ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.
## cl.distributeddatamgr.7 class RdbPredicatesV9 从ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts
**变更影响**
RdbPredicatesV9接口标记废弃,应用需要进行适配
应用需要进行适配,才可以在新版本SDK环境正常编译通过
**关键的接口/组件变更**
class RdbPredicatesV9 从ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.d.ts 改名为interface RdbPredicates。
......@@ -152,7 +150,7 @@ class RdbPredicatesV9 从ohos.data.rdb.d.ts 迁移至@ohos.data.relationalStore.
## cl.distributeddatamgr.8 interface ResultSetV9 从api/@ohos.data.relationalStore.d.ts 迁移至@ohos.data.relationalStore.d.ts
**变更影响**
ResultSetV9接口标记废弃,应用需要进行适配
应用需要进行适配,才可以在新版本SDK环境正常编译通过
**关键的接口/组件变更**
interface ResultSetV9 从api/data/rdb/resultSet.d.ts 迁移至@ohos.data.relationalStore.d.ts 改名为interface ResultSet。
......
# 文件管理子系统ChangeLog
## cl.filemanagement.1 environment模块变更
文件管理子系统d.ts归档整改,现统一整改到file一层目录下。environment模块支持错误码处理。
**变更影响**
基于此前版本开发的应用,需注意d.ts位置的变更及import模块名的变更。现environment模块支持错误码处理,需注意错误码处理的使用。[相关适配指导参考](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md)
**关键接口/组件变更**
原environment使用的是@ohos.environment,以以下方式import:
```js
import environment from '@ohos.environment';
```
现environment使用的是@ohos.file.environment,以以下方式import:
```js
import environment from '@ohos.file.environment';
```
## cl.filemanagement.2 securityLabel模块变更
文件管理子系统d.ts归档整改,现统一整改到file一层目录下。securityLabel模块支持错误码处理。
**变更影响**
基于此前版本开发的应用,需注意d.ts位置的变更及import模块名的变更。现securityLabel模块支持错误码处理,需注意错误码处理的使用。[相关适配指导参考](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md)
**关键接口/组件变更**
原securityLabel使用的是@ohos.securityLabel,以以下方式import:
```js
import securityLabel from '@ohos.securityLabel';
```
现securityLabel使用的是@ohos.file.securityLabel,以以下方式import:
```js
import securityLabel from '@ohos.file.securityLabel';
```
## cl.filemanagement.3 fs模块变更
fs模块下Stat接口ino属性类型变更。
**变更影响**
fs模块下Stat接口ino属性类型变更,由number变更为bigint,以适配文件系统下所有类型文件的inode范围。
**关键接口/组件变更**
原Stat接口ino属性类型为number,现变更为bigint。
## cl.filemanagement.4 fileAccess模块变更
文件管理子系统d.ts归档整改,现统一整改到file一层目录下。fileAccess模块支持错误码处理。
**变更影响**
基于此前版本开发的应用,需注意d.ts位置的变更及import模块名的变更。现fileAccess模块支持错误码处理,需注意错误码处理的使用。[相关适配指导参考](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md)
**关键接口/组件变更**
原fileAccess使用的是@ohos.data.fileAccess,以以下方式import:
```js
import fileAccess from '@ohos.data.fileAccess';
```
现fileAccess使用的是@ohos.file.fileAccess,以以下方式import:
```js
import fileAccess from '@ohos.file.fileAccess';
```
## cl.filemanagement.5 fileExtensionInfo模块变更
文件管理子系统d.ts归档整改,现统一整改到file一层目录下。fileExtensionInfo模块支持错误码处理。
**变更影响**
基于此前版本开发的应用,需注意d.ts位置的变更及import模块名的变更。现fileExtensionInfo模块支持错误码处理,需注意错误码处理的使用。[相关适配指导参考](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md)
**关键接口/组件变更**
原fileExtensionInfo使用的是@ohos.fileExtensionInfo,以以下方式import:
```js
import fileExtensionInfo from '@ohos.fileExtensionInfo';
```
现fileExtensionInfo使用的是@ohos.file.fileExtensionInfo,以以下方式import:
```js
import fileExtensionInfo from '@ohos.file.fileExtensionInfo';
```
## cl.filemanagement.6 storageStatistics模块变更
文件管理子系统d.ts归档整改,现统一整改到file一层目录下。fileExtensionInfo模块支持错误码处理。
**变更影响**
基于此前版本开发的应用,需注意d.ts位置的变更及import模块名的变更。现storageStatistics模块支持错误码处理,需注意错误码处理的使用。[相关适配指导参考](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md)
**关键接口/组件变更**
原storageStatistics使用的是@ohos.storageStatistics,以以下方式import:
```js
import storageStatistics from '@ohos.storageStatistics';
```
现storageStatistics使用的是@ohos.file.storageStatistics,以以下方式import:
```js
import storageStatistics from '@ohos.file.storageStatistics';
```
## cl.filemanagement.7 volumeManager模块变更
文件管理子系统d.ts归档整改,现统一整改到file一层目录下。fileExtensionInfo模块支持错误码处理。
**变更影响**
基于此前版本开发的应用,需注意d.ts位置的变更及import模块名的变更。现volumeManager模块支持错误码处理,需注意错误码处理的使用。[相关适配指导参考](../OpenHarmony_3.2.8.1/changelogs-filemanagement.md)
**关键接口/组件变更**
原volumeManager使用的是@ohos.volumeManager,以以下方式import:
```js
import volumeManager from '@ohos.volumeManager';
```
现volumeManager使用的是@ohos.file.volumeManager,以以下方式import:
```js
import volumeManager from '@ohos.file.volumeManager';
```
# 输入法框架changeLog
## cl.inputmethod_frameworks.1 API文件名变更
下列模块不符合OpenHarmony接口文件名命名规范。在API9进行变更。
**变更影响**
修改后的SDK与先前已发布版本不兼容,影响在此前版本已开发的应用,应用需要进行适配改动才可以在新版本SDK环境正常编译通过。
**关键的接口/组件变更**
| 模块 | 变更前文件名 | 变更后文件名 |
|------|--------------|--------------|
| 输入法框架模块 | @ohos.inputmethod.d.ts |@ohos.inputMethod.d.ts |
| 输入法服务模块 |@ohos.inputmethodengine.d.ts | @ohos.inputMethodEngine.d.ts |
| 输入法ExtentionAbility模块 | @ohos.inputmethodextensionability.d.ts | @ohos.InputMethodExtensionAbility.d.ts |
| 输入法ExtentionContext模块 |@ohos.inputmethodextensioncontext.d.ts | @ohos.InputMethodExtensionContext.d.ts |
| 输入法子类型模块 | @ohos.inputMethodSubtype.d.ts | @ohos.InputMethodSubtype.d.ts |
**适配指导**
应用中对输入法框架d.ts文件的import后的文件名要写为变更后文件名,即小驼峰/大驼峰命名格式。
如:
```js
import inputMethodEngine from '@ohos.inputMethodEngine';
```
\ No newline at end of file
# 文件子系统ChangeLog
## cl.file.1 mediaLibrary相关接口变更
multimedia 部件 medialibrary 接口废弃原有相关接口,使用 FilePicker 替代。
**变更影响**
基于此前版本开发的应用,需注意废弃接口的迭代更新。替代的 FilePicker 应用是OpenHarmony中预置的系统应用,为用户提供文件选择及保存功能。
**关键接口/组件变更**
medialibrary 相关接口废弃,原接口位于 @ohos.multimedia.medialibrary;替代应用为 FilePicker,位于[@ohos.file.picker](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.file.picker.d.ts)
| 模块名 | 方法/属性/枚举/常量 | 变更类型 |
| ------------------------- | ------------------------------------------------------------ | -------- |
| medialibrary | **function** getMediaLibrary(): MediaLibrary; | 废弃 |
| medialibrary | **function** getMediaLibrary(context: Context): MediaLibrary; | 废弃 |
| medialibrary | **function** getFileAssets(options: MediaFetchOptions, callback: AsyncCallback\<FetchFileResult\>): void | 废弃 |
| medialibrary | **function** getFileAssets(options: MediaFetchOptions): Promise\<FetchFileResult\> | 废弃 |
| medialibrary | **function** on(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback: Callback\<void\>): void | 废弃 |
| medialibrary | **function** off(type: 'deviceChange'\|'albumChange'\|'imageChange'\|'audioChange'\|'videoChange'\|'fileChange'\|'remoteFileChange', callback?: Callback\<void\>): void | 废弃 |
| medialibrary | **function** createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback\<FileAsset\>): void | 废弃 |
| medialibrary | **function** createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise\<FileAsset\> | 废弃 |
| medialibrary | **function** deleteAsset(uri: string): Promise\<void\> | 废弃 |
| medialibrary | **function** deleteAsset(uri: string, callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** getPublicDirectory(type: DirectoryType, callback: AsyncCallback\<string\>): void | 废弃 |
| medialibrary | **function** getPublicDirectory(type: DirectoryType): Promise\<string\> | 废弃 |
| medialibrary | **function** getAlbums(options: MediaFetchOptions, callback: AsyncCallback\<Array\<Album\>\>): void | 废弃 |
| medialibrary | **function** getAlbums(options: MediaFetchOptions): Promise\<Array\<Album\>\> | 废弃 |
| medialibrary | **function** release(callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** release(): Promise\<void\> | 废弃 |
| medialibrary | **function** storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback\<string\>): void | 废弃 |
| medialibrary | **function** storeMediaAsset(option: MediaAssetOption): Promise\<string\> | 废弃 |
| medialibrary | **function** startImagePreview(images: Array\<string\>, index: number, callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** startImagePreview(images: Array\<string\>, callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** startImagePreview(images: Array\<string\>, index?: number): Promise\<void\> | 废弃 |
| medialibrary | **function** startMediaSelect(option: MediaSelectOption, callback: AsyncCallback\<Array\<string\>\>): void | 废弃 |
| medialibrary | **function** startMediaSelect(option: MediaSelectOption): Promise\<Array\<string\>\> | 废弃 |
| medialibrary | **function** getActivePeers(): Promise\<Array\<PeerInfo\>\>; | 废弃 |
| medialibrary | **function** getActivePeers(callback: AsyncCallback\<Array\<PeerInfo\>\>): void; | 废弃 |
| medialibrary | **function** getAllPeers(): Promise\<Array\<PeerInfo\>\>; | 废弃 |
| medialibrary | **function** FileAsset.isDirectory(callback: AsyncCallback\<boolean\>): void | 废弃 |
| medialibrary | **function** FileAsset.isDirectory():Promise\<boolean\> | 废弃 |
| medialibrary | **function** FileAsset.commitModify(callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** FileAsset.commitModify(): Promise\<void\> | 废弃 |
| medialibrary | **function** FileAsset.open(mode: string, callback: AsyncCallback\<number\>): void | 废弃 |
| medialibrary | **function** FileAsset.open(mode: string): Promise\<number\> | 废弃 |
| medialibrary | **function** FileAsset.close(fd: number, callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** FileAsset.close(fd: number): Promise\<void\> | 废弃 |
| medialibrary | **function** FileAsset.getThumbnail(callback: AsyncCallback\<image.PixelMap\>): void | 废弃 |
| medialibrary | **function** FileAsset.getThumbnail(size: Size, callback: AsyncCallback\<image.PixelMap\>): void | 废弃 |
| medialibrary | **function** FileAsset.getThumbnail(size?: Size): Promise\<image.PixelMap\> | 废弃 |
| medialibrary | **function** FileAsset.favorite(isFavorite: boolean, callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** FileAsset.favorite(isFavorite: boolean): Promise\<void\> | 废弃 |
| medialibrary | **function** FileAsset.isFavorite(callback: AsyncCallback\<boolean\>): void | 废弃 |
| medialibrary | **function** FileAsset.isFavorite():Promise\<boolean\> | 废弃 |
| medialibrary | **function** FileAsset.trash(isTrash: boolean, callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** FileAsset.trash(isTrash: boolean): Promise\<void\> | 废弃 |
| medialibrary | **function** FileAsset.isTrash(callback: AsyncCallback\<boolean\>): void | 废弃 |
| medialibrary | **function** FileAsset.isTrash():Promise\<boolean\> | 废弃 |
| medialibrary | **function** FetchFileResult.getCount(): number | 废弃 |
| medialibrary | **function** FetchFileResult.isAfterLast(): boolean | 废弃 |
| medialibrary | **function** FetchFileResult.close(): void | 废弃 |
| medialibrary | **function** FetchFileResult.getFirstObject(callback: AsyncCallback\<FileAsset\>): void | 废弃 |
| medialibrary | **function** FetchFileResult.getFirstObject(): Promise\<FileAsset\> | 废弃 |
| medialibrary | **function** FetchFileResult.getNextObject(callback: AsyncCallback\<FileAsset\>): void | 废弃 |
| medialibrary | **function** FetchFileResult.getNextObject(): Promise\<FileAsset\> | 废弃 |
| medialibrary | **function** FetchFileResult.getLastObject(callback: AsyncCallback\<FileAsset\>): void | 废弃 |
| medialibrary | **function** FetchFileResult.getLastObject(): Promise\<FileAsset\> | 废弃 |
| medialibrary | **function** FetchFileResult.getPositionObject(index: number, callback: AsyncCallback\<FileAsset\>): void | 废弃 |
| medialibrary | **function** FetchFileResult.getPositionObject(index: number): Promise\<FileAsset\> | 废弃 |
| medialibrary | **function** FetchFileResult.getAllObject(callback: AsyncCallback\<Array\<FileAsset\>\>): void | 废弃 |
| medialibrary | **function** FetchFileResult.getAllObject(): Promise\<Array\<FileAsset\>\> | 废弃 |
| medialibrary | **function** Album.commitModify(callback: AsyncCallback\<void\>): void | 废弃 |
| medialibrary | **function** Album.commitModify(): Promise\<void\> | 废弃 |
| medialibrary | **function** Album.getFileAssets(options: MediaFetchOptions, callback: AsyncCallback\<FetchFileResult\>): void | 废弃 |
| medialibrary | **function** Album.getFileAssets(options?: MediaFetchOptions): Promise\<FetchFileResult\> | 废弃 |
| medialibrary | **enum** DeviceType | 废弃 |
| medialibrary | **enum** FileKey | 废弃 |
| medialibrary | **enum** DirectoryType | 废弃 |
| medialibrary | **enum** MediaType | 废弃 |
| medialibrary | **interface** PeerInfo | 废弃 |
| medialibrary | **interface** Size | 废弃 |
| medialibrary | **interface** MediaFetchOptions | 废弃 |
| medialibrary | **interface** MediaAssetOption | 废弃 |
| medialibrary | **interface** MediaSelectOption | 废弃 |
| medialibrary | **interface** FileAsset | 废弃 |
**适配指导**
以选取一张图片为例,在替代应用中如下方式进行调用:
```js
import picker from '@ohos.file.picker';
async function example() {
try {
let PhotoSelectOptions = new picker.PhotoSelectOptions();
PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
PhotoSelectOptions.maxSelectNumber = 1;
let photoPicker = new picker.PhotoViewPicker();
photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult) => {
if (PhotoSelectResult !== undefined) {
console.info("PhotoViewPicker.select pass, PhotoSelectResult uri: " + JSON.stringify(PhotoSelectResult));
} else {
console.error("PhotoViewPicker.select PhotoSelectResult is undefined");
}
}).catch((err) => {
console.error("PhotoViewPicker.select fail, err: " + err);
});
} catch (err) {
console.error("PhotoViewPicker fail, err: " + err);
}
}
```
\ No newline at end of file
# 公共通信子系统NFC JS API变更Changelog
OpenHarmony 3.2.10.2(Mr)版本相较于OpenHarmony 3.2.beta4版本,分布式数据管理子系统的API变更如下
## cl.nfc.1 接口变更
NFC部分API6到API8部分JS接口不支持抛出错误码,需要删除废弃,然后使用新的API9替换。
开发者需要根据以下说明对应用进行适配。
**变更影响**
影响部分API6到API8部分JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。
**关键的接口/组件变更**
| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 |
| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- |
| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | FeatureType | 废弃 |
| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | isSupported | 废弃 |
| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | hasHceCapability | 新增 |
| api/@ohos.nfc.controller.d.ts | nfcController | isNfcAvailable | 废弃 |
| api/@ohos.nfc.controller.d.ts | nfcController | openNfc | 废弃 |
| api/@ohos.nfc.controller.d.ts | nfcController | closeNfc | 废弃 |
| api/@ohos.nfc.controller.d.ts | nfcController | enableNfc | 新增 |
| api/@ohos.nfc.controller.d.ts | nfcController | disableNfc | 新增 |
| api/@ohos.nfc.tag.d.ts | tag | getNfcATag | 废弃 |
| api/@ohos.nfc.tag.d.ts | tag | getNfcBTag | 废弃 |
| api/@ohos.nfc.tag.d.ts | tag | getNfcFTag | 废弃 |
| api/@ohos.nfc.tag.d.ts | tag | getNfcVTag | 废弃 |
| api/@ohos.nfc.tag.d.ts | tag | getNfcA | 新增 |
| api/@ohos.nfc.tag.d.ts | tag | getNfcB | 新增 |
| api/@ohos.nfc.tag.d.ts | tag | getNfcF | 新增 |
| api/@ohos.nfc.tag.d.ts | tag | getNfcV | 新增 |
| api/tag/tagSession.d.ts | TagSession | getTagInfo | 废弃 |
| api/tag/tagSession.d.ts | TagSession | connectTag | 废弃 |
| api/tag/tagSession.d.ts | TagSession | reset | 废弃 |
| api/tag/tagSession.d.ts | TagSession | isTagConnected | 废弃 |
| api/tag/tagSession.d.ts | TagSession | setSendDataTimeout | 废弃 |
| api/tag/tagSession.d.ts | TagSession | getSendDataTimeout | 废弃 |
| api/tag/tagSession.d.ts | TagSession | sendData | 废弃 |
| api/tag/tagSession.d.ts | TagSession | getMaxSendLength | 废弃 |
| api/tag/tagSession.d.ts | TagSession | connect | 新增 |
| api/tag/tagSession.d.ts | TagSession | resetConnection | 新增 |
| api/tag/tagSession.d.ts | TagSession | isConnected | 新增 |
| api/tag/tagSession.d.ts | TagSession | setTimeout | 新增 |
| api/tag/tagSession.d.ts | TagSession | getTimeout | 新增 |
| api/tag/tagSession.d.ts | TagSession | transmit | 新增 |
| api/tag/tagSession.d.ts | TagSession | getMaxTransmitSize | 新增 |
**适配指导**
查看API开发指南:
[cardEmulation-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md)
[nfcController-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-nfcController.md)
[tag-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md)
[TagSession-API参考](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-tagSession.md)
```
# 事件通知子系统ChangeLog
## cl.notification.1 删除标记为废弃的API9接口
[事件通知异常处理整改](../OpenHarmony_3.2.8.3/changelogs-notification.md)将部分API9接口标记为了废弃,根据OpenHarmony接口规范,需要删除标记为废弃的API9接口。
**变更影响**
基于此前版本开发的应用,需要将被删除的接口替换为新接口,否则会影响应用编译。
**关键接口/组件变更**
原接口中标记为废弃的API9接口将被删除,可以使用新接口中的同名接口替换。
| 原接口 | 新接口 |
| ----------------------- | -------------------------------- |
| @ohos.commonEvent.d.ts | @ohos.commonEventManager.d.ts |
| @ohos.notification.d.ts | @ohos.notificationManager.d.ts |
| @ohos.notification.d.ts | @ohos.notificationSubscribe.d.ts |
接口、属性被删除:
- @ohos.notification.d.ts
- 接口 publishAsBundle、cancelAsBundle、isNotificationSlotEnabled、setSyncNotificationEnabledWithoutApp、getSyncNotificationEnabledWithoutApp 被删除。可以使用 api/@ohos.notificationManager.d.ts 的同名接口替换。
- 接口 enableNotificationSlot 被删除。可以使用 api/@ohos.notificationManager.d.ts 的接口 setNotificationEnableSlot 替换。
- 导出类 NotificationActionButton、NotificationBasicContent、NotificationContent、NotificationLongTextContent、NotificationMultiLineContent、NotificationPictureContent、NotificationFlags、NotificationFlagStatus、NotificationRequest、DistributedOptions、NotificationSlot、NotificationSorting、NotificationTemplate、NotificationUserInput 被删除。可以使用 api/@ohos.notificationManager.d.ts 的同名导出类替换。
- 导出类 NotificationSubscribeInfo、NotificationSubscriber、SubscribeCallbackData、EnabledNotificationCallbackData 被删除。可以使用 api/@ohos.notificationSubscribe.d.ts 的同名导出类替换。
**适配指导**
如上所述,仅将老接口平移到了新的namespace中,所以可以通过修改import来解决适配问题:
如原先接口使用了@ohos.commonEvent
```js
import commonEvent from '@ohos.commonEvent';
```
可以通过直接修改import,来切换到新的namespace上:
```js
import commonEvent from '@ohos.commonEventManager';
```
@ohos.notification拆分成了两个namespace,需要根据接口情况选择需要的新namespace进行适配。
此外还需要适配异常处理,具体参考新接口的接口文档。
# 上传下载子系统ChangeLog
## cl.request.2 request上传下载接口变更
- 删除API9-beta接口:
1. function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void;
2. function download(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>;
3. function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void;
4. function upload(context: BaseContext, config: UploadConfig): Promise<UploadTask>;
**变更影响**
基于此前版本使用Stage模式开发的应用,需适配变更后的接口,否则会影响原有业务逻辑。
**关键的接口/组件变更**
| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 |
|--------------|--------------|-------------------------------------------------------------------------------------------------------------------|------|
| ohos.request | request | function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; | 删除 |
| ohos.request | request | function download(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>; | 删除 |
| ohos.request | request | function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void; | 删除 |
| ohos.request | request | function upload(context: BaseContext, config: UploadConfig): Promise<UploadTask>; | 删除 |
**适配指导**
以download为例,在新版本上需要使用downloadFile, 如下方式进行调用:
```ts
try {
request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
return;
}
});
} catch (err) {
console.log("downloadFile callback fail." + "errCode:" + err.code + ",errMessage:" + err.message);
}
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册