mirror of
https://github.com/openharmony/update_updateservice.git
synced 2026-07-01 21:03:59 -04:00
73e015c4de555da881c77167deb0682d879789f8
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:
-
Searching for available update packages
-
Downloading update packages
-
Setting and obtaining the update policy
-
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
Writes the update command to the misc partition and runs the reboot command to access the updater. |
|
Usage
- Import libupdateclient.
import client from 'libupdateclient.z.so'
- Obtain the Updater object.
let updater = client.getUpdater('OTA');
- Obtain the new version information.
updater.getNewVersionInfo(info => {
info "New version information"
});
- Checks for a new version.
updater.checkNewVersion(info => {
info "New version information"
});
- Download the new version and monitor the download process.
updater.download();
updater.on("downloadProgress", progress => {
progress "Download progress information"
});
- Start the update.
updater.upgrade();
updater.on("upgradeProgress", progress => {
progress "Update progress information"
});
- Set the update policy.
updater.setUpdatePolicy(result => {
result "Update policy setting result"
});
- Check the update policy.
updater.getUpdatePolicy(policy => {
policy "Update policy"
});
Repositories Involved
Update subsystem
update_app
update_updateservice
update_updater
Description
Languages
C++
97.6%
C
2.4%