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

!8223 翻译已完成7345+7481

Merge pull request !8223 from shawn_he/7345-a
...@@ -34,7 +34,7 @@ Obtains the localized script for the specified language. ...@@ -34,7 +34,7 @@ Obtains the localized script for the specified language.
| string | Localized script for the specified language.| | string | Localized script for the specified language.|
**Example** **Example**
``` ```js
i18n.getDisplayLanguage("zh", "en-GB", true); i18n.getDisplayLanguage("zh", "en-GB", true);
i18n.getDisplayLanguage("zh", "en-GB"); i18n.getDisplayLanguage("zh", "en-GB");
``` ```
...@@ -61,7 +61,7 @@ Obtains the localized script for the specified country. ...@@ -61,7 +61,7 @@ Obtains the localized script for the specified country.
| string | Localized script for the specified country.| | string | Localized script for the specified country.|
**Example** **Example**
``` ```js
i18n.getDisplayCountry("zh-CN", "en-GB", true); i18n.getDisplayCountry("zh-CN", "en-GB", true);
i18n.getDisplayCountry("zh-CN", "en-GB"); i18n.getDisplayCountry("zh-CN", "en-GB");
``` ```
...@@ -86,7 +86,7 @@ Checks whether the localized script for the specified language is displayed from ...@@ -86,7 +86,7 @@ Checks whether the localized script for the specified language is displayed from
| boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.| | boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned. i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned.
i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned. i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned.
``` ```
...@@ -106,7 +106,7 @@ Obtains the system language. ...@@ -106,7 +106,7 @@ Obtains the system language.
| string | System language ID.| | string | System language ID.|
**Example** **Example**
``` ```js
i18n.getSystemLanguage(); i18n.getSystemLanguage();
``` ```
...@@ -117,12 +117,12 @@ setSystemLanguage(language: string): boolean ...@@ -117,12 +117,12 @@ setSystemLanguage(language: string): boolean
Sets the system language. Sets the system language.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION **Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Description | | Name | Type | Description |
| -------- | ------ | ----- | | -------- | ------ | ----- |
...@@ -134,7 +134,7 @@ Sets the system language. ...@@ -134,7 +134,7 @@ Sets the system language.
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.setSystemLanguage('zh'); i18n.setSystemLanguage('zh');
``` ```
...@@ -155,7 +155,7 @@ Obtains the list of system languages. ...@@ -155,7 +155,7 @@ Obtains the list of system languages.
| Array<string> | List of the IDs of system languages.| | Array<string> | List of the IDs of system languages.|
**Example** **Example**
``` ```js
i18n.getSystemLanguages(); i18n.getSystemLanguages();
``` ```
...@@ -181,7 +181,7 @@ Obtains the list of countries and regions supported for the specified language. ...@@ -181,7 +181,7 @@ Obtains the list of countries and regions supported for the specified language.
| Array<string> | List of the IDs of the countries and regions supported for the specified language.| | Array<string> | List of the IDs of the countries and regions supported for the specified language.|
**Example** **Example**
``` ```js
i18n.getSystemCountries('zh'); i18n.getSystemCountries('zh');
``` ```
...@@ -200,7 +200,7 @@ Obtains the system region. ...@@ -200,7 +200,7 @@ Obtains the system region.
| string | System region ID.| | string | System region ID.|
**Example** **Example**
``` ```js
i18n.getSystemRegion(); i18n.getSystemRegion();
``` ```
...@@ -211,12 +211,12 @@ setSystemRegion(region: string): boolean ...@@ -211,12 +211,12 @@ setSystemRegion(region: string): boolean
Sets the system region. Sets the system region.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION **Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Description | | Name | Type | Description |
| ------ | ------ | ----- | | ------ | ------ | ----- |
...@@ -228,7 +228,7 @@ Sets the system region. ...@@ -228,7 +228,7 @@ Sets the system region.
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.setSystemRegion('CN'); i18n.setSystemRegion('CN');
``` ```
...@@ -247,7 +247,7 @@ Obtains the system locale. ...@@ -247,7 +247,7 @@ Obtains the system locale.
| string | System locale ID.| | string | System locale ID.|
**Example** **Example**
``` ```js
i18n.getSystemLocale(); i18n.getSystemLocale();
``` ```
...@@ -258,12 +258,12 @@ setSystemLocale(locale: string): boolean ...@@ -258,12 +258,12 @@ setSystemLocale(locale: string): boolean
Sets the system locale. Sets the system locale.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION **Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name | Type | Description | | Name | Type | Description |
| ------ | ------ | --------------- | | ------ | ------ | --------------- |
...@@ -275,7 +275,7 @@ Sets the system locale. ...@@ -275,7 +275,7 @@ Sets the system locale.
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.setSystemLocale('zh-CN'); i18n.setSystemLocale('zh-CN');
``` ```
...@@ -302,7 +302,7 @@ Checks whether the system language matches the specified region. ...@@ -302,7 +302,7 @@ Checks whether the system language matches the specified region.
| boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.| | boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.isSuggested('zh', 'CN'); i18n.isSuggested('zh', 'CN');
``` ```
...@@ -327,7 +327,7 @@ Obtains a **Calendar** object. ...@@ -327,7 +327,7 @@ Obtains a **Calendar** object.
| [Calendar](#calendar8) | **Calendar** object.| | [Calendar](#calendar8) | **Calendar** object.|
**Example** **Example**
``` ```js
i18n.getCalendar("zh-Hans", "gregory"); i18n.getCalendar("zh-Hans", "gregory");
``` ```
...@@ -349,7 +349,7 @@ Sets the date for this **Calendar** object. ...@@ -349,7 +349,7 @@ Sets the date for this **Calendar** object.
| date | Date | Yes | Date to be set for the **Calendar** object.| | date | Date | Yes | Date to be set for the **Calendar** object.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("en-US", "gregory"); var calendar = i18n.getCalendar("en-US", "gregory");
var date = new Date(2021, 10, 7, 8, 0, 0, 0); var date = new Date(2021, 10, 7, 8, 0, 0, 0);
calendar.setTime(date); calendar.setTime(date);
...@@ -370,7 +370,7 @@ Sets the date and time for this **Calendar** object. The value is represented by ...@@ -370,7 +370,7 @@ Sets the date and time for this **Calendar** object. The value is represented by
| time | number | Yes | Number of milliseconds that have elapsed since the Unix epoch.| | time | number | Yes | Number of milliseconds that have elapsed since the Unix epoch.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("en-US", "gregory"); var calendar = i18n.getCalendar("en-US", "gregory");
calendar.setTime(10540800000); calendar.setTime(10540800000);
``` ```
...@@ -395,7 +395,7 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object ...@@ -395,7 +395,7 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object
| second | number | No | Second to set. | | second | number | No | Second to set. |
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
``` ```
...@@ -415,7 +415,7 @@ Sets the time zone of this **Calendar** object. ...@@ -415,7 +415,7 @@ Sets the time zone of this **Calendar** object.
| timezone | string | Yes | Time zone, for example, **Asia/Shanghai**.| | timezone | string | Yes | Time zone, for example, **Asia/Shanghai**.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTimeZone("Asia/Shanghai"); calendar.setTimeZone("Asia/Shanghai");
``` ```
...@@ -435,7 +435,7 @@ Obtains the time zone of this **Calendar** object. ...@@ -435,7 +435,7 @@ Obtains the time zone of this **Calendar** object.
| string | Time zone of the **Calendar** object.| | string | Time zone of the **Calendar** object.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTimeZone("Asia/Shanghai"); calendar.setTimeZone("Asia/Shanghai");
calendar.getTimeZone(); // Asia/Shanghai" calendar.getTimeZone(); // Asia/Shanghai"
...@@ -456,7 +456,7 @@ Obtains the start day of a week for this **Calendar** object. ...@@ -456,7 +456,7 @@ Obtains the start day of a week for this **Calendar** object.
| number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| | number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("en-US", "gregory"); var calendar = i18n.getCalendar("en-US", "gregory");
calendar.getFirstDayOfWeek(); calendar.getFirstDayOfWeek();
``` ```
...@@ -476,7 +476,7 @@ Sets the start day of a week for this **Calendar** object. ...@@ -476,7 +476,7 @@ Sets the start day of a week for this **Calendar** object.
| value | number | No | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| | value | number | No | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setFirstDayOfWeek(0); calendar.setFirstDayOfWeek(0);
``` ```
...@@ -496,7 +496,7 @@ Obtains the minimum number of days in the first week of a year. ...@@ -496,7 +496,7 @@ Obtains the minimum number of days in the first week of a year.
| number | Minimum number of days in the first week of a year.| | number | Minimum number of days in the first week of a year.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.getMinimalDaysInFirstWeek(); calendar.getMinimalDaysInFirstWeek();
``` ```
...@@ -516,7 +516,7 @@ Sets the minimum number of days in the first week of a year. ...@@ -516,7 +516,7 @@ Sets the minimum number of days in the first week of a year.
| value | number | No | Minimum number of days in the first week of a year.| | value | number | No | Minimum number of days in the first week of a year.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setMinimalDaysInFirstWeek(3); calendar.setMinimalDaysInFirstWeek(3);
``` ```
...@@ -541,7 +541,7 @@ Obtains the value of the specified field in the **Calendar** object. ...@@ -541,7 +541,7 @@ Obtains the value of the specified field in the **Calendar** object.
| number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.| | number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
calendar.get("hour_of_day"); // 8 calendar.get("hour_of_day"); // 8
...@@ -567,7 +567,7 @@ Obtains the name of the **Calendar** object displayed for the specified locale. ...@@ -567,7 +567,7 @@ Obtains the name of the **Calendar** object displayed for the specified locale.
| string | Name of the **Calendar** object displayed for the specified locale.| | string | Name of the **Calendar** object displayed for the specified locale.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("en-US", "buddhist"); var calendar = i18n.getCalendar("en-US", "buddhist");
calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh. calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh.
``` ```
...@@ -592,7 +592,7 @@ Checks whether the specified date in this **Calendar** object is a weekend. ...@@ -592,7 +592,7 @@ Checks whether the specified date in this **Calendar** object is a weekend.
| boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.| | boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00 calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00
calendar.isWeekend(); // false calendar.isWeekend(); // false
...@@ -619,7 +619,7 @@ Parameters ...@@ -619,7 +619,7 @@ Parameters
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. | | options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. |
**Example** **Example**
``` ```js
var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"}); var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"});
``` ```
...@@ -643,7 +643,7 @@ Checks whether the format of the specified phone number is valid. ...@@ -643,7 +643,7 @@ Checks whether the format of the specified phone number is valid.
| boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.| | boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.|
**Example** **Example**
``` ```js
var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.isValidNumber("15812312312"); phonenumberfmt.isValidNumber("15812312312");
``` ```
...@@ -668,9 +668,34 @@ Formats a phone number. ...@@ -668,9 +668,34 @@ Formats a phone number.
| string | Formatted phone number.| | string | Formatted phone number.|
**Example** **Example**
```js
var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.isValidNumber("15812312312");
``` ```
### getLocationName<sup>8+</sup>
static getLocationName(number: string, locale: string): string
Obtains the home location of a phone number.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---------- |
| number | string | Yes | Phone number.|
| locale | string | Yes | Locale ID.|
**Return value**
| Type | Description |
| ------ | ---------- |
| string | Home location of the phone number.|
**Example**
```js
var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.format("15812312312"); phonenumberfmt.isValidNumber("15812312312");
``` ```
...@@ -723,7 +748,7 @@ Converts one measurement unit into another and formats the unit based on the spe ...@@ -723,7 +748,7 @@ Converts one measurement unit into another and formats the unit based on the spe
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.| | string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
**Example** **Example**
``` ```js
i18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); i18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long");
``` ```
...@@ -747,7 +772,7 @@ Creates an **IndexUtil** object. ...@@ -747,7 +772,7 @@ Creates an **IndexUtil** object.
| [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.| | [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.|
**Example** **Example**
``` ```js
var indexUtil= i18n.getInstance("zh-CN"); var indexUtil= i18n.getInstance("zh-CN");
``` ```
...@@ -769,7 +794,7 @@ Obtains the index list for this **locale** object. ...@@ -769,7 +794,7 @@ Obtains the index list for this **locale** object.
| Array&lt;string&gt; | Index list for this **locale** object.| | Array&lt;string&gt; | Index list for this **locale** object.|
**Example** **Example**
``` ```js
var indexUtil = i18n.getInstance("zh-CN"); var indexUtil = i18n.getInstance("zh-CN");
var indexList = indexUtil.getIndexList(); var indexList = indexUtil.getIndexList();
``` ```
...@@ -789,7 +814,7 @@ Adds the index of the new **locale** object to the index list. ...@@ -789,7 +814,7 @@ Adds the index of the new **locale** object to the index list.
| locale | string | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string | Yes | A string containing locale information, including the language, optional script, and region.|
**Example** **Example**
``` ```js
var indexUtil = i18n.getInstance("zh-CN"); var indexUtil = i18n.getInstance("zh-CN");
indexUtil.addLocale("en-US"); indexUtil.addLocale("en-US");
``` ```
...@@ -814,7 +839,7 @@ Obtains the index of a text object. ...@@ -814,7 +839,7 @@ Obtains the index of a text object.
| string | Index of the **text** object.| | string | Index of the **text** object.|
**Example** **Example**
``` ```js
var indexUtil= i18n.getInstance("zh-CN"); var indexUtil= i18n.getInstance("zh-CN");
indexUtil.getIndex("hi"); // Return h. indexUtil.getIndex("hi"); // Return h.
``` ```
...@@ -842,7 +867,7 @@ Checks whether the input character string is composed of digits. ...@@ -842,7 +867,7 @@ Checks whether the input character string is composed of digits.
| boolean | Returns **true** if the input character is a digit; returns **false** otherwise.| | boolean | Returns **true** if the input character is a digit; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isdigit = i18n.Character.isDigit("1"); // Return true. var isdigit = i18n.Character.isDigit("1"); // Return true.
``` ```
...@@ -866,7 +891,7 @@ Checks whether the input character is a space. ...@@ -866,7 +891,7 @@ Checks whether the input character is a space.
| boolean | Returns **true** if the input character is a space; returns **false** otherwise.| | boolean | Returns **true** if the input character is a space; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isspacechar = i18n.Character.isSpaceChar("a"); // Return false. var isspacechar = i18n.Character.isSpaceChar("a"); // Return false.
``` ```
...@@ -890,7 +915,7 @@ Checks whether the input character is a white space. ...@@ -890,7 +915,7 @@ Checks whether the input character is a white space.
| boolean | Returns **true** if the input character is a white space; returns **false** otherwise.| | boolean | Returns **true** if the input character is a white space; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isspacechar = i18n.Character.isSpaceChar("a"); // Return false. var isspacechar = i18n.Character.isSpaceChar("a"); // Return false.
``` ```
...@@ -914,7 +939,7 @@ Checks whether the input character is of the right to left (RTL) language. ...@@ -914,7 +939,7 @@ Checks whether the input character is of the right to left (RTL) language.
| boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.| | boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isrtl = i18n.Character.isRTL("a"); // Return false. var isrtl = i18n.Character.isRTL("a"); // Return false.
``` ```
...@@ -938,7 +963,7 @@ Checks whether the input character is an ideographic character. ...@@ -938,7 +963,7 @@ Checks whether the input character is an ideographic character.
| boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.| | boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isideograph = i18n.Character.isIdeograph("a"); // Return false. var isideograph = i18n.Character.isIdeograph("a"); // Return false.
``` ```
...@@ -962,7 +987,7 @@ Checks whether the input character is a letter. ...@@ -962,7 +987,7 @@ Checks whether the input character is a letter.
| boolean | Returns **true** if the input character is a letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is a letter; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isletter = i18n.Character.isLetter("a"); // Return true. var isletter = i18n.Character.isLetter("a"); // Return true.
``` ```
...@@ -986,7 +1011,7 @@ Checks whether the input character is a lowercase letter. ...@@ -986,7 +1011,7 @@ Checks whether the input character is a lowercase letter.
| boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.|
**Example** **Example**
``` ```js
var islowercase = i18n.Character.isLowerCase("a"); // Return true. var islowercase = i18n.Character.isLowerCase("a"); // Return true.
``` ```
...@@ -1010,7 +1035,7 @@ Checks whether the input character is an uppercase letter. ...@@ -1010,7 +1035,7 @@ Checks whether the input character is an uppercase letter.
| boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isuppercase = i18n.Character.isUpperCase("a"); // Return false. var isuppercase = i18n.Character.isUpperCase("a"); // Return false.
``` ```
...@@ -1034,7 +1059,7 @@ Obtains the type of the input character string. ...@@ -1034,7 +1059,7 @@ Obtains the type of the input character string.
| string | Type of the input character.| | string | Type of the input character.|
**Example** **Example**
``` ```js
var type = i18n.Character.getType("a"); var type = i18n.Character.getType("a");
``` ```
...@@ -1058,7 +1083,7 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation. ...@@ -1058,7 +1083,7 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation.
| [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.| | [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
``` ```
...@@ -1080,7 +1105,7 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object. ...@@ -1080,7 +1105,7 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object.
| text | string | Yes | Text to be processed by the **BreakIterator** object.| | text | string | Yes | Text to be processed by the **BreakIterator** object.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
``` ```
...@@ -1100,7 +1125,7 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object. ...@@ -1100,7 +1125,7 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object.
| string | Text being processed by the **BreakIterator** object.| | string | Text being processed by the **BreakIterator** object.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.getLineBreakText(); // Apple is my favorite fruit. iterator.getLineBreakText(); // Apple is my favorite fruit.
...@@ -1121,7 +1146,7 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text ...@@ -1121,7 +1146,7 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text
| number | Position of the **BreakIterator** object in the text being processed.| | number | Position of the **BreakIterator** object in the text being processed.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.current(); // 0 iterator.current(); // 0
...@@ -1142,7 +1167,7 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi ...@@ -1142,7 +1167,7 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi
| number | Offset to the first text boundary of the processed text.| | number | Offset to the first text boundary of the processed text.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.first(); // 0 iterator.first(); // 0
...@@ -1163,7 +1188,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic ...@@ -1163,7 +1188,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic
| number | Offset of the last text boundary of the processed text.| | number | Offset of the last text boundary of the processed text.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.last(); // 27 iterator.last(); // 27
...@@ -1189,7 +1214,7 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb ...@@ -1189,7 +1214,7 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.first(); // 0 iterator.first(); // 0
...@@ -1212,7 +1237,7 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary. ...@@ -1212,7 +1237,7 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary.
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.first(); // 0 iterator.first(); // 0
...@@ -1240,7 +1265,7 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the ...@@ -1240,7 +1265,7 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the
| number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.| | number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.following(0); // 6 iterator.following(0); // 6
...@@ -1268,7 +1293,7 @@ Checks whether the position specified by the offset is a text boundary. If **tru ...@@ -1268,7 +1293,7 @@ Checks whether the position specified by the offset is a text boundary. If **tru
| boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.| | boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.isBoundary(0); // true; iterator.isBoundary(0); // true;
...@@ -1290,7 +1315,7 @@ Checks whether the 24-hour clock is used. ...@@ -1290,7 +1315,7 @@ Checks whether the 24-hour clock is used.
| boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.| | boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.|
**Example** **Example**
``` ```js
var is24HourClock = i18n.is24HourClock(); var is24HourClock = i18n.is24HourClock();
``` ```
...@@ -1316,7 +1341,7 @@ Sets the 24-hour clock. ...@@ -1316,7 +1341,7 @@ Sets the 24-hour clock.
| boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.| | boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.|
**Example** **Example**
``` ```js
// Set the system time to the 24-hour clock. // Set the system time to the 24-hour clock.
var success = i18n.set24HourClock(true); var success = i18n.set24HourClock(true);
``` ```
...@@ -1344,7 +1369,7 @@ Adds a preferred language to the specified position on the preferred language li ...@@ -1344,7 +1369,7 @@ Adds a preferred language to the specified position on the preferred language li
| boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.| | boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.|
**Example** **Example**
``` ```js
// Add zh-CN to the preferred language list. // Add zh-CN to the preferred language list.
var language = 'zh-CN'; var language = 'zh-CN';
var index = 0; var index = 0;
...@@ -1373,7 +1398,7 @@ Deletes a preferred language from the specified position on the preferred langua ...@@ -1373,7 +1398,7 @@ Deletes a preferred language from the specified position on the preferred langua
| boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.| | boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.|
**Example** **Example**
``` ```js
// Delete the first preferred language from the preferred language list. // Delete the first preferred language from the preferred language list.
var index = 0; var index = 0;
var success = i18n.removePreferredLanguage(index); var success = i18n.removePreferredLanguage(index);
...@@ -1394,7 +1419,7 @@ Obtains the list of preferred languages. ...@@ -1394,7 +1419,7 @@ Obtains the list of preferred languages.
| Array&lt;string&gt; | List of preferred languages.| | Array&lt;string&gt; | List of preferred languages.|
**Example** **Example**
``` ```js
var preferredLanguageList = i18n.getPreferredLanguageList(); var preferredLanguageList = i18n.getPreferredLanguageList();
``` ```
...@@ -1413,7 +1438,7 @@ Obtains the first language in the preferred language list. ...@@ -1413,7 +1438,7 @@ Obtains the first language in the preferred language list.
| string | First language in the preferred language list.| | string | First language in the preferred language list.|
**Example** **Example**
``` ```js
var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); var firstPreferredLanguage = i18n.getFirstPreferredLanguage();
``` ```
...@@ -1432,7 +1457,7 @@ Obtains the preferred language of an application. ...@@ -1432,7 +1457,7 @@ Obtains the preferred language of an application.
| string | Preferred language of the application.| | string | Preferred language of the application.|
**Example** **Example**
``` ```js
var appPreferredLanguage = i18n.getAppPreferredLanguage(); var appPreferredLanguage = i18n.getAppPreferredLanguage();
``` ```
...@@ -1456,7 +1481,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID. ...@@ -1456,7 +1481,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID.
| TimeZone | **TimeZone** object corresponding to the time zone ID.| | TimeZone | **TimeZone** object corresponding to the time zone ID.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
``` ```
...@@ -1478,7 +1503,7 @@ Obtains the ID of the specified **TimeZone** object. ...@@ -1478,7 +1503,7 @@ Obtains the ID of the specified **TimeZone** object.
| string | Time zone ID corresponding to the **TimeZone** object.| | string | Time zone ID corresponding to the **TimeZone** object.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getID(); timezone.getID();
``` ```
...@@ -1504,7 +1529,7 @@ Obtains the representation of a **TimeZone** object in the specified locale. ...@@ -1504,7 +1529,7 @@ Obtains the representation of a **TimeZone** object in the specified locale.
| string | Representation of the **TimeZone** object in the specified locale.| | string | Representation of the **TimeZone** object in the specified locale.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getDisplayName("zh-CN", false); timezone.getDisplayName("zh-CN", false);
``` ```
...@@ -1524,7 +1549,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an ...@@ -1524,7 +1549,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.| | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getRawOffset(); timezone.getRawOffset();
``` ```
...@@ -1544,7 +1569,139 @@ Obtains the offset between the time zone represented by a **TimeZone** object an ...@@ -1544,7 +1569,139 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.| | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getOffset(1234567890); timezone.getOffset(1234567890);
``` ```
### getAvailableIDs<sup>9+</sup>
static getAvailableIDs(): Array&lt;string&gt;
Obtains the list of time zone IDs supported by the system.
**System capability**: SystemCapability.Global.I18n
**Return value**
| Type | Description |
| ------ | ----------------------- |
| Array&lt;string&gt; | List of time zone IDs supported by the system.|
**Example**
```js
var ids = i18n.TimeZone.getAvailableIDs();
```
### getAvailableZoneCityIDs<sup>9+</sup>
static getAvailableZoneCityIDs(): Array&lt;string&gt;
Obtains the list of time zone city IDs supported by the system.
**System capability**: SystemCapability.Global.I18n
**Return value**
| Type | Description |
| ------ | ----------------------- |
| Array&lt;string&gt; | List of time zone city IDs supported by the system.|
**Example**
```js
var cityIDs = i18n.TimeZone.getAvailableZoneCityIDs();
```
### getCityDisplayName<sup>9+</sup>
static getCityDisplayName(cityID: string, locale: string): string
Obtains the localized display of a time zone city in the specified locale.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- |
| cityID | string | Yes | Time zone city ID.|
| locale | string | Yes | Locale ID.|
**Return value**
| Type | Description |
| ------ | ----------------------- |
| string | Localized display of the time zone city in the specified locale.|
**Example**
```js
var displayName = i18n.TimeZone.getCityDisplayName("Shanghai", "zh-CN");
```
### getTimezoneFromCity<sup>9+</sup>
static getTimezoneFromCity(cityID: string): TimeZone
Obtains the **TimeZone** object corresponding to the specified time zone city ID.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- |
| cityID | string | Yes | Time zone city ID.|
**Return value**
| Type | Description |
| ------ | ----------------------- |
| TimeZone | **TimeZone** object corresponding to the specified time zone city ID.|
**Example**
```js
var timezone = i18n.TimeZone.getTimezoneFromCity("Shanghai");
```
## i18n.setUsingLocalDigit<sup>9+</sup>
setUsingLocalDigit(flag: boolean): boolean
Sets whether to turn on the local digit switch.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- |
| flag | boolean | Yes | Whether to turn on the local digit switch. The value **true** means to turn on the local digit switch, and the value **false** indicates the opposite.|
**Return value**
| Type | Description |
| -------- | ------------ |
| boolean | Result indicating whether the local digit switch is successfully set. The value **true** indicates that the local digit switch is successfully set, and the value **false** indicates the opposite.|
**Example**
```js
var status = i18n.setUsingLocalDigit(true);
```
## i18n.getUsingLocalDigit<sup>9+</sup>
getUsingLocalDigit(): boolean
Checks whether the local digit switch is turned on.
**System capability**: SystemCapability.Global.I18n
**Return value**
| Type | Description |
| -------- | ------------ |
| boolean | Result indicating whether the local digit switch is turned on. The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.|
**Example**
```js
var status = i18n.getUsingLocalDigit();
```
...@@ -32,7 +32,7 @@ This is a system API. ...@@ -32,7 +32,7 @@ This is a system API.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.| | type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| keyOptions | [keyOptions](#keyOptions) | Yes| Key option, which specifies the condition for combination key input.| | keyOptions | [keyOptions](#keyoptions) | Yes| Key option, which specifies the condition for combination key input.|
| callback | Callback&lt;KeyOptions&gt; | Yes| Callback used to return the result.<br> When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.| | callback | Callback&lt;KeyOptions&gt; | Yes| Callback used to return the result.<br> When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.|
**Example** **Example**
...@@ -62,7 +62,7 @@ This is a system API. ...@@ -62,7 +62,7 @@ This is a system API.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.| | type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| keyOptions | [keyOptions](#keyOptions) | Yes| Key options passed to the key input event when listening starts.| | keyOptions | [keyOptions](#keyoptions) | Yes| Key options passed to the key input event when listening starts.|
| callback | Callback&lt;KeyOptions&gt; | Yes| Callback function passed to the key input event with **keyOptions** when listening starts.| | callback | Callback&lt;KeyOptions&gt; | Yes| Callback function passed to the key input event with **keyOptions** when listening starts.|
**Example** **Example**
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
The Input Device module implements listening for connection, disconnection, and update events of input devices and displays information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse. The Input Device module implements listening for connection, disconnection, and update events of input devices and displays information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse.
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -28,7 +29,7 @@ Enables listening for hot swap events of an input device. ...@@ -28,7 +29,7 @@ Enables listening for hot swap events of an input device.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------- | | -------- | ---------------------------------------- | ---- | ----------- |
| type | string | Yes | Event type of the input device. | | type | string | Yes | Event type of the input device. |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | Yes | Listener for events of the input device.| | listener | Callback&lt;[DeviceListener](#devicelistener9)&gt; | Yes | Listener for events of the input device.|
**Example** **Example**
...@@ -63,7 +64,7 @@ Disables listening for hot swap events of an input device. ...@@ -63,7 +64,7 @@ Disables listening for hot swap events of an input device.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------- | | -------- | ---------------------------------------- | ---- | ----------- |
| type | string | Yes | Event type of the input device. | | type | string | Yes | Event type of the input device. |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | No | Listener for events of the input device.| | listener | Callback&lt;[DeviceListener](#devicelistener9)&gt; | No | Listener for events of the input device.|
**Example** **Example**
...@@ -245,7 +246,7 @@ Obtains the keyboard type of an input device. This API uses an asynchronous call ...@@ -245,7 +246,7 @@ Obtains the keyboard type of an input device. This API uses an asynchronous call
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------------- | | -------- | ---------------------------------------- | ---- | --------------------------------- |
| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| | deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype)&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;[KeyboardType](#keyboardtype9)&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -268,7 +269,7 @@ Obtains the keyboard type of an input device. This API uses a promise to return ...@@ -268,7 +269,7 @@ Obtains the keyboard type of an input device. This API uses a promise to return
| Parameter | Description | | Parameter | Description |
| ---------------------------------------- | ------------------- | | ---------------------------------------- | ------------------- |
| Promise&lt;[KeyboardType](#keyboardtype)&gt; | Promise used to return the result.| | Promise&lt;[KeyboardType](#keyboardtype9)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -336,7 +337,7 @@ Defines the axis range of an input device. ...@@ -336,7 +337,7 @@ Defines the axis range of an input device.
| Name | Type | Description | | Name | Type | Description |
| ----------------------- | ------------------------- | -------- | | ----------------------- | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | Input source type of the axis.| | source | [SourceType](#sourcetype) | Input source type of the axis.|
| axis | [AxisType](#axistype) | Axis type. | | axis | [AxisType](#axistype9) | Axis type. |
| max | number | Maximum value of the axis. | | max | number | Maximum value of the axis. |
| min | number | Minimum value of the axis. | | min | number | Minimum value of the axis. |
| fuzz<sup>9+</sup> | number | Fuzzy value of the axis. | | fuzz<sup>9+</sup> | number | Fuzzy value of the axis. |
...@@ -358,7 +359,7 @@ Enumerates the input source types. For example, if a mouse reports an x-axis eve ...@@ -358,7 +359,7 @@ Enumerates the input source types. For example, if a mouse reports an x-axis eve
| touchpad | string | The input device is a touchpad.| | touchpad | string | The input device is a touchpad.|
| joystick | string | The input device is a joystick.| | joystick | string | The input device is a joystick.|
## ChangeType ## ChangedType
Defines the change type for the hot swap event of an input device. Defines the change type for the hot swap event of an input device.
......
...@@ -126,7 +126,7 @@ Switches to another input method. This API uses a promise to return the result. ...@@ -126,7 +126,7 @@ Switches to another input method. This API uses a promise to return the result.
``` ```
## InputMethodController ## InputMethodController
In the following API examples, you must first use **[getInputMethodController](#inputmethodgetinputmethodcontroller)** to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance. In the following API examples, you must first use [getInputMethodController](#getinputmethodcontroller) to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance.
### stopInput ### stopInput
...@@ -174,7 +174,7 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. ...@@ -174,7 +174,7 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
## InputMethodSetting<sup>8+</sup> ## InputMethodSetting<sup>8+</sup>
In the following API examples, you must first use **[getInputMethodSetting](#inputmethodgetinputmethodsetting8)** to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance. In the following API examples, you must first use [getInputMethodSetting](#getinputmethodsetting) to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance.
### listInputMethod ### listInputMethod
......
...@@ -536,7 +536,7 @@ Parameters ...@@ -536,7 +536,7 @@ Parameters
**Example** **Example**
``` ```
var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); var pluralRules= new Intl.PluralRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"});
``` ```
......
# Update # Update
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications. The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications.
There are two types of updates: SD card update and over the air (OTA) update. There are two types of updates: SD card update and over the air (OTA) update.
...@@ -10,135 +7,180 @@ There are two types of updates: SD card update and over the air (OTA) update. ...@@ -10,135 +7,180 @@ There are two types of updates: SD card update and over the air (OTA) update.
- The SD card update depends on the update packages and SD cards. - The SD card update depends on the update packages and SD cards.
- The OTA update depends on the server deployed by the device manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the device manufacturer. - The OTA update depends on the server deployed by the device manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the device manufacturer.
> **Note:**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
```js ```js
import update from '@ohos.update' import update from '@ohos.update'
``` ```
## Required Permissions ## update.getOnlineUpdater
None
## update.getUpdater
getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater
Obtains the **Updater** object for local update. Obtains an **OnlineUpdater** object.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | --------------------------- | --------- | ------------ | | ----------- | --------------------------- | ---- | ------ |
| upgradeFile | string | Yes | Update file. | | upgradeInfo | [UpgradeInfo](#upgradeinfo) | Yes | **UpgradeInfo** object.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------------- | | ------------------- | ---- |
| [Updater](#updater) | **Updater** object. | | [Updater](#updater) | **OnlineUpdater** object.|
**Example** **Example**
``` ```ts
try { try {
let updater = update.getUpdater('/data/updater/updater.zip', 'OTA'); var upgradeInfo = {
upgradeApp: "com.ohos.ota.updateclient",
businessType: {
vendor: update.BusinessVendor.PUBLIC,
subType: update.BusinessSubType.FIRMWARE
}
}
let updater = update.getOnlineUpdater(upgradeInfo);
} catch(error) { } catch(error) {
console.error(" Fail to get updater error: " + error); console.error(`Fail to get updater error: ${error}`);
} }
``` ```
## update.getUpdaterForOther ## update.getRestorer
getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater getRestorer(): Restorer
Obtains the **Updater** object for the device to be updated. Obtains a **Restorer** object for restoring factory settings.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | --------------------------- | --------- | --------------------- |
| upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated. |
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------------- | | --------------------- | ------ |
| [Updater](#updater) | **Updater** object. | | [Restorer](#restorer) | **Restorer** object for restoring factory settings.|
**Example** **Example**
``` ```ts
try { try {
let updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA'); let restorer = update.getRestorer();
} catch(error) { } catch(error) {
console.error(" Fail to get updater error: " + error); console.error(`Fail to get restorer: ${error}`);
} }
``` ```
## update.getUpdaterFromOther ## update.getLocalUpdater
getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater getLocalUpdater(): LocalUpdater
Obtains the **Updater** object from another device for the device to be updated. Obtains a **LocalUpdater** object.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | --------------------------- | --------- | --------------------- |
| upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated. |
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------------- | | ----------------------------- | ------ |
| [Updater](#updater) | **Updater** object. | | [LocalUpdater](#localupdater) | **LocalUpdater** object.|
**Example** **Example**
``` ```ts
try { try {
let updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA'); let localUpdater = update.getLocalUpdater();
} catch(error) { } catch(error) {
console.error(" Fail to get updater error: " + error); console.error(`Fail to get localUpdater error: ${error}`);
} }
``` ```
## Updater ## Updater
### checkNewVersion
checkNewVersion(callback: AsyncCallback\<CheckResult>): void
Checks whether a new version is available. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<[CheckResult](#checkresult)> | Yes | Callback used to return the result.|
**Example**
```ts
updater.checkNewVersion((err, result) => {
console.log(`checkNewVersion isExistNewVersion ${result?.isExistNewVersion}`);
});
```
### checkNewVersion
checkNewVersion(): Promise\<CheckResult>
Checks whether a new version is available. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Return value**
| Type | Description |
| ------------------------------------- | ------------------- |
| Promise\<[CheckResult](#checkresult)> | Promise used to return the result.|
**Example**
```ts
updater.checkNewVersion().then(result => {
console.log(`checkNewVersion isExistNewVersion: ${result.isExistNewVersion}`);
// Version digest information
console.log(`checkNewVersion versionDigestInfo: ${result.newVersionInfo.versionDigestInfo.versionDigest}`);
}).catch(err => {
console.log(`checkNewVersion promise error ${JSON.stringify(err)}`);
});
```
### getNewVersionInfo ### getNewVersionInfo
getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void
Obtains the new version information. This function uses an asynchronous callback to return the result. Obtains information about the new version. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | --------------- |
| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information. | | callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | Yes | Callback used to return the result.|
**Example** **Example**
``` ```ts
updater.getNewVersionInfo(info => { updater.getNewVersionInfo((err, info) => {
console.log("getNewVersionInfo success " + info.status); console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
console.log(`info versionName = ` + info.checkResult[0].versionName); console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`);
console.log(`info versionCode = ` + info.checkResult[0].versionCode);
console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo);
}); });
``` ```
...@@ -146,451 +188,1562 @@ updater.getNewVersionInfo(info => { ...@@ -146,451 +188,1562 @@ updater.getNewVersionInfo(info => {
getNewVersionInfo(): Promise\<NewVersionInfo> getNewVersionInfo(): Promise\<NewVersionInfo>
Obtains the new version information. This function uses a promise to return the result. Obtains information about the new version. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ---------------------------------------- | | ---------------------------------------- | -------------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information. | | Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.|
**Example** **Example**
``` ```ts
updater.getNewVersionInfo().then(value => { updater.getNewVersionInfo().then(info => {
console.log(`info versionName = ` + value.checkResult[0].versionName); console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
console.log(`info versionCode = ` + value.checkResult[0].versionCode); console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`);
console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo);
}).catch(err => { }).catch(err => {
console.log("getNewVersionInfo promise error: " + err.code); console.log(`getNewVersionInfo promise error ${JSON.stringify(err)}`);
}); });
``` ```
### checkNewVersion ### getNewVersionDescription
checkNewVersion(callback: AsyncCallback\<NewVersionInfo>): void getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void
Checks whether the current version is the latest. This function uses an asynchronous callback to return the result. Obtains the description file of the new version. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- | | ------------------ | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information. | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. |
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file. |
| callback | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>>) | Yes | Callback used to return the result.|
**Example** **Example**
``` ```ts
updater.checkNewVersion(info => { // Version digest information
console.log("checkNewVersion success " + info.status); var versionDigestInfo = {
console.log(`info versionName = ` + info.checkResult[0].versionName); versionDigest: "versionDigest" // Version digest information in the check result
console.log(`info versionCode = ` + info.checkResult[0].versionCode); }
console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo);
// Options of the description file
var descriptionOptions = {
format: DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese
}
updater.getNewVersionDescription(versionDigestInfo, descriptionOptions, (err, info) => {
console.log(`getNewVersionDescription info ${JSON.stringify(info)}`);
console.log(`getNewVersionDescription err ${JSON.stringify(err)}`);
}); });
``` ```
### checkNewVersion ### getNewVersionDescription
checkNewVersion(): Promise\<NewVersionInfo> getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>>;
Checks whether the current version is the latest. This function uses a promise to return the result. Obtains the description file of the new version. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| ------------------ | ---------------------------------------- | ---- | ------ |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.|
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ---------------------------------------- | | ---------------------------------------- | ------------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information. | | Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.|
**Example** **Example**
``` ```ts
updater.checkNewVersion().then(value => { // Version digest information
console.log(`info versionName = ` + value.checkResult[0].versionName); var versionDigestInfo = {
console.log(`info versionCode = ` + value.checkResult[0].versionCode); versionDigest: "versionDigest" // Version digest information in the check result
console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo); }
// Options of the description file
var descriptionOptions = {
format: DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese
}
updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then(info => {
console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`);
}).catch(err => { }).catch(err => {
console.log("checkNewVersion promise error: " + err.code); console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`);
}); });
``` ```
### verifyUpdatePackage ### getCurrentVersionInfo
verifyUpdatePackage(upgradeFile: string, certsFile: string): void getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void
Verifies whether the update package is valid. Obtains information about the current version. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | --------- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------- |
| upgradeFile | string | Yes | Path of the update package to be verified. | | callback | AsyncCallback\<[CurrentVersionInfo](#currentversioninfo)> | Yes | Callback used to return the result.|
| certsFile | string | Yes | Certificate path. |
**Example** **Example**
``` ```ts
updater.on("verifyProgress", callback => { updater.getCurrentVersionInfo((err, info) => {
console.info('on verifyProgress ' + callback.percent); console.log(`info osVersion = ${info?.osVersion}`);
console.log(`info deviceName = ${info?.deviceName}`);
console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`);
}); });
update.verifyUpdatePackage("XXX", "XXX");
``` ```
### rebootAndCleanUserData<sup>8+</sup> ### getCurrentVersionInfo
rebootAndCleanUserData(): Promise\<number> getCurrentVersionInfo(): Promise\<CurrentVersionInfo>
Reboots the device and clears the user partition data. This function uses a promise to return the result. Obtains information about the current version. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ---------------------------------------- | | ---------------------------------------- | ------------------- |
| Promise\<number> | Promise used to return the execution result. | | Promise\<[CurrentVersionInfo](#currentversioninfo)> | Promise used to return the result.|
**Example** **Example**
``` ```ts
updater.rebootAndCleanUserData().then(result => { updater.getCurrentVersionInfo().then(info => {
console.log("rebootAndCleanUserData " + result); console.log(`info osVersion = ${info.osVersion}`);
console.log(`info deviceName = ${info.deviceName}`);
console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`);
}).catch(err => { }).catch(err => {
console.info("rebootAndCleanUserData promise error: " + err.code); console.log(`getCurrentVersionInfo promise error ${JSON.stringify(err)}`);
}); });
``` ```
### rebootAndCleanUserData<sup>8+</sup> ### getCurrentVersionDescription
rebootAndCleanUserData(callback: AsyncCallback\<number>): void getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void
Reboots the device and clears the user partition data. This function uses a promise to return the result. Obtains the description file of the current version. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------- | --------- | ---------------------------------------- | | ------------------ | ---------------------------------------- | ---- | --------------- |
| callback | AsyncCallback\<number> | Yes | Callback used to return the execution result. | | descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file. |
| callback | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>>) | Yes | Callback used to return the result.|
**Example** **Example**
``` ```ts
updater.rebootAndCleanUserData(result => { // Options of the description file
console.log("rebootAndCleanUserData ", result) var descriptionOptions = {
format: DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese
}
updater.getCurrentVersionDescription(descriptionOptions, (err, info) => {
console.log(`getCurrentVersionDescription info ${JSON.stringify(info)}`);
console.log(`getCurrentVersionDescription err ${JSON.stringify(err)}`);
}); });
``` ```
### applyNewVersion ### getCurrentVersionDescription
applyNewVersion(): Promise\<number> getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>>
Installs the update package. This function uses a promise to return the result. Obtains the description file of the current version. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| ------------------ | ---------------------------------------- | ---- | ------ |
| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ---------------------------------------- | | ---------------------------------------- | -------------------- |
| Promise\<number> | Promise used to return the execution result. | | Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.|
**Example** **Example**
``` ```ts
updater.applyNewVersion().then(result => { // Options of the description file
console.log("appVewVersion ", result) var descriptionOptions = {
format: DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese
}
updater.getCurrentVersionDescription(descriptionOptions).then(info => {
console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`);
}).catch(err => { }).catch(err => {
console.info("applyNewVersion promise error: " + err.code); console.log(`getCurrentVersionDescription promise error ${JSON.stringify(err)}`);
}); });
``` ```
### applyNewVersion ### getTaskInfo
applyNewVersion(callback: AsyncCallback\<number>): void getTaskInfo(callback: AsyncCallback\<TaskInfo>): void
Installs the update package. This function uses a promise to return the result. Obtains information about the update task. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------- | --------- | ---------------------------------------- | | -------- | ------------------------------------- | ---- | ---------------- |
| callback | AsyncCallback\<number> | Yes | Callback used to return the execution result. | | callback | AsyncCallback\<[TaskInfo](#taskinfo)> | Yes | Callback used to return the result.|
**Example** **Example**
``` ```ts
updater.applyNewVersion(result => { updater.getTaskInfo((err, info) => {
console.log("applyNewVersion ", result) console.log(`getTaskInfo isexistTask= ${info?.existTask}`);
}); });
``` ```
### download ### getTaskInfo
download(): void getTaskInfo(): Promise\<TaskInfo>
Downloads the new version and displays the download process. Obtains information about the update task. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Return value**
| Type | Description |
| ------------------------------- | ------------------- |
| Promise\<[TaskInfo](#taskinfo)> | Promise used to return the result.|
**Example** **Example**
``` ```ts
updater.on("downloadProgress", progress => { updater.getTaskInfo().then(info => {
console.log("downloadProgress on" + progress); console.log(`getTaskInfo isexistTask= ${info.existTask}`);
console.log(`downloadProgress status: ` + progress.status); }).catch(err => {
console.log(`downloadProgress percent: ` + progress.percent); console.log(`getTaskInfo promise error ${JSON.stringify(err)}`);
}); });
updater.download();
``` ```
### upgrade ### download
upgrade():void download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions, callback: AsyncCallback\<void>): void
Starts an update. Downloads the new version. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| ----------------- | --------------------------------------- | ---- | ---------------------------------- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. |
| downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example** **Example**
``` ```ts
updater.on("upgradeProgress", progress => { // Version digest information
console.log("upgradeProgress on" + progress); var versionDigestInfo = {
console.log(`upgradeProgress status: ` + progress.status); versionDigest: "versionDigest" // Version digest information in the check result
console.log(`upgradeProgress percent: ` + progress.percent); }
// Download options
var downloadOptions = {
allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
order: update.Order.DOWNLOAD // Download
}
updater.download(versionDigestInfo, downloadOptions, (err) => {
console.log(`download error ${JSON.stringify(err)}`);
}); });
updater.upgrade();
``` ```
### setUpdatePolicy ### download
setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions): Promise\<void>
Sets the update policy. This function uses an asynchronous callback to return the result. Downloads the new version. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- | | ----------------- | --------------------------------------- | ---- | ------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set. | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.|
| callback | Callback used to return the execution result. | Yes | Callback used to return the execution result. | | downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options. |
**Return value**
| Type | Description |
| -------------- | -------------------------- |
| Promise\<void> | Promise that returns no value.|
**Example** **Example**
```ts
// Version digest information
var versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result
}
// Download options
var downloadOptions = {
allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
order: update.Order.DOWNLOAD // Download
}
updater.download(versionDigestInfo, downloadOptions).then(() => {
console.log(`download start`);
}).catch(err => {
console.log(`download error ${JSON.stringify(err)}`);
});
``` ```
// Set the update policy.
let policy = { ### resumeDownload
autoDownload: false,
autoDownloadNet: true, resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions, callback: AsyncCallback\<void>): void
mode: 2,
autoUpgradeInterval: [ 2, 3 ], Resumes download of the new version. This API uses an asynchronous callback to return the result.
autoUpgradeCondition: 2
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| --------------------- | ---------------------------------------- | ---- | ------------------------------------ |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. |
| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes | Options for resuming download. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example**
```ts
// Version digest information
var versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result
}
// Options for resuming download
var resumeDownloadOptions = {
allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
} }
updater.setUpdatePolicy(policy, result => { updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err) => {
console.log("setUpdatePolicy ", result) console.log(`resumeDownload error ${JSON.stringify(err)}`);
}); });
``` ```
### setUpdatePolicy ### resumeDownload
setUpdatePolicy(policy: UpdatePolicy): Promise\<number> resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions): Promise\<void>
Sets the update policy. This function uses a promise to return the result. Resumes download of the new version. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ----------------------------- | --------- | --------------------- | | --------------------- | ---------------------------------------- | ---- | ------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set. | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.|
| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes | Options for resuming download.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ---------------------------------------- | | -------------- | -------------------------- |
| Promise\<number> | Promise used to return the execution result. | | Promise\<void> | Promise that returns no value.|
**Example** **Example**
```ts
// Version digest information
var versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result
}
// Options for resuming download
var resumeDownloadOptions = {
allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
}
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(value => {
console.log(`resumeDownload start`);
}).catch(err => {
console.log(`resumeDownload error ${JSON.stringify(err)}`);
});
``` ```
let policy = {
autoDownload: false, ### pauseDownload
autoDownloadNet: true,
mode: 2, pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions, callback: AsyncCallback\<void>): void
autoUpgradeInterval: [ 2, 3 ],
autoUpgradeCondition: 2 Pauses download of the new version. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ------------------------------------ |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. |
| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes | Options for pausing download. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example**
```ts
// Version digest information
var versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result
}
// Options for pausing download
var pauseDownloadOptions = {
isAllowAutoResume: true // Whether to allow automatic resuming of download
} }
updater.setUpdatePolicy(policy).then(result => updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err) => {
console.log("setUpdatePolicy ", result) console.log(`pauseDownload error ${JSON.stringify(err)}`);
).catch(err => {
console.log("setUpdatePolicy promise error: " + err.code);
}); });
``` ```
### getUpdatePolicy ### pauseDownload
getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions): Promise\<void>
Obtains the update policy. This function uses an asynchronous callback to return the result. Resumes download of the new version. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- | | -------------------- | ---------------------------------------- | ---- | ------ |
| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the update policy. | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.|
| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes | Options for pausing download.|
**Return value**
| Type | Description |
| -------------- | -------------------------- |
| Promise\<void> | Promise that returns no value.|
**Example** **Example**
```ts
// Version digest information
var versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result
}
// Options for pausing download
var pauseDownloadOptions = {
isAllowAutoResume: true // Whether to allow automatic resuming of download
}
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(value => {
console.log(`pauseDownload`);
}).catch(err => {
console.log(`pauseDownload error ${JSON.stringify(err)}`);
});
``` ```
updater.getUpdatePolicy(policy => {
console.log("getUpdatePolicy success"); ### upgrade
console.log(`policy autoDownload = ` + policy.autoDownload);
console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet); upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, callback: AsyncCallback\<void>): void
console.log(`policy mode = ` + policy.mode);
Updates the version. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| ----------------- | --------------------------------------- | ---- | ------------------------------------ |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. |
| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example**
```ts
// Version digest information
var versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result
}
// Installation options
var upgradeOptions = {
order: update.Order.INSTALL // Installation command
}
updater.upgrade(versionDigestInfo, upgradeOptions, (err) => {
console.log(`upgrade error ${JSON.stringify(err)}`);
}); });
``` ```
### getUpdatePolicy ### upgrade
getUpdatePolicy(): Promise\<UpdatePolicy> upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): Promise\<void>
Obtains the update policy. This function uses a promise to return the result. Updates the version. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| ----------------- | --------------------------------------- | ---- | ------ |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.|
| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ---------------------------------------- | | -------------- | -------------------------- |
| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy. | | Promise\<void> | Promise that returns no value.|
**Example** **Example**
``` ```ts
updater.getUpdatePolicy().then(value => { // Version digest information
console.log(`info autoDownload = ` + value.autoDownload); var versionDigestInfo = {
console.log(`info autoDownloadNet = ` + value.autoDownloadNet); versionDigest: "versionDigest" // Version digest information in the check result
console.log(`info mode = ` + value.mode); }
// Installation options
var upgradeOptions = {
order: update.Order.INSTALL // Installation command
}
updater.upgrade(versionDigestInfo, upgradeOptions).then(() => {
console.log(`upgrade start`);
}).catch(err => { }).catch(err => {
console.log("getUpdatePolicy promise error: " + err.code); console.log(`upgrade error ${JSON.stringify(err)}`);
}); });
``` ```
## UpdateTypes ### clearError
Enumerates update types. clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, callback: AsyncCallback\<void>): void
Clears errors. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Description | **Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
| ----- | ------------- |
| OTA | OTA update. | **Parameters**
| patch | Patch update. |
| Name | Type | Mandatory | Description |
| ----------------- | --------------------------------------- | ---- | ------------------------------------ |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. |
| clearOptions | [ClearOptions](#clearoptions) | Yes | Clear options. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example**
```ts
// Version digest information
var versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result
}
// Options for clearing errors
var clearOptions = {
status: update.UpgradeStatus.UPGRADE_FAIL,
}
updater.clearError(versionDigestInfo, clearOptions, (err) => {
console.log(`clearError error ${JSON.stringify(err)}`);
});
```
### clearError
## PackageTypes clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Promise\<void>
Enumerates update package types. Clears errors. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description | **Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
| -------------------- | ------------- | --------------------------------------- |
| PACKAGE_TYPE_NORMAL | 1 | Common update package. | **Parameters**
| PACKAGE_TYPE_BASE | 2 | Basic update package. |
| PACKAGE_TYPE_CUST | 3 | Custom update package. | | Name | Type | Mandatory | Description |
| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. | | ----------------- | --------------------------------------- | ---- | ------ |
| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package. | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.|
| PACKAGE_TYPE_VERSION | 6 | Version update package. | | clearOptions | [ClearOptions](#clearoptions) | Yes | Update options. |
| PACKAGE_TYPE_PATCH | 7 | Patch package. |
**Return value**
| Type | Description |
| -------------- | -------------------------- |
| Promise\<void> | Promise that returns no value.|
**Example**
```ts
// Version digest information
var versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result
}
// Options for clearing errors
var clearOptions = {
status: update.UpgradeStatus.UPGRADE_FAIL,
}
updater.clearError(versionDigestInfo, clearOptions).then(() => {
console.log(`clearError success`);
}).catch(err => {
console.log(`clearError error ${JSON.stringify(err)}`);
});
```
## InstallMode ### getUpgradePolicy
Enumerates update modes. getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void
Obtains the update policy. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description | **Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
| ------------------- | ------------- | ----------------- |
| INSTALL_MODE_NORMAL | 0 | Normal update. | **Parameters**
| INSTALL_MODE_NIGHT | 1 | Update at night. |
| INSTALL_MODE_AUTO | 2 | Automatic update. | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------- |
| callback | AsyncCallback\<[UpgradePolicy](#upgradepolicy)> | Yes | Callback used to return the result.|
**Example**
```ts
updater.getUpgradePolicy((err, policy) => {
console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`);
console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`);
});
```
### getUpgradePolicy
## NewVersionStatus getUpgradePolicy(): Promise\<UpgradePolicy>
Enumerates new version check results. Obtains the update policy. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description | **Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
| ------------------- | ------------- | ---------------------------------------- |
| VERSION_STATUS_ERR | -1 | System error while checking for the new version. | **Return value**
| VERSION_STATUS_NEW | 0 | New version detected. |
| VERSION_STATUS_NONE | 1 | No new version detected. | | Type | Description |
| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version. | | ---------------------------------------- | --------------------- |
| Promise\<[UpgradePolicy](#upgradepolicy)> | Promise used to return the result.|
**Example**
```ts
updater.getUpgradePolicy().then(policy => {
console.log(`policy downloadStrategy = ${policy.downloadStrategy}`);
console.log(`policy autoUpgradeStrategy = ${policy.autoUpgradeStrategy}`);
}).catch(err => {
console.log(`getUpgradePolicy promise error ${JSON.stringify(err)}`);
});
```
### setUpgradePolicy
## UpdatePolicy setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void
Defines the update policy. Sets the update policy. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description | **Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
| ------------------- | --------------------------- | --------- | ------------------------------------ |
| autoDownload | bool | Yes | Automatic update switch. |
| installMode | [InstallMode](#installmode) | Yes | Update mode. |
| autoUpgradeInterval | Array\<number> | Yes | Period of time for automatic update. |
## NewVersionInfo **Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ------------- |
| policy | [UpgradePolicy](#upgradepolicy) | Yes | Update policy. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
let policy = {
downloadStrategy: false,
autoUpgradeStrategy: false,
autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes
}
updater.setUpgradePolicy(policy, (err) => {
console.log(`setUpgradePolicy result: ${err}`);
});
```
Defines the new version information. ### setUpgradePolicy
setUpgradePolicy(policy: UpgradePolicy): Promise\<void>
Sets the update policy. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description | **Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
| --------------- | ---------------------------------------- | --------- | -------------------------------- |
| status | [NewVersionStatus](#newversionstatus) | Yes | Update status. |
| errMsg | string | Yes | Error message. |
| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result. |
| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information. |
## CheckResult **Parameters**
Defines the version check result. | Name | Type | Mandatory | Description |
| ------ | ------------------------------- | ---- | ---- |
| policy | [UpgradePolicy](#upgradepolicy) | Yes | Update policy.|
**Return value**
| Type | Description |
| -------------- | ------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
let policy = {
downloadStrategy: false,
autoUpgradeStrategy: false,
autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes
}
updater.setUpgradePolicy(policy).then(() => {
console.log(`setUpgradePolicy success`);
}).catch(err => {
console.log(`setUpgradePolicy promise error ${JSON.stringify(err)}`);
});
```
### terminateUpgrade
terminateUpgrade(callback: AsyncCallback\<void>): void
Terminates the update. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description | **Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
| ------------- | ----------------------------- | --------- | --------------------------------- |
| versionName | string | Yes | Version name. |
| versionCode | number | Yes | Version code. |
| size | number | Yes | Version size. |
| verifyInfo | string | Yes | Version verification information. |
| packageType | [PackageTypes](#packagetypes) | Yes | Version type. |
| descriptionId | string | Yes | Version description information. |
## DescriptionInfo **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example**
```ts
updater.terminateUpgrade((err) => {
console.log(`terminateUpgrade error ${JSON.stringify(err)}`);
});
```
### terminateUpgrade
terminateUpgrade(): Promise\<void>
Terminates the update. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Return value**
| Type | Description |
| -------------- | -------------------------- |
| Promise\<void> | Promise that returns no value.|
**Example**
```ts
updater.terminateUpgrade().then(() => {
console.log(`terminateUpgrade success`);
}).catch(err => {
console.log(`terminateUpgrade error ${JSON.stringify(err)}`);
});
```
### on
on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void
Enables listening for update events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory | Description |
| ----------------- | ---------------------------------------- | ---- | ---- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.|
| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.|
**Example**
```ts
var eventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // Listening for update events
extraInfo: ""
}
updater.on(eventClassifyInfo, (eventInfo) => {
console.log("updater on " + JSON.stringify(eventInfo));
});
```
### off
off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void
Disables listening for update events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory | Description |
| ----------------- | ---------------------------------------- | ---- | ---- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.|
| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | No | Event callback.|
**Example**
```ts
var eventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // Listening for update events
extraInfo: ""
}
updater.off(eventClassifyInfo, (eventInfo) => {
console.log("updater off " + JSON.stringify(eventInfo));
});
```
## Restorer
### factoryReset
factoryReset(callback: AsyncCallback\<void>): void
Restore the device to its factory settings. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.FACTORY_RESET (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example**
```ts
restorer.factoryReset((err) => {
console.log(`factoryReset error ${JSON.stringify(err)}`);
});
```
### factoryReset
factoryReset(): Promise\<void>
Restore the device to its factory settings. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.FACTORY_RESET (a system permission)
**Return value**
| Type | Description |
| -------------- | -------------------------- |
| Promise\<void> | Promise that returns no value.|
**Example**
```ts
restorer.factoryReset().then(() => {
console.log(`factoryReset success`);
}).catch(err => {
console.log(`factoryReset error ${JSON.stringify(err)}`);
});
```
## LocalUpdater
### verifyUpgradePackage
verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: AsyncCallback\<void>): void
Verifies the update package. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ---- | ---------------- |
| upgradeFile | [UpgradeFile](#upgradefile) | Yes | Update file. |
| certsFile | string | Yes | Path of the certificate file. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var upgradeFile = {
fileType: update.ComponentType.OTA, // OTA package
filePath: "path" // Path of the local update package
}
localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err) => {
console.log(`factoryReset error ${JSON.stringify(err)}`);
});
```
### verifyUpgradePackage
verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<void>
Verifies the update package. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ---- | ------ |
| upgradeFile | [UpgradeFile](#upgradefile) | Yes | Update file. |
| certsFile | string | Yes | Path of the certificate file.|
**Return value**
| Type | Description |
| -------------- | ---------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var upgradeFile = {
fileType: update.ComponentType.OTA, // OTA package
filePath: "path" // Path of the local update package
}
localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => {
console.log(`verifyUpgradePackage success`);
}).catch(err => {
console.log(`verifyUpgradePackage error ${JSON.stringify(err)}`);
});
```
### applyNewVersion
applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: AsyncCallback\<void>): void
Installs the update package. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ---------------------------------- | ---- | --------------------------------------- |
| upgradeFile | Array<[UpgradeFile](#upgradefile)> | Yes | Update file. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.|
**Example**
```ts
var upgradeFiles = [{
fileType: update.ComponentType.OTA, // OTA package
filePath: "path" // Path of the local update package
}]
localUpdater.applyNewVersion(upgradeFiles, (err) => {
console.log(`applyNewVersion error ${JSON.stringify(err)}`);
});
```
### applyNewVersion
applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void>
Installs the update package. This API uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission)
**Return value**
| Type | Description |
| -------------- | -------------------------- |
| Promise\<void> | Promise that returns no value.|
**Example**
```ts
var upgradeFiles = [{
fileType: update.ComponentType.OTA, // OTA package
filePath: "path" // Path of the local update package
}]
localUpdater.applyNewVersion(upgradeFiles).then(() => {
console.log(`applyNewVersion success`);
}).catch(err => {
console.log(`applyNewVersion error ${JSON.stringify(err)}`);
});
```
### on
on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void
Enables listening for update events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory | Description |
| ----------------- | ---------------------------------------- | ---- | ---- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.|
| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.|
**Example**
```ts
var eventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // Listening for update events
extraInfo: ""
}
function onTaskUpdate(eventInfo) {
console.log(`on eventInfo id `, eventInfo.eventId);
}
localUpdater.on(eventClassifyInfo, onTaskUpdate);
```
### off
off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void
Disables listening for update events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory | Description |
| ----------------- | ---------------------------------------- | ---- | ---- |
| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.|
| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.|
**Example**
```ts
var eventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // Listening for update events
extraInfo: ""
}
function onTaskUpdate(eventInfo) {
console.log(`on eventInfo id `, eventInfo.eventId);
}
localUpdater.off(eventClassifyInfo, onTaskUpdate);
```
## UpgradeInfo
Represents update information.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------------ | ----------------------------- | ---- | ------ |
| upgradeApp | string | Yes | Application package name. |
| businessType | [BusinessType](#businesstype) | Yes | Update service type.|
## BusinessType
Enumerates update service types.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------- | ----------------------------------- | ---- | ---- |
| vendor | [BusinessVendor](#businessvendor) | Yes | Application vendor. |
| subType | [BusinessSubType](#businesssubtype) | Yes | Type |
## CheckResult
Represents the package check result.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ----------------- | --------------------------------- | ---- | ------ |
| isExistNewVersion | bool | Yes | Whether a new version is available.|
| newVersionInfo | [NewVersionInfo](#newversioninfo) | No | Information about the new version. |
## NewVersionInfo
Represents information about the new version.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ----------------- | ---------------------------------------- | ---- | ---- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.|
| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes | Version components.|
## VersionDigestInfo
Represents version digest information.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------------- | ------ | ---- | ---- |
| versionDigest | string | Yes | Version digest information.|
## VersionComponent
Represents a version component.
**System capability**: SystemCapability.Update.UpdateService
| Parameter | Type | Mandatory | Description |
| --------------- | ----------------------------------- | ---- | -------- |
| componentId | number | Yes | Component ID. |
| componentType | [ComponentType](#componenttype) | Yes | Component type. |
| upgradeAction | [UpgradeAction](#upgradeaction) | Yes | Update mode. |
| displayVersion | string | Yes | Display version number. |
| innerVersion | string | Yes | Internal version number. |
| size | number | Yes | Update package size. |
| effectiveMode | [EffectiveMode](#effectivemode) | Yes | Effective mode. |
| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes | Information about the version description file.|
## DescriptionOptions
Represents options of the description file.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------- | ---- | ------ |
| format | [DescriptionFormat](#descriptionformat) | Yes | Format of the description file.|
| language | string | Yes | Language of the description file.|
## ComponentDescription
Represents a component description file.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| --------------- | ----------------------------------- | ---- | ------ |
| componentId | string | Yes | Component ID. |
| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes | Information about the description file.|
## DescriptionInfo
Represents information about the version description file.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| --------------- | ----------------------------------- | ---- | ------ |
| descriptionType | [DescriptionType](#descriptiontype) | Yes | Type of the description file.|
| content | string | Yes | Content of the description file.|
## CurrentVersionInfo
Represents information about the current version.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ----------------- | ---------------------------------------- | ---- | ----- |
| osVersion | string | Yes | System version number.|
| deviceName | string | Yes | Device name. |
| versionComponents | Array\<[VersionComponent](#versioncomponent)> | No | Version components. |
## DownloadOptions
Represents download options.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------------ | ------------------- | ---- | ---- |
| allowNetwork | [NetType](#nettype) | Yes | Network type.|
| order | [Order](#order) | Yes | Update command.|
## ResumeDownloadOptions
Represents options for resuming download.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------------ | ------------------- | ---- | ---- |
| allowNetwork | [NetType](#nettype) | Yes | Network type.|
## PauseDownloadOptions
Represents options for pausing download.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type| Mandatory | Description |
| ----------------- | ---- | ---- | -------- |
| isAllowAutoResume | bool | Yes | Whether to allow automatic resuming of download.|
## UpgradeOptions
Represents update options.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ----- | --------------- | ---- | ---- |
| order | [Order](#order) | Yes | Update command.|
## ClearOptions
Represents options for clearing errors.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------ | ------------------------------- | ---- | ---- |
| status | [UpgradeStatus](#upgradestatus) | Yes | Error status.|
## UpgradePolicy
Represents an update policy.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------------------- | --------------------------------------- | ---- | ------- |
| downloadStrategy | bool | Yes | Automatic download policy. |
| autoUpgradeStrategy | bool | Yes | Automatic update policy. |
| autoUpgradePeriods | Array\<[UpgradePeriod](#upgradeperiod)> | Yes | Automatic update period.|
## UpgradePeriod
Represents a period for automatic update.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ---- |
| start | number | Yes | Start time.|
| end | number | Yes | End time.|
## TaskInfo
Represents task information.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| --------- | --------------------- | ---- | ------ |
| existTask | bool | Yes | Whether a task exists.|
| taskBody | [TaskBody](#taskinfo) | Yes | Task data. |
## EventInfo
Represents event type information.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| -------- | --------------------- | ---- | ---- |
| eventId | [EventId](#eventid) | Yes | Event ID.|
| taskBody | [TaskBody](#taskinfo) | Yes | Task data.|
## TaskBody
Represents task data.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ----------------- | ---------------------------------------- | ---- | ---- |
| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.|
| status | [UpgradeStatus](#upgradestatus) | Yes | Update status.|
| subStatus | number | No | Sub-status. |
| progress | number | Yes | Progress. |
| installMode | number | Yes | Installation mode.|
| errorMessages | Array\<[ErrorMessage](#errormessage)> | No | Error message.|
| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes | Version components.|
## ErrorMessage
Represents an error message.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------------ | ------ | ---- | ---- |
| errorCode | number | Yes | Error code. |
| errorMessage | string | Yes | Error description.|
## EventClassifyInfo
Represents event type information.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| ------------- | ------------------------------- | ---- | ---- |
| eventClassify | [EventClassify](#eventclassify) | Yes | Event type.|
| extraInfo | string | Yes | Additional information.|
## UpgradeFile
Represents an update file.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ---- |
| fileType | [ComponentType](#componenttype) | Yes | File type.|
| filePath | string | Yes | File path.|
## UpgradeTaskCallback
### (eventInfo: [EventInfo](#eventinfo)): void
Represents an event callback.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description |
| --------- | ----------------------- | ---- | ---- |
| eventInfo | [EventInfo](#eventinfo) | Yes | Event information.|
## BusinessVendor
Device vendor.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| ------ | -------- | ---- |
| PUBLIC | "public" | Open source. |
## BusinessSubType
Represents an update type.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| -------- | ---- | ---- |
| FIRMWARE | 1 | Firmware. |
## ComponentType
Represents a component type.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| ---- | ---- | ---- |
| OTA | 1 | Firmware. |
## UpgradeAction
Represents an update mode.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| -------- | ---------- | ---- |
| UPGRADE | "upgrade" | Differential package. |
| RECOVERY | "recovery" | Recovery package. |
## EffectiveMode
Represents an effective mode.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| ------------- | ---- | ---- |
| COLD | 1 | Cold update. |
| LIVE | 2 | Live update. |
| LIVE_AND_COLD | 3 | Hybrid live and cold update.|
## DescriptionType
Represents a description file type.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| ------- | ---- | ---- |
| CONTENT | 0 | Content. |
| URI | 1 | Link. |
## DescriptionFormat
Represents a description file format.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| ---------- | ---- | ---- |
| STANDARD | 0 | Standard format.|
| SIMPLIFIED | 1 | Simple format.|
## NetType
Enumerates network types.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| ----------------- | ---- | --------- |
| CELLULAR | 1 | Data network. |
| METERED_WIFI | 2 | Wi-Fi hotspot. |
| NOT_METERED_WIFI | 4 | Non Wi-Fi hotspot. |
| WIFI | 6 | Wi-Fi. |
| CELLULAR_AND_WIFI | 7 | Data network and Wi-Fi.|
## Order
Represents an update command.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| -------------------- | ---- | ----- |
| DOWNLOAD | 1 | Download. |
| INSTALL | 2 | Install. |
| DOWNLOAD_AND_INSTALL | 3 | Download and install.|
| APPLY | 4 | Apply. |
| INSTALL_AND_APPLY | 6 | Install and apply.|
## UpgradeStatus
Enumerates update states.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| ---------------- | ---- | ---- |
| WAITING_DOWNLOAD | 20 | Waiting for download. |
| DOWNLOADING | 21 | Downloading. |
| DOWNLOAD_PAUSED | 22 | Download paused.|
| DOWNLOAD_FAIL | 23 | Download failed.|
| WAITING_INSTALL | 30 | Waiting for installation. |
| UPDATING | 31 | Updating. |
| WAITING_APPLY | 40 | Waiting for applying the update. |
| APPLYING | 21 | Applying the update. |
| UPGRADE_SUCCESS | 50 | Update succeeded.|
| UPGRADE_FAIL | 51 | Update failed.|
## EventClassify
Represents an event type.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value | Description |
| ---- | ---------- | ---- |
| TASK | 0x01000000 | Task event.|
## EventId
Defines the version description information. Enumerates event IDs.
**System capability**: SystemCapability.Update.UpdateService **System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory | Description | | Name | Default Value | Description |
| ------------- | ------ | --------- | ------------------------------ | | ---------------------- | ---------- | ------ |
| descriptionId | string | Yes | Version ID information. | | EVENT_TASK_BASE | 0x01000000 | Indicates a task event. |
| content | string | Yes | Version changelog information. | | EVENT_TASK_RECEIVE | 0x01000001 | Indicates that a task is received. |
| EVENT_TASK_CANCEL | 0x01000010 | Indicates that a task is cancelled. |
| EVENT_DOWNLOAD_WAIT | 0x01000011 | Indicates the state of waiting for the download. |
| EVENT_DOWNLOAD_START | 0x01000100 | Indicates that the download starts. |
| EVENT_DOWNLOAD_UPDATE | 0x01000101 | Indicates the download progress update.|
| EVENT_DOWNLOAD_PAUSE | 0x01000110 | Indicates that the download is paused. |
| EVENT_DOWNLOAD_RESUME | 0x01000111 | Indicates that the download is resumed. |
| EVENT_DOWNLOAD_SUCCESS | 0x01001000 | Indicates that the download succeeded. |
| EVENT_DOWNLOAD_FAIL | 0x01001001 | Indicates that the download failed. |
| EVENT_UPGRADE_WAIT | 0x01001010 | Indicates the state of waiting for the update. |
| EVENT_UPGRADE_START | 0x01001011 | Indicates that the update starts. |
| EVENT_UPGRADE_UPDATE | 0x01001100 | Indicates that the update is in progress. |
| EVENT_APPLY_WAIT | 0x01001101 | Indicates the state of waiting for applying the update. |
| EVENT_APPLY_START | 0x01001110 | Indicates the state of applying the update. |
| EVENT_UPGRADE_SUCCESS | 0x01001111 | Indicates that the update succeeded. |
| EVENT_UPGRADE_FAIL | 0x01010000 | Indicates that the update failed. |
...@@ -8,7 +8,7 @@ The open-source code repositories are available at [https://openharmony.gitee.co ...@@ -8,7 +8,7 @@ The open-source code repositories are available at [https://openharmony.gitee.co
## Overview of Source Code Acquisition<a name="section12763342204"></a> ## Overview of Source Code Acquisition<a name="section12763342204"></a>
You can use any of the following methods to acquire the OpenHarmony source code: The OpenHarmony source code is open to you as [HPM parts](../hpm-part/Readme-EN.md), which can be obtained in any of the following ways:
- **Method 1**: Acquire the source code from the Gitee code repository. You can use the **repo** or **git** tool to download the latest code from the code repository. - **Method 1**: Acquire the source code from the Gitee code repository. You can use the **repo** or **git** tool to download the latest code from the code repository.
- **Method 2**: Acquire the source code from [DevEco Marketplace](https://repo.harmonyos.com/#/en/home). Visit [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), search for your desired open-source distribution, and download the bundle list \(or customize bundles and download the bundle list\). Then use the **hpm-cli** tool to download and install the bundles and compilation toolchain on your local PC. - **Method 2**: Acquire the source code from [DevEco Marketplace](https://repo.harmonyos.com/#/en/home). Visit [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), search for your desired open-source distribution, and download the bundle list \(or customize bundles and download the bundle list\). Then use the **hpm-cli** tool to download and install the bundles and compilation toolchain on your local PC.
...@@ -89,7 +89,7 @@ You can use any of the following methods to acquire the OpenHarmony source code: ...@@ -89,7 +89,7 @@ You can use any of the following methods to acquire the OpenHarmony source code:
- **Obtaining OpenHarmony release code** - **Obtaining OpenHarmony release code**
For details about how to obtain the source code of an OpenHarmony release, see the [Release Notes](https://gitee.com/openharmony/docs/blob/master/en/release-notes/Readme.md). For details about how to obtain the source code of an OpenHarmony release, see the [Release Notes]([Release Notes](../../release-notes/Readme.md).
## Method 2: Acquiring Source Code from DevEco Marketplace<a name="section463013147412"></a> ## Method 2: Acquiring Source Code from DevEco Marketplace<a name="section463013147412"></a>
...@@ -168,7 +168,7 @@ You must install **Node.js** and HPM on your local PC. The installation procedur ...@@ -168,7 +168,7 @@ You must install **Node.js** and HPM on your local PC. The installation procedur
To ensure the download performance, you are advised to download the source code or the corresponding solution from the image library of the respective site listed in the table below. To ensure the download performance, you are advised to download the source code or the corresponding solution from the image library of the respective site listed in the table below.
The table below provides only the sites for downloading the latest OpenHarmony LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes](https://gitee.com/openharmony/docs/blob/master/en/release-notes/Readme.md). The table below provides only the sites for downloading the latest OpenHarmony LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes]([Release Notes](../../release-notes/Readme.md).
**Table 1** Sites for acquiring source code **Table 1** Sites for acquiring source code
...@@ -182,12 +182,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L ...@@ -182,12 +182,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) | | 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) |
| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | | 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 Information**| **Site**| **SHA-256 Verification Code**| | **Source code of the Latest Release**| **Version Information**| **Site**| **SHA-256 Verification Code**|
| Full code base (for mini, small, and standard systems)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/code-v3.2-Beta1.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/code-v3.2-Beta1.tar.gz.sha256)| | Full code base (for mini, small, and standard systems)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256)|
| RK3568 standard system solution (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)| | RK3568 standard system solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)|
| Hi3861 solution (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_pegasus.tar.gz.sha256) | | Hi3861 solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256) |
| Hi3516 solution-LiteOS (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz.sha256)| | Hi3516 solution-LiteOS (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz.sha256)|
| Hi3516 solution-Linux (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz.sha256)| | Hi3516 solution-Linux (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz.sha256)|
| RELEASE-NOTES | 3.2 Beta1 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v3.2-beta1.md)| - | | RELEASE-NOTES | 3.2 Beta2 | [Download](../../release-notes/OpenHarmony-v3.2-beta2.md)| - |
| **Compiler Toolchain**| **Version Information**| **Site**| **SHA-256 Verification Code**| | **Compiler Toolchain**| **Version Information**| **Site**| **SHA-256 Verification Code**|
| Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | | Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - |
...@@ -197,7 +197,7 @@ The table below provides only the sites for downloading the latest OpenHarmony L ...@@ -197,7 +197,7 @@ The table below provides only the sites for downloading the latest OpenHarmony L
> >
> The image repository is synchronized at 23:00 (UTC +8:00) every day. > The image repository is synchronized at 23:00 (UTC +8:00) every day.
Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to GitHub. For details, see [Adding a new SSH key to your GitHub account](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).\) Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to GitHub. For details, see [Adding a new SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).\)
``` ```
repo init -u git@github.com:openharmony/manifest.git -b master --no-repo-verify repo init -u git@github.com:openharmony/manifest.git -b master --no-repo-verify
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册