2021-06-02 02:19:43 +08:00
2021-06-02 02:19:43 +08:00
2021-06-02 02:19:43 +08:00
2021-06-02 02:19:43 +08:00
2021-06-02 02:19:43 +08:00
2021-06-02 02:19:43 +08:00
2021-06-02 02:19:43 +08:00
2021-06-02 02:19:43 +08:00
2021-06-02 02:19:43 +08:00

Update Service

Introduction

The update service is a system ability (SA) started by the init process of OHOS to implement an update.

The update service provides the following functions:

  1. Searching for available update packages

  2. Downloading update packages

  3. Setting and obtaining the update policy

  4. Triggering an update

Directory Structure

base/update/updateservice  # Update service code
├── client                 # NAPI-based update client
├── engine                 # Update client engine
│   ├── etc                # rc configuration files for the update client engine
│   ├── include            # Header files for the update client engine
│   ├── sa_profile         # SA profiles
│   └── src                # Source code of the update client engine
├── interfaces             # Update client APIs
│   └── innerkits          # SA APIs 
├── kits                   # External APIs
│   └── js                 # JS APIs for the update app
└── tests                  # Test code
    └── unittest           # Unit test code for the update client

Description

JS APIs

API

Description

checkNewVersion

Checks whether a new update package is available.

download()

Downloads the update package.

upgrade()

Writes the update command to the misc partition and runs the reboot command to access the updater.

getNewVersionInfo()

Obtains the version information after a version update.

setUpdatePolicy

Sets the update policy.

getUpdatePolicy

Obtains the update policy.

Usage

  1. Import libupdateclient.
import client from 'libupdateclient.z.so'
  1. Obtain the Updater object.
let updater = client.getUpdater('OTA');
  1. Obtain the new version information.
updater.getNewVersionInfo(info => {
	info "New version information"
});
  1. Checks for a new version.
updater.checkNewVersion(info => {
	info "New version information"
});
  1. Download the new version and monitor the download process.
updater.download();
updater.on("downloadProgress", progress => {
	progress "Download progress information"
});
  1. Start the update.
updater.upgrade();
updater.on("upgradeProgress", progress => {
	progress "Update progress information"
});
  1. Set the update policy.
updater.setUpdatePolicy(result => {
	result "Update policy setting result"
});
  1. Check the update policy.
updater.getUpdatePolicy(policy => {
	policy "Update policy"
});

Repositories Involved

Update subsystem

update_app

update_updateservice

update_updater

S
Description
提供系统更新的系统服务,具备搜索,下载,安装新版本的功能。
Readme 2.4 MiB
Languages
C++ 97.6%
C 2.4%