提交 06a3c7ac 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 7df59f38
......@@ -175,23 +175,30 @@ Obtains system service information.
```js
import fs from '@ohos.file.fs'
import hidebug from '@ohos.hidebug'
import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext();
context.getFilesDir().then((data) => {
var path = data + "/serviceInfo.txt";
console.info("output path: " + path);
let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
var serviceId = 10;
var args = new Array("allInfo");
try {
hidebug.getServiceDump(serviceId, file.fd, args);
} catch (error) {
console.info(error.code);
console.info(error.message);
}
fs.closeSync(file);
})
import common from '@ohos.app.ability.common'
let applicationContext: common.Context;
try {
applicationContext = this.context.getApplicationContext();
} catch (error) {
console.info(error.code);
console.info(error.message);
}
var filesDir = applicationContext.filesDir;
var path = filesDir + "/serviceInfo.txt";
console.info("output path: " + path);
let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
var serviceId = 10;
var args = new Array("allInfo");
try {
hidebug.getServiceDump(serviceId, file.fd, args);
} catch (error) {
console.info(error.code);
console.info(error.message);
}
fs.closeSync(file);
```
## hidebug.startJsCpuProfiling<sup>9+</sup>
......
......@@ -89,9 +89,11 @@ Specifies whether background applications are allowed to access the network. Thi
**Example**
```js
policy.setBackgroundAllowed(true).then(function (error) {
console.log(JSON.stringify(error))
})
policy.setBackgroundAllowed(true).then(() => {
console.log("setBackgroundAllowed success");
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.isBackgroundAllowed<sup>10+</sup>
......@@ -164,10 +166,11 @@ Checks whether the current application is allowed to access the network when run
**Example**
```js
policy.isBackgroundAllowed().then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.isBackgroundAllowed().then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.setPolicyByUid<sup>10+</sup>
......@@ -248,9 +251,11 @@ Sets the metered network access policy for the application specified by a given
**Example**
```js
policy.setPolicyByUid(11111, policy.NetUidPolicy.NET_POLICY_NONE).then(function (error) {
console.log(JSON.stringify(error))
})
policy.setPolicyByUid(11111, policy.NetUidPolicy.NET_POLICY_NONE).then(() => {
console.log("setPolicyByUid success");
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.getPolicyByUid<sup>10+</sup>
......@@ -329,10 +334,11 @@ Obtains the network access policy for the application specified by a given UID.
**Example**
```js
policy.getPolicyByUid(11111).then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.getPolicyByUid(11111).then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.getUidsByPolicy<sup>10+</sup>
......@@ -412,10 +418,11 @@ Obtains all UIDs that match the specified network policy. This API uses a promis
**Example**
```js
policy.getUidsByPolicy(11111).then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.getUidsByPolicy(11111).then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.getNetQuotaPolicies<sup>10+</sup>
......@@ -487,11 +494,11 @@ Obtains the network quota policies. This API uses a promise to return the result
**Example**
```js
policy.getNetQuotaPolicies().then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.getNetQuotaPolicies().then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.setNetQuotaPolicies<sup>10+</sup>
......@@ -608,9 +615,11 @@ let netquotapolicy = {
netQuotaPolicyList.push(netquotapolicy);
policy.setNetQuotaPolicies(netQuotaPolicyList).then(function (error) {
console.log(JSON.stringify(error))
})
policy.setNetQuotaPolicies(netQuotaPolicyList).then(() => {
console.log("setNetQuotaPolicies success");
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.isUidNetAllowed<sup>10+</sup>
......@@ -692,10 +701,11 @@ Checks whether the application specified by a given UID is allowed to access a m
**Example**
```js
policy.isUidNetAllowed(11111, true).then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.isUidNetAllowed(11111, true).then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.isUidNetAllowed<sup>10+</sup>
......@@ -777,10 +787,11 @@ Checks whether the application specified by a given UID is allowed to access the
**Example**
```js
policy.isUidNetAllowed(11111, 'wlan0').then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.isUidNetAllowed(11111, 'wlan0').then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.setDeviceIdleTrustlist<sup>10+</sup>
......@@ -861,9 +872,11 @@ Adds applications specified by given UIDs to the device idle allowlist. This API
**Example**
```js
policy.setDeviceIdleTrustlist([11111,22222], true).then(function (error) {
console.log(JSON.stringify(error))
})
policy.setDeviceIdleTrustlist([11111,22222], true).then(() => {
console.log("setDeviceIdleTrustlist success");
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.getDeviceIdleTrustlist<sup>10+</sup>
......@@ -934,10 +947,11 @@ Obtains the UIDs of applications that are on the device idle allowlist. This API
**Example**
```js
policy.getDeviceIdleTrustlist().then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.getDeviceIdleTrustlist().then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.getBackgroundPolicyByUid<sup>10+</sup>
......@@ -1017,10 +1031,11 @@ Obtains the background network policy for the application specified by a given U
**Example**
```js
policy.getBackgroundPolicyByUid(11111).then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.getBackgroundPolicyByUid(11111).then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.resetPolicies<sup>10+</sup>
......@@ -1099,9 +1114,11 @@ Restores all the policies (cellular network, background network, firewall, and a
**Example**
```js
policy.resetPolicies('1').then(function (error) {
console.log(JSON.stringify(error))
})
policy.resetPolicies('1').then(() => {
console.log("resetPolicies success");
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.updateRemindPolicy<sup>10+</sup>
......@@ -1186,9 +1203,11 @@ Updates a reminder policy. This API uses a promise to return the result.
```js
import connection from '@ohos.net.connection';
policy.updateRemindPolicy(connection.NetBearType.BEARER_CELLULAR, '1', policy.RemindType.REMIND_TYPE_WARNING).then(function (error) {
console.log(JSON.stringify(error))
})
policy.updateRemindPolicy(connection.NetBearType.BEARER_CELLULAR, '1', policy.RemindType.REMIND_TYPE_WARNING).then(() => {
console.log("updateRemindPolicy success");
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.setPowerSaveTrustlist<sup>10+</sup>
......@@ -1269,9 +1288,11 @@ Sets whether to add the application specified by a given UID to the power-saving
**Example**
```js
policy.setPowerSaveTrustlist([11111,22222], true).then(function (error) {
console.log(JSON.stringify(error))
})
policy.setPowerSaveTrustlist([11111,22222], true).then(() => {
console.log("setPowerSaveTrustlist success");
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.getPowerSaveTrustlist<sup>10+</sup>
......@@ -1343,10 +1364,11 @@ Obtains the UID array of applications that are on the device idle allowlist. Thi
**Example**
```js
policy.getPowerSaveTrustlist().then(function (error, data) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(data))
})
policy.getPowerSaveTrustlist().then((data) => {
console.log(JSON.stringify(data));
}).catch(error => {
console.log(JSON.stringify(error));
});
```
## policy.on
......
# i18n Error Codes
# I18N Error Codes
> **NOTE**
>
......@@ -8,7 +8,7 @@
**Error Message**
Unspported para value.
param value not valid
**Description**
......@@ -17,25 +17,7 @@ This error code is reported if an I18N API is called with invalid parameter valu
**Possible Causes**
Invalid parameter values are probably due to incorrect parameter types.
**Solution**
Check whether the parameter type is correct.
## 890002 Incorrect Configuration Option
**Error Message**
param value not valid
**Description**
This error code is reported if an I18N API is called with invalid option values specified.
**Possible Causes**
Invalid option values are probably due to incorrect option types.
**Solution**
Check whether the option type is correct.
......@@ -157,8 +157,9 @@ You must install **Node.js** and HPM on your local PC. The installation procedur
2. Learn more about the distribution.
1. Read carefully the information about the distribution to learn its application scenarios, features, components, usage, and customization methods.
2. Click **Download** if you want to download the distribution to your local PC.
3. Click **Device component tailoring** if you want to add or delete components of the distribution.
2. Use either of the following modes to obtain the source code:
- Click **Download** if you want to download the distribution to your local PC.
- Click **Device component tailoring** if you want to add or delete components of the distribution.
**Figure 2** Example distribution
......@@ -200,12 +201,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L
| Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | 418.1 MB |
| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | - |
| **Source Code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
| Full code base (for mini, small, and standard systems) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/code-v4.0-Beta1.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/code-v4.0-Beta1.tar.gz.sha256)| 26.2 GB |
| Hi3861 solution (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_pegasus.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_pegasus.tar.gz.sha256)| 25.1 MB |
| Hi3516 solution-LiteOS (binary)| 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_LiteOS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_LiteOS.tar.gz.sha256)| 287.6 MB |
| Hi3516 solution-Linux (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_Linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_Linux.tar.gz.sha256)| 186.4 MB |
| RK3568 standard system solution (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/dayu200_standard_arm32.tar.gz.sha256)| 4.5 GB |
| RELEASE-NOTES | 4.0 Beta1 | [Download](../../release-notes/OpenHarmony-v4.0-beta1.md)| - | - |
| Full code base (for mini, small, and standard systems) | 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/code-v4.0-Beta2.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/code-v4.0-Beta2.tar.gz.sha256)| 27.7 GB |
| Hi3861 solution (binary) | 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_pegasus.tar.gz.sha256)| 27.5 MB |
| Hi3516 solution-LiteOS (binary)| 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_taurus_LiteOS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_taurus_LiteOS.tar.gz.sha256)| 300.9 MB |
| Hi3516 solution-Linux (binary) | 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_taurus_Linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/hispark_taurus_Linux.tar.gz.sha256)| 192.4 MB |
| RK3568 standard system solution (binary) | 4.0 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta2/dayu200_standard_arm32.tar.gz.sha256)| 5.2 GB |
| RELEASE-NOTES | 4.0 Beta2 | [Download](../../release-notes/OpenHarmony-v4.0-beta2.md) | - | - |
| **Compiler Toolchain**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
| Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | - |
......
# USB Manager Changelog
## cl.usb_manager.1 Error Information Return Method Change
The USB Manager API uses service logic return values to indicate error information, which does not comply with the API error code specifications of OpenHarmony. Beginning from API version 9, error information is returned by throwing exceptions.
**Change Impact**
The application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected.
**Key API/Component Changes**
Changed the USB module name from **@ohos.usb.d.ts** to **@ohos.usbV9.d.ts**, and added error code processing for all APIs in the module.
**Adaptation Guide**
Take the **getDevices** API as an example. The sample code is as follows:
```ts
import usbV9 from '@ohos.usbV9'
try {
usbV9.getDevices(); // If an improper parameter is passed to this API, an exception will be thrown.
} catch (err) {
console.error("getDevices errCode:" + err.code + ",errMessage:" + err.message);
}
```
# Location Subsystem ChangeLog
## cl.location.1 Migration of System APIs and APIs in API Version 9 to the New @ohos.geoLocationManager.d.ts
The APIs in **@ohos.geolocation.d.ts** do not support throwing error codes. However, APIs in API version 9 and system APIs are required to support throwing of error codes. To support this function, all system APIs and APIs in API version 9 in **@ohos.geolocation.d.ts** are migrated to the newly added **@ohos.geoLocationManager.d.ts** file, and corresponding error code description is added.
To use system APIs and APIs in API version 9 of the location subsystem, you need to import **@ohos.geoLocationManager**.
import geoLocationManager from '@ohos.geoLocationManager';
**Change Impact**
System APIs and APIs in API version 9 are affected. To ensure normal use of these APIs, you need to import **@ohos.geoLocationManager**.
import geoLocationManager from '@ohos.geoLocationManager';
Other APIs are not affected.
**Key API/Component Changes**
| Class| API Type| Declaration| Change Type|
| -- | -- | -- | -- |
|geolocation| namespace | declare namespacegeolocation| Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation | interface | export interface ReverseGeocodingMockInfo | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation | interface | export interface LocationMockConfig | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation | interface | export interface CountryCode | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation | enum | export enum CountryCodeType | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation.GeoAddress | field | isFromMock?: Boolean; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation.Location | field | isFromMock?: Boolean; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation.GeoLocationErrorCode | field | NOT_SUPPORTED = 100 | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation.GeoLocationErrorCode | field | QUERY_COUNTRY_CODE_ERROR | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation| method | function on(type: 'countryCodeChange', callback: Callback&lt;CountryCode&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation| method | function off(type: 'countryCodeChange', callback?: Callback&lt;CountryCode&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation| method | function getCountryCode(callback: AsyncCallback&lt;CountryCode&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation| method | function getCountryCode(): Promise&lt;CountryCode&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation| method | function enableLocationMock(scenario: LocationRequestScenario, callback: AsyncCallback&lt;void&gt;): void; | Deleted this API in API version 9.|
|geolocation| method | function enableLocationMock(callback: AsyncCallback&lt;void&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation| method | function enableLocationMock(scenario: LocationRequestScenario): Promise&lt;void&gt;; | Deleted this API in API version 9.|
|geolocation| method | function enableLocationMock(): Promise&lt;void&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation| method | function disableLocationMock(scenario: LocationRequestScenario, callback: AsyncCallback&lt;void&gt;): void; | Deleted this API in API version 9.|
|geolocation| method | function disableLocationMock(callback: AsyncCallback&lt;void&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function disableLocationMock(scenario: LocationRequestScenario): Promise&lt;void&gt;; | Deleted this API in API version 9.|
|geolocation| method | function disableLocationMock(): Promise&lt;void&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function setMockedLocations(config: LocationMockConfig, callback: AsyncCallback&lt;void&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function setMockedLocations(config: LocationMockConfig): Promise&lt;void&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function enableReverseGeocodingMock(callback: AsyncCallback&lt;void&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function enableReverseGeocodingMock(): Promise&lt;void&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function disableReverseGeocodingMock(callback: AsyncCallback&lt;void&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function disableReverseGeocodingMock(): Promise&lt;void&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;, callback: AsyncCallback&lt;void&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;): Promise&lt;void&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback&lt;boolean&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType): Promise&lt;boolean&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback&lt;boolean&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts** and changed the return value in the callback to **void**. |
|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise&lt;boolean&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts** and changed the return value in the promise to **void**. |
**(Optional) Adaptation Guide**
The following sample code shows how to call **enableLocation** in the new version:
```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 Location Service Permission Change
From API version 9, the **ohos.permission.APPROXIMATELY_LOCATION** permission is added for obtaining the approximate location.
If you use API version 9 or later, you need to apply for both the **ohos.permission.LOCATION** and **ohos.permission.APPROXIMATELY_LOCATION** permissions. Applying for only the **ohos.permission.LOCATION** permission will fail.
**Change Impact**
Applications using API versions earlier than 9 are not affected. For an application using API version 9 or later, the method for applying for the location permission is changed. The details are as follows:
Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user as described below.
The system provides the following location permissions:
- ohos.permission.LOCATION
- ohos.permission.APPROXIMATELY_LOCATION
- ohos.permission.LOCATION_IN_BACKGROUND
If your application needs to access the device location information, it must first apply for required permissions. Specifically speaking:
API versions earlier than 9: Apply for **ohos.permission.LOCATION**.
API version 9 and later: Apply for **ohos.permission.APPROXIMATELY_LOCATION**, or apply for **ohos.permission.APPROXIMATELY_LOCATION** and **ohos.permission.LOCATION**. Note that **ohos.permission.LOCATION** cannot be applied for separately.
| API Version| Location Permission| Permission Application Result| Location Accuracy|
| -------- | -------- | -------- | -------- |
| Earlier than 9| ohos.permission.LOCATION | Success| Location accurate to meters|
| 9 and later| ohos.permission.LOCATION | Failed| No location obtained.|
| 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Success| Location accurate to 5 kilometers.|
| 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Success| Location accurate to meters|
If your application needs to access the device location information when running in the background, it must be configured to be able to run in the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
You can declare the required permissions in your application's configuration file. For details, see the [permission application guide](../../../application-dev/security/accesstoken-guidelines.md).
**Key API/Component Changes**
Applications using API versions earlier than 9 are not affected.
If your application uses API version 9 or later and needs to call APIs requiring the **ohos.permission.LOCATION** permission in **@ohos.geolocation** and **@ohos.geoLocationManager**, you need to apply for the corresponding permission as described previously.
# Globalization Subsystem ChangeLog
## cl.global.1 Support of Error Codes for the Internalization Module
APIs provided by the internationalization module of the globalization subsystem are changed to support error codes in the following scenarios. The following changes are made in API version 9 and later:
- Obtaining the local expression of a country or language
- Obtaining the list of languages supported by the system and the list of areas supported by a language
- Checking whether a language matches an area
- Obtaining and setting the system language, country or region, and area
- Obtaining and setting the 24-hour clock of the system
- Obtaining, adding, and removing the preferred language
- Obtaining and setting localized numbers
You need to adapt your application.
**Change Impact**
The preceding APIs are changed to the static methods of the **System** class. When such an API is called, add the class name to the end of the module name.
For setter APIs, the type of the return value is changed from boolean to void, for example, **setSystemLanguage**.
When a call to an API fails, an error code is returned according to the failure cause. For example, when permissions are not correctly configured for an application, **201** is returned.
**Key API/Component Changes**
- Involved APIs:
- 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;
**Adaptation Guide**
Use the **try-catch** block to capture errors returned by an API.
```
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}.`)
}
```
# Power Subsystem ChangeLog
## cl.powermgr.1 Error Information Return Method Change of APIs
The **power** module uses service logic return values to indicate error information, which does not comply with the API error code specifications of OpenHarmony. Therefore, modification is made in API version 9 and later.
- Power consumption statistics: [@ohos.batteryStatistics](../../../application-dev/reference/apis/js-apis-batteryStatistics.md)
- Screen brightness: [@ohos.brightness](../../../application-dev/reference/apis/js-apis-brightness.md)
- Power management: [@ohos.power](../../../application-dev/reference/apis/js-apis-power.md)
- Runninglock management: [@ohos.runningLock](../../../application-dev/reference/apis/js-apis-runninglock.md)
- Thermal management: [@ohos.thermal](../../../application-dev/reference/apis/js-apis-thermal.md)
Asynchronous API: An error message is returned via **AsyncCallback** or the **error** object of **Promise**.
Synchronous API: An error message is returned via an exception.
#### Change Impact
The application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected.
#### Key API/Component Changes
Error code processing is added for the following APIs:
- 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
#### Adaptation Guide
For details, see the API reference document of each API.
## cl.powermgr.2 System API Change
#### Change Impact
The application developed based on earlier versions needs to adapt to new API names and the new method for returning API error information. Otherwise, the original service logic will be affected.
#### Key API/Component Changes
| Bundle Name | Original API | New API |
| ----------- | ------------------------------------ | ------------------------------ |
| @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 |
#### Adaptation Guide
For details, see [@ohos.power](../../../application-dev/reference/apis/js-apis-power.md).
# Upload and Download Subsystem Changelog
## cl.request.1 Changes of Error Code Definitions and Some API Names
## cl.request.1 Changes of Error Code Definitions and API Names
- The processing of the [upload and download error codes](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/errorcodes/errorcode-request.md) is added to the upload and download APIs.
- An error message is returned via **AsyncCallback** or the **error** object of **Promise**. An error message related to the parameter type or quantity is returned via an exception.
- Some APIs need to be replaced with new APIs, and the parameters remain unchanged.
- Processing of [error codes](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/errorcodes/errorcode-request.md) is added to the upload and download APIs.
- Error information is returned via the **error** object in **AsyncCallback** or **Promise**. An error message related to the parameter type or quantity is returned via an exception.
- Some APIs are replaced with new APIs, but the parameters remain unchanged.
**Change Impact**
......@@ -12,7 +12,7 @@ The application developed based on earlier versions needs to adapt the method fo
**Key API/Component Changes**
| Module | Class | Method/Attribute/Enumeration/Constant | Change Type |
| Module | Class | Method/Attribute/Enum/Constant | Change Type |
|--------------|--------------|-----------------------------------------------------------------------------------------------------------------------|-----------|
| ohos.request | request | EXCEPTION_PERMISSION | Added|
| ohos.request | request | EXCEPTION_PARAMCHECK | Added|
......@@ -89,7 +89,7 @@ The application developed based on earlier versions needs to adapt the method fo
**Adaptation Guide**
The following uses **downloadFile** as an example to show how it is called in the new version:
The following sample code shows how to call **downloadFile** in the new version:
```ts
try {
......
# Telephony Subsystem ChangeLog
## cl.telephony.1 Input Parameter Change of System APIs of the SMS Module
Input parameters of some system APIs of the SMS module are changed, leading to noncompliance with the API specifications of OpenHarmony. The following changes are made in API version 9 and later:
The **slotId** parameter is added to the **isImsSmsSupported** API, indicating the slot ID.
**Change Impact**
Input parameters of JS APIs need to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected.
**Key API/Component Changes**
- Involved APIs:
isImsSmsSupported(callback: AsyncCallback<boolean>): void;
isImsSmsSupported(): Promise<boolean>;
- Before change:
```js
function isImsSmsSupported(callback: AsyncCallback<boolean>): void;
function isImsSmsSupported(): Promise<boolean>;
```
- After change:
```js
function isImsSmsSupported(slotId: number, callback: AsyncCallback<boolean>): void;
function isImsSmsSupported(slotId: number): Promise<boolean>;
```
**Adaptation Guide**
Add an input parameter. The sample code is as follows:
Callback mode:
```js
let slotId = 0;
sms.isImsSmsSupported(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
Promise mode:
```js
let slotId = 0;
let promise = sms.isImsSmsSupported(slotId);
promise.then(data => {
console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`);
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册