diff --git a/en/application-dev/device/pointerstyle-guidelines.md b/en/application-dev/device/pointerstyle-guidelines.md index cecab92b282e2da7a3bb966bcedeefa84768f22e..bcc09093eed4440a0c5e62c5d4cfe37a3f954c87 100644 --- a/en/application-dev/device/pointerstyle-guidelines.md +++ b/en/application-dev/device/pointerstyle-guidelines.md @@ -15,11 +15,11 @@ import pointer from '@ohos.multimodalInput.pointer'; The following table lists the common APIs for mouse pointer management. For details about the APIs, see [ohos.multimodalInput.pointer](../reference/apis/js-apis-pointer.md). | Instance | API | Description | -| ------- | ------------------------------------------------------------ | --------------------------------------------------------------- | -| pointer | function isPointerVisible(callback: AsyncCallback\): void; | Checks the visible status of the mouse pointer. | -| pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\): void; | Sets the visible status of the mouse pointer. This setting takes effect for the mouse pointer globally. | +| ------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| pointer | function isPointerVisible(callback: AsyncCallback\): void; | Checks the visible status of the mouse pointer. | +| pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\): void; | Sets the visible status of the mouse pointer. This setting takes effect for the mouse pointer globally.| | pointer | function setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback\): void; | Sets the mouse pointer style. This setting takes effect for the mouse pointer style of a specified window. | -| pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\): void; | Obtains the mouse pointer style. | +| pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\): void; | Obtains the mouse pointer style. | ## Hiding the Mouse Pointer @@ -77,43 +77,48 @@ When designing a color picker, you can have the mouse pointer switched to the co 5. Set the mouse pointer to the default style. ```js +import pointer from '@ohos.multimodalInput.pointer'; import window from '@ohos.window'; // 1. Enable the color pickup function. // 2. Obtain the window ID. -window.getTopWindow((error, windowClass) => { - windowClass.getProperties((error, data) => { - var windowId = data.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - // 3. Set the mouse pointer to the color picker style. - pointer.setPointerStyle(windowId, pointer.PointerStyle.COLOR_SUCKER).then(() => { - console.log(`Successfully set mouse pointer style`); - }); - } catch (error) { - console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(message)}`); - } - }); +window.getLastWindow(this.context, (error, windowClass) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + var windowId = windowClass.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + // 3. Set the mouse pointer to the color picker style. + pointer.setPointerStyle(windowId, pointer.PointerStyle.COLOR_SUCKER).then(() => { + console.log(`Successfully set mouse pointer style`); + }); + } catch (error) { + console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(`message`)}`); + } }); // 4. End color pickup. -window.getTopWindow((error, windowClass) => { - windowClass.getProperties((error, data) => { - var windowId = data.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - // 5. Set the mouse pointer to the default style. - pointer.setPointerStyle(windowId, pointer.PointerStyle.DEFAULT).then(() => { - console.log(`Successfully set mouse pointer style`); - }); - } catch (error) { - console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(message)}`); - } - }); +window.getLastWindow(this.context, (error, windowClass) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + var windowId = windowClass.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + // 5. Set the mouse pointer to the default style. + pointer.setPointerStyle(windowId, pointer.PointerStyle.DEFAULT).then(() => { + console.log(`Successfully set mouse pointer style`); + }); + } catch (error) { + console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(`message`)}`); + } }); ``` diff --git a/en/application-dev/reference/apis/js-apis-contact.md b/en/application-dev/reference/apis/js-apis-contact.md index 2778a143c65125eca650324e67a220ab60f64ead..bcc8b36fc9a93191258ed78edb68df61ccce4c28 100644 --- a/en/application-dev/reference/apis/js-apis-contact.md +++ b/en/application-dev/reference/apis/js-apis-contact.md @@ -166,6 +166,7 @@ Updates a contact based on the specified contact information. This API uses an a ```js contact.updateContact({ + id: 1, name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, (err) => { @@ -200,6 +201,7 @@ Updates a contact based on the specified contact information and attributes. Thi ```js contact.updateContact({ + id: 1, name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, { @@ -241,6 +243,7 @@ Updates a contact based on the specified contact information and attributes. Thi ```js let promise = contact.updateContact({ + id: 1, name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, { diff --git a/en/application-dev/reference/apis/js-apis-pointer.md b/en/application-dev/reference/apis/js-apis-pointer.md index a6a94cddde77b0bf1c9e70c29c6c2c8d89997c74..49ed81e115de6345453c93441b68cda2a132021b 100644 --- a/en/application-dev/reference/apis/js-apis-pointer.md +++ b/en/application-dev/reference/apis/js-apis-pointer.md @@ -2,7 +2,8 @@ The **pointer** module provides APIs related to pointer attribute management. -> **NOTE**
+> **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. ## Modules to Import @@ -237,6 +238,8 @@ Obtains the mouse movement speed. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.Pointer +**System API**: This is a system API. + **Return value** | Name | Description | @@ -263,8 +266,6 @@ Obtains the mouse pointer style. This API uses an asynchronous callback to retur **System capability**: SystemCapability.MultimodalInput.Input.Pointer -**System API**: This is a system API. - **Parameters** | Name | Type | Mandatory | Description | @@ -277,21 +278,23 @@ Obtains the mouse pointer style. This API uses an asynchronous callback to retur ```js import window from '@ohos.window'; -window.getTopWindow((error, win) => { - win.getWindowProperties((error, properties) => { - let windowId = properties.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - pointer.getPointerStyle(windowId, (error, style) => { - console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); - }); - } catch (error) { - console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); - } - }); +window.getLastWindow(this.context, (error, win) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + let windowId = win.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.getPointerStyle(windowId, (error, style) => { + console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); + }); + } catch (error) { + console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } }); ``` @@ -320,21 +323,23 @@ Obtains the mouse pointer style. This API uses a promise to return the result. ```js import window from '@ohos.window'; -window.getTopWindow((error, win) => { - win.getWindowProperties((error, properties) => { - let windowId = properties.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - pointer.getPointerStyle(windowId).then((style) => { - console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); - }); - } catch (error) { - console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); - } - }); +window.getLastWindow(this.context, (error, win) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + let windowId = win.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.getPointerStyle(windowId).then((style) => { + console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); + }); + } catch (error) { + console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } }); ``` @@ -359,21 +364,23 @@ Sets the mouse pointer style. This API uses an asynchronous callback to return t ```js import window from '@ohos.window'; -window.getTopWindow((error, win) => { - win.getWindowProperties((error, properties) => { - let windowId = properties.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => { - console.log(`Set pointer style success`); - }); - } catch (error) { - console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); - } - }); +window.getLastWindow(this.context, (error, win) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + let windowId = win.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => { + console.log(`Set pointer style success`); + }); + } catch (error) { + console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } }); ``` ## pointer.setPointerStyle9+ @@ -397,21 +404,23 @@ Sets the mouse pointer style. This API uses a promise to return the result. ```js import window from '@ohos.window'; -window.getTopWindow((error, win) => { - win.getWindowProperties((error, properties) => { - let windowId = properties.id; - if (windowId < 0) { - console.log(`Invalid windowId`); - return; - } - try { - pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { - console.log(`Set pointer style success`); - }); - } catch (error) { - console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); - } - }); +window.getLastWindow(this.context, (error, win) => { + if (error.code) { + console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error)); + return; + } + let windowId = win.getWindowProperties().id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { + console.log(`Set pointer style success`); + }); + } catch (error) { + console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } }); ``` ## PointerStyle9+ diff --git a/en/device-dev/get-code/gettools-acquire.md b/en/device-dev/get-code/gettools-acquire.md index a3025ebd834424ff319aa25f3194609ead2cf1e9..5c220923fef21109d1556e925d96946da2d54c7f 100644 --- a/en/device-dev/get-code/gettools-acquire.md +++ b/en/device-dev/get-code/gettools-acquire.md @@ -74,6 +74,7 @@ Before using the Docker environment, perform the following operations: > > You do not need to obtain the source code for the HPM-based Docker environment. +3. Perform subsequent operations as a user who has the root permission or has been granted the permission to use Docker. ## Standalone Docker Environment diff --git a/en/device-dev/subsystems/subsys-boot-init-deviceInfo.md b/en/device-dev/subsystems/subsys-boot-init-deviceInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..fd2c79d06f047628a118cdc137a4acbdfefa67ca --- /dev/null +++ b/en/device-dev/subsystems/subsys-boot-init-deviceInfo.md @@ -0,0 +1,158 @@ +# DeviceInfo Adaptation + +## DeviceInfo parameters and mapping APIs + +| Parameter| API| Description| +|----------|------- |------| +| const.product.devicetype | const char\* GetDeviceType(void) | Obtains the device type.| +| const.product.manufacturer | const char\* GetManufacture(void) | Obtains the device manufacturer.| +| const.product.brand | const char\* GetBrand(void) | Obtains the device brand.| +| const.product.name | const char\* GetMarketName(void) | Obtains the device marketing name.| +| const.build.product | const char\* GetProductSeries(void) | Obtains the device series name.| +| const.product.model | const char\* GetProductModel(void) | Obtains the device authentication model.| +| const.software.model | const char\* GetSoftwareModel(void) | Obtains the device software model.| +| const.product.hardwareversion | const char\* GetHardwareModel(void) | Obtains the device hardware model.| +| const.product.hardwareprofile | const char\* GetHardwareProfile(void) | Obtains the device hardware profile.| +| ohos.boot.sn | const char\* GetSerial(void) | Obtains the serial number (SN) of the device.| +| const.product.software.version | const char\* GetDisplayVersion(void) | Obtains the software version visible to users.| +| const.product.bootloader.version | const char\* GetBootloaderVersion(void) | Obtains the bootloader version of the device.| +| const.product.udid | int GetDevUdid(char \*udid, int size) | Obtains the UDID of the device through **DeviceInfo** or through calculation if the attempt to obtain the UDID through **DeviceInfo** fails.| +| | const char *AclGetSerial(void); | Obtains the SN of the device (with ACL check).| +| | int AclGetDevUdid(char *udid, int size); | Obtains the UDID of the device (with ACL check).| + +## DeviceInfo Source + +### Adaptation of OHOS Fixed-value Parameters + +- OHOS fixed-value parameters: + + ``` + const.ohos.version.security_patch + const.ohos.releasetype + const.ohos.apiversion + const.ohos.fullname + ``` + +- Description of adaptation: + + OHOS fixed-value parameters are filled by the OHOS and do not need to be adapted by vendors. Currently, these parameters are defined in the **/base/startup/init/services/etc/param/ohos_const/ohos.para** file. + +### Adaptation of Vendor Fixed-value Parameters + +- Vendor fixed-value parameters: + + ``` + const.product.devicetype + const.product.manufacturer + const.product.brand + const.product.name + const.build.product + const.product.model + const.software.model + const.product.hardwareversion + const.product.hardwareprofile + const.product.software.version + const.product.bootloader.version + const.build.characteristics + ... ... + + ``` + + +- Description of adaptation: + + Adapt parameters in the **vendor** directory based on actual requirements. + + (1) Take RK3568 as an example for standard-system devices. Adapt parameters in the **/vendor/hihope/rk3568/etc/para/hardware_rk3568.para** file and install the file to the specified directory. + + ``` + ohos_prebuilt_etc("para_for_chip_prod") { + source = "./para/hardware_rk3568.para" + install_images = [ chip_prod_base_dir ] + relative_install_dir = "para" + part_name = "product_rk3568" + } + ``` + + (2) For mini- and small-system devices, adapt parameters in the respective **hals/utils/sys_param/vendor.para** file. For example: + + ``` + const.product.manufacturer=Talkweb + + const.product.brand=Talkweb + + const.product.name=Niobe + + const.build.product=Niobe + + const.product.model=Niobe407 + + const.software.model="2.0.0" + + const.product.hardwareversion="1.0.0" + + const.product.hardwareprofile="RAM:192K,ROM:1M,ETH:true" + ... ... + ``` + +### Adaptation of Vendor Dynamic-value Parameters + +- Currently, three ways are provided to obtain vendor dynamic-value parameters: cmdline, macro definition, and **BUILD.gn** definition. + + 1. cmdline: Values that are read from cmdline include **ohos.boot.hardware**, **ohos.boot.bootslots**, and **ohos.boot.sn**. The way to obtain **ohos.boot.sn** differs according to the system type as follows: + + (1) For standard-system devices: **ohos.boot.sn** is read from cmdline (generated by U-Boot). If the SN is obtained, the value is directly read; if the file path is obtained, the value is read from the file. If the preceding attempt fails, the value is read from the default SN files; that is, **/sys/block/mmcblk0/device/cid** and **/proc/bootdevice/cid**. + + (2) For mini- and small-system devices: These devices may come with their own special algorithms. Therefore, **HalGetSerial()** can be used to obtain the SN from the **hal_sys_param.c** file in the **hals/utils/sys_param** directory. + + 2. Macro definition: Obtain parameter values by compiling macro definitions. Currently, this mode is available only for mini- and small-system devices. For example: + + ``` + defines = [ + "INCREMENTAL_VERSION=\"${ohos_version}\"", + "BUILD_TYPE=\"${ohos_build_type}\"", + "BUILD_USER=\"${ohos_build_user}\"", + "BUILD_TIME=\"${ohos_build_time}\"", + "BUILD_HOST=\"${ohos_build_host}\"", + "BUILD_ROOTHASH=\"${ohos_build_roothash}\"", + ] + ``` + + 3. **BUILD.gn** definition: Obtain parameter values from the **/base/startup/init/services/etc/BUILD.gn** file. For example: + + ``` + if (target_cpu == "arm64") { + extra_paras += [ "const.product.cpu.abilist=arm64-v8a" ] + } + if (build_variant == "user") { + extra_paras += [ + "const.secure=1", + "const.debuggable=0", + ] + } else if (build_variant == "root") { + extra_paras += [ + "const.secure=0", + "const.debuggable=1", + ] + } + if (device_type != "default") { + extra_paras += [ + "const.product.devicetype=${device_type}", + "const.build.characteristics=${device_type}", + ] + } + module_install_dir = "etc/param" + } + ``` +#### Notes + + (1) For small-system devices, add the compilation of **vendor.para** to the **hals/utils/sys_param/BUILD.gn** file. + + ``` + copy("vendor.para") { + sources = [ "./vendor.para" ] + outputs = [ "$root_out_dir/vendor/etc/param/vendor.para" ] + } + ``` + + (2) For mini-system devices, a file system is not available and therefore, the **hal_sys_param.c** and **vendor.para** files are converted into header files and are compiled to the system during compilation. diff --git a/en/device-dev/subsystems/subsys-boot-init-jobs.md b/en/device-dev/subsystems/subsys-boot-init-jobs.md index 0a9bc5be6ee4270204bc0899dc825fce38a1617e..bd8ab114595085b855a2b60f6d84f17d74c4936d 100644 --- a/en/device-dev/subsystems/subsys-boot-init-jobs.md +++ b/en/device-dev/subsystems/subsys-boot-init-jobs.md @@ -5,7 +5,7 @@ A job is a set of commands in the **.cfg** file of the init module. A maximum of ### Basic Concepts A job can be configured in the **init.cfg** file or the custom **.cfg** file of the module. The parser of the init process aggregates commands of the jobs with the same name into one job. For jobs with the same name, the init process only ensures that the commands in the **init.cfg** file are executed in preference. It does not guarantee the execution sequence of commands in other **.cfg** files. -- Common job +- Basic job A job executed in a fixed phase during init process startup, for example, pre-init, init, or post-init. - pre-init: pre-initialization phase. Key services on which other services depend, such as ueventd, watchdog, and hilogd, are started in this phase. The mounting of data partitions is also done in this phase. @@ -20,7 +20,21 @@ A job can be configured in the **init.cfg** file or the custom **.cfg** file of A job triggered based on specific conditions. You can add conditions to a job so that the job is executed when the conditions are met. - A condition is a combination of system parameter values and supports operations such as **&&** and **||**, for example, **"condition": "sys.usb.config = none && sys.usb.configfs = 0"**. When defining commands for a job, you can add attributes in the format of **param:xxx** to form different commands. + A condition is a combination of system parameter values. It supports operations such as **&&** and **||** as well as matching of any parameter values by using the wildcard character (*). + + Generally, you can configure a condition in the format shown below: + + ``` + "condition": "sys.usb.config = none && sys.usb.configfs = 0" + ``` + + If you need to enable parameter checking in the boot phase, configure the condition as follows: + + ``` + "condition": "boot && const.debuggable=1" + ``` + + When defining commands for a job, you can add attributes in the format of **param:xxx** to form different commands. ### Constraints With the system parameter module, the standard system is able to support basic, conditional, and custom jobs. The small system supports only basic jobs. @@ -29,881 +43,80 @@ With the system parameter module, the standard system is able to support basic, ### Use Cases A job is a command set, where you can manage the commands to be executed. A maximum of 4096 commands can be added to a command set. During the init startup process, the execution of jobs helps ensure normal running of services. -### Parameters +### Parameter Description **Table 1** Command set description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Command - - - Format and Example - - - Description - - - Supported System Type - -
- mkdir - - mkdir target folder [mode] [owner] [group]
Example:
mkdir /storage/myDirectory
mkdir /storage/myDirectory 0755 root root -
- Creates a folder. mkdir and the target folder must be separated by only one space. Folders cannot be created recursively. - - Small and standard systems -
- chmod - - chmod permission target
Example:
chmod 0600 /storage/myFile.txt
chmod 0750 /storage/myDir -
- Modifies the permission, which must be in the 0xxx format. chmod, permission, and target must be separated by only one space. - - Small and standard systems -
- chown - - chown uid gid target
Example:
chown 900 800 /storage/myDir
chown 100 100 /storage/myFile.txt -
- Modifies the owner group. chown, uid, gid, and target must be separated by only one space. - - Small and standard systems -
- mount - - mount fileSystemType src dst flags data
Example:
mount vfat /dev/mmcblk0 /sdc rw,umask=000
mount jffs2 /dev/mtdblock3 /storage nosuid -
- Mounts devices. Every two parameters must be separated by only one space.
For details about flags, see the mountFlagMap[] array of the mountFlagMap function in base/startup/init/services/init/init_common_cmds.c. The data field is optional. -
- Small and standard systems -
- start - - start serviceName
Example:
start foundationstart -
- Starts services. serviceName must be contained in the services array. - - Small and standard systems -
- export - - export key value
Example:
export TEST /data/test -
- Sets environment variables. key and value respectively indicate the environment variable and its value. - - Small and standard systems -
- rm - - rm filename
Example:
rm /data/testfile -
- Deletes a file. filename indicates the absolute file path. - - Small and standard systems -
- rmdir - - rmdir dirname
Example:
rmdir /data/testdir -
- Deletes a directory. dirname indicates the absolute path of the directory. - - Small and standard systems -
- write - - write filename value
Example:
write /data/testfile 0 -
- Writes a file. filename and value respectively indicate the absolute file path and the string to write. - - Standard system -
- stop - - stop servicename
Example:
stop console -
- Stops a service. servicename indicates the name of the service to stop. - - Small and standard systems -
- copy - - copy oldfile newfile
Example:
copy /data/old /data/new -
- Copies a file. oldfile and newfile respectively indicate the old and new absolute file paths. - - Small and standard systems -
- reset - - reset servicename
Example:
reset console -
- Resets a service. servicename indicates the name of the service to reset. If the service has not been started, this command will start the service. If the service is running, the command will stop the service and then restart it. - - Small and standard systems -
- reboot - - reboot subsystem
Example:
reboot updater -
- Restarts the system. subsystem is optional. If it is not specified, the device enters the current system upon restarting. If it is specified, the device enters the corresponding subsystem upon restarting. For example, if you run reboot updater, the device enters the updater subsystem upon restarting. - - Small and standard systems -
- sleep - - sleep time
Example:
sleep 5 -
- Enters the sleep mode. time indicates the sleep time.
To avoid impact on services, exercise caution when running this command. -
- Small and standard systems -
- domainname - - domainname name
Example:
domainname localdomain -
- Sets the domain name. - - Small and standard systems -
- hostname - - hostname name
Example:
hostname localhost -
- Sets the host name. - - Small and standard systems -
- wait - - wait filepath
Example:
wait /data/testfile or wait /data/testfile 5 -
- Waits for commands. The waiting time must not exceed 5 seconds. - - Small and standard systems -
- setrlimit - - setrlimit resource curValue maxValue
Example:
setrlimit RLIMIT_CPU 10 100 -
- Sets resource usage restrictions.
For details, see the resource[] array of the DoSetrlimit function in base/startup/init/services/init/init_common_cmds.c. -
- Small and standard systems -
- exec - - exec Path of the executable file Parameters passed by the executable file
Example:
exec /system/bin/udevadm trigger -
- Runs an executable file. The command must not contain more than 10 parameters. - - Small and standard systems -
- syncexec - - syncexec Path of the executable file Parameters passed by the executable file
Example:
syncexec /system/bin/udevadm trigger -
- Runs an executable file synchronously. The **wait** function will be called to wait for the child process to end. The command must not contain more than 10 parameters. - - Standard system -
- mknode - - mknod name { b | c } Major Minor
Example:
mknod path b 0644 1 9 -
- Creates an index node corresponding to a directory entry and a special file. - - Standard system -
- makedev - - makedev major minor
Example:
makedev -v update -
- Creates a static device node, which is usually in the /dev directory. - - Standard system -
- symlink - - symlink target link_name
Example
symlink /proc/self/fd/0 /dev/stdin -
- Creates a symbolic link. - - Standard system -
- trigger - - trigger jobName
Example
trigger early-fs -
- Triggers a job. - - Standard system -
- insmod - - insmod [-f] [options]
Example
insmod xxx.ko -
- Loads a kernel module file. - - Standard system -
- setparam - - setparam paramname paramvalue
Example:
setparam sys.usb.config hdc -
- Sets system parameters. - - Standard system -
- load_persist_params - - load persist params
Example:
load_persist_params  -
- Loads persist parameters. There must be one and only one space after the load_persist_params command. - - Standard system -
- load_param - - load params
Example:
load_param /data/test.normal.para -
- Loads the parameters from a file to the memory. - - Standard system -
- load_access_token_id - - load_access_token_id  - - Writes the access token to the data/service/el0/access_token/nativetoken.json file. There is one and only one space after load_access_token_id. - - Standard system -
- ifup - - ifup NIC
Example:
ifup eth0 -
- Activates the specified NIC. - - Standard system -
- mount_fstab - - mount_fstab fstab.test
Example:
mount_fstab /vendor/etc/fstab.test -
- Mounts partitions based on the fstab file. - - Standard system -
- umount_fstab - - umount_fstab fstab.test
Example:
umount_fstab /vendor/etc/fstab.test -
- Unmounts partitions based on the fstab file. - - Standard system -
- restorecon - - restorecon file or dir
Example:
restorecon /file -
- Reloads the SELinux context. - - Standard system -
- stopAllServices - - stopAllServices [bool]
Example:
stopAllServices false
stopAllServices -
- Stops all services. - - Standard system -
- umount - - umount path
Example:
umount /vendor -
- Unmounts a mounted device. - - Standard system -
- sync - - sync  - - Writes data to the disk synchronously. There is only one and only one space after sync. - - Standard system -
- timer_start - - timer_start serviceName
Example:
timer_start console -
- Starts the service timer. - - Standard system -
- timer_stop - - timer_stop serviceName
Example:
timer_stop console -
- Stops the service timer. - - Standard system -
- init_global_key - - init_global_key path
Example:
init_global_key /data -
- Initializes the encryption key of the data partition file. - - Standard system -
- init_main_user - - init_main_user - - Encrypts the main user directory. - - Standard system -
- mkswap - - mkswap file
Example:
mkswap /swapfile1 -
- Creates a swap partition on a file or device. - - Standard system -
- swapon - - swapon file
Example:
swapon /swapfile1 -
- Activates the swap space. - - Standard system -
- mksandbox - - mksandbox fileName
Example:
mksandbox system -
- Creates a sandbox. - - Standard system -
- loadcfg - - loadcfg filePath
Example:
loadcfg /patch/fstab.cfg -
- Loads other .cfg files. The maximum size of the target file (only /patch/fstab.cfg supported currently) is 50 KB. Each line in the /patch/fstab.cfg file is a command. The command types and formats must comply with their respective requirements mentioned in this table. A maximum of 20 commands are allowed. - - Small system -
+ | Command| Format and Example| Description| + | -------- | -------- | -------- | + | mkdir | mkdir target folder [mode] [owner] [group]
Example:
mkdir /storage/myDirectory
mkdir /storage/myDirectory 0755 root root| Creates a folder. mkdir and the target folder must be separated by only one space.
System type: small system and standard system| + | chmod | chmod permission target
Example:
chmod 0600 /storage/myFile.txt
chmod 0750 /storage/myDir | Modifies the permission, which must be in the 0xxx format. chmod, permission, and target must be separated by only one space.
System type: small system and standard system| + | chown | chown uid gid target
Example:
chown 900 800 /storage/myDir
chown 100 100 /storage/myFile.txt | Modifies the owner group. chown, uid, gid, and target must be separated by only one space.
System type: small system and standard system| + | mount | mount fileSystemType src dst flags [data]
Example:
mount vfat /dev/mmcblk0 /sdc rw,umask=000
mount jffs2 /dev/mtdblock3 /storage nosuid | Mounts devices. Every two parameters must be separated by only one space. For details about flags, see the mountFlagMap[] function in base/startup/init/services/init/init\_common\_cmds.c. The data field is optional.
System type: small system and standard system| + | start | start serviceName
Example: start foundation| Starts services. serviceName must be contained in the services array.
System type: small system and standard system| + | export | export key value
Example:
export TEST /data/test| Sets environment variables. key and value respectively indicate the environment variable and its value.
System type: small system and standard system| + | rm | rm filename
Example:
rm /data/testfile| Deletes a file. filename indicates the absolute file path.
System type: small system and standard system| + | rmdir | rmdir dirname
Example:
rmdir /data/testdir| Deletes a directory. dirname indicates the absolute path of the directory.
System type: small system and standard system| + | write | write filename value
Example:
write /data/testfile 0| Writes a file. filename and value respectively indicate the absolute file path and the string to write.
System type: small system and standard system| + | stop | stop serviceName
Example:
stop console| Stops a service. servicenamei> indicates the name of the service to stop.
System type: small system and standard system| + | copy | copy oldfile newfile
Example:
copy /data/old /data/new| Copies a file. oldfile and newfile respectively indicate the old and new absolute file paths.
System type: small system and standard system| + | reset | reset serviceName
Example:
reset console| Resets a service. servicename indicates the name of the service to reset. If the service has not been started, this command will start the service. If the service is running, the command will stop the service and then restart it.
System type: small system and standard system| + | reboot | reboot [subsystem]
Example:
reboot updater| Restarts the system. subsystem is optional. If it is not specified, the device enters the current system upon restarting. If it is specified, the device enters the corresponding subsystem upon restarting. For example, if you run reboot updater, the device enters the updater subsystem upon restarting.
System type: small system and standard system| + | sleep | sleep time
Example:
sleep 5| Enters the sleep mode. time indicates the sleep time, which must not exceed 5 seconds.
To avoid impact on services, exercise caution when running this command.
System type: small system and standard system| + | domainname | domainname name
Example:
domainname localdomain| Sets the domain name.
System type: small system and standard system| + | hostname | hostname name
Example:
hostname localhost| Sets the host name.
System type: small system and standard system| + | wait | wait filepath [time]
Example:
wait /data/testfile or wait /data/testfile 5| Waits for commands. time indicates the waiting time, which must not exceed 5 seconds.
System type: small system and standard system| + | setrlimit | setrlimit resource curValue maxValue
Example:
setrlimit RLIMIT_CPU 10 100| Sets resource usage restrictions.
System type: small system and standard system| + | write | write path content
Example:
write /proc/sys/kernel/sysrq 0| Writes a file.
System type: small system and standard system| + | exec | exec Path of the executable file Parameters passed by the executable file
Example:
exec /system/bin/mkdir /data/test.txt| Runs an executable file. This command is called by the system.
System type: small system and standard system| + | syncexec | syncexec Path of the executable file Parameters passed by the executable file
Example:
syncexec /system/bin/udevadm trigger| Runs an executable file synchronously. The **wait** function will be called to wait for the child process to end. The command must not contain more than 10 parameters.
System type: standard system + | mknode |mknod name { b \| c } Major Minor
Example:
mknod path b 0644 1 9| Creates an index node corresponding to a directory entry and a special file.
System type: standard system| + | makedev | makedev major minor
Example:
makedev -v update| Creates a static device node, which is usually in the /dev directory.
System type: standard system| + | symlink | symlink target link_name
Example:
symlink /proc/self/fd/0 /dev/stdin| Creates a symbolic link.
System type: standard system| + | trigger | trigger jobName
Example:
trigger early-fs| Triggers a job.
System type: standard system| + | insmod | insmod [-f] [options]
Example:
insmod xxx.ko| Loads a kernel module file.
System type: standard system| + | setparam | setparam paramName paramValue
Example:
setparam sys.usb.config hdc| Sets system parameters.
System type: standard system| + | load_persist_params | load persist params
Example:
load_persist_params | Loads persist parameters. There must be one and only one space after the load_persist_params command.
System type: standard system| + | load_param | load params
Example:
load_param /data/test.normal.para| Loads the parameters from a file to the memory.
System type: standard system| + | load_access_token_id | load_access_token_id | Writes the access token to the data/service/el0/access_token/nativetoken.json file. There is one and only one space after load_access_token_id.
System type: standard system| + | ifup | ifup NIC
Example:
ifup eth0| Activates the specified NIC.
System type: standard system| + | mount_fstab | mount_fstab fstab.test
Example:
mount_fstab /vendor/etc/fstab.test| Mounts partitions based on the fstab file.
System type: standard system| + | umount_fstab | umount_fstab fstab.test
Example:
umount_fstab /vendor/etc/fstab.test| Unmounts partitions based on the fstab file.
System type: standard system| + | restorecon | restorecon file or dir
Example:
restorecon /file| Reloads the SELinux context.
System type: standard system| + | stopAllServices | stopAllServices [bool]
Example:
stopAllServices false or stopAllServices| Stops all services. The maximum response time is 10 ms by default.
System type: standard system| + | umount |umount path
Example:
umount /vendor| Unmounts a mounted device.
System type: standard system| + | sync | sync | Writes data to the disk synchronously. There is only one and only one space after sync.
System type: standard system| + | timer_start | timer_start serviceName
Example:
timer_start console| Starts the service timer.
System type: standard system| + | timer_stop | timer_stop serviceName
Example:
timer_stop console| Stops a service timer.
System type: standard system| + | init_global_key | init_global_key path
Example:
init_global_key /data| Initializes the encryption key of the data partition file.
System type: standard system| + | init_main_user | init_main_user| Encrypts the main user directory.
System type: standard system| + | mkswap | mkswap file
Example:
mkswap /swapfile1| Creates a swap partition on a file or device.
System type: standard system| + | swapon | swapon file
Example:
swapon /swapfile1| Activates the swap space.
System type: standard system| + | mksandbox | mksandbox fileName
Example:
mksandbox system| Creates a sandbox.
System type: standard system| + | loadcfg | loadcfg filePath
Example:
loadcfg /patch/fstab.cfg| Loads other .cfg files. The maximum size of the target file (only /patch/fstab.cfg supported currently) is 50 KB. Each line in the /patch/fstab.cfg file is a command. The command types and formats must comply with their respective requirements mentioned in this table. A maximum of 20 commands are allowed.
System type: small system| ### Available APIs Job management is a part of the init startup process. It is a process-based function that completely serves the init startup process. It does not provide any functional APIs for other modules. It works in a way similar to command group management and does not provide help for other types of management. The following describes the job management APIs. **Table 2** Description of job parsing APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- API - - Input Parameter - - Return Value - - Description - - Supported System Type -
- void ParseAllJobs(const cJSON *fileRoot) - - const cJSON *fileRoot - - void - - Provides the general entry for parsing jobs. - - Small and standard systems -
- static void ParseJob(const cJSON  *jobItem, Job *resJob) - - const cJSON *jobItem, Job *resJob - - void - - Checks whether a job exists and parses cmds in it. - - Small system -
- int GetCmdLinesFromJson(const cJSON *root, CmdLines **cmdLines) - - const cJSON *root, CmdLines **cmdLines - - int - - Parses cmds in the job. This API is used for the small system. It does not apply to the standard system because the trigger command and condition attribute are involved. - - Small and standard systems -
- int ParseTriggerConfig(const cJSON *fileRoot, int (*checkJobValid)(const char *jobName)) - - const cJSON *fileRoot, int (*checkJobValid)(const char *jobName) - - int - - Parses the trigger command in the job. - - Standard system -
- static int ParseTrigger_(const TriggerWorkSpace *workSpace, const cJSON *triggerItem, int (*checkJobValid)(const char *jobName)) - - const TriggerWorkSpace *workSpace, const cJSON *triggerItem, int (*checkJobValid)(const char *jobName) - - int - - Obtains the job name, condition attribute, and cmds command group. Jobs are stored in a hash table, and commands are stored in a queue structure. - - Standard system -
+| API| Function| Supported System Type| +|:--------|:-----|:------| +|void ParseAllJobs(const cJSON *fileRoot)|Provides the general entry for parsing jobs.| Small and standard systems| +|static void ParseJob(const cJSON *jobItem, Job *resJob)|Checks whether a job exists and parses cmds in it.| Small system| +|int GetCmdLinesFromJson(const cJSON *root, CmdLines **cmdLines)| Parses cmds in the job. This API is used for the small system.
It does not apply to the standard system because the trigger command and condition attribute are involved.| Small and standard systems| +|int ParseTriggerConfig(const cJSON *fileRoot,
int (*checkJobValid)(const char *jobName))|Parses the trigger command in the job.| Standard system| +|static int ParseTrigger_(const TriggerWorkSpace *workSpace,
const cJSON *triggerItem,
int (*checkJobValid)(const char *jobName))|Obtains the job name, condition attribute, and cmds command group.
Jobs are stored in a hash table, and commands are stored in a queue structure.| Standard system| **Table 3** Description of the job triggering APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- API - - Input Parameter - - Return Value - - Description - - Supported System Type -
- void PostTrigger(EventType type, const char *content, uint32_t contentLen) - - EventType type, const char *content, uint32_t contentLen - - void - - Verifies the validity of the job name and sends a job triggering event. - - Standard system -
- static void SendTriggerEvent(int type, const char *content, uint32_t contentLen) - - int type, const char *content, uint32_t contentLen - - void - - Performs functions such as system control and starting or stopping of services based on system parameters. - - Standard system -
- static void DoTriggerCmd(const struct CmdArgs *ctx) - - const struct CmdArgs *ctx - - void - - Executes the trigger command. - - Standard system -
- void DoTriggerExec(const char *triggerName) - - const char *triggerName - - void - - Finds a command group based on the job name and pushes the commands in the command group to the execution queue. This API is available only for the standard system. - - Standard system -
- void DoJob(const char *jobName) - - const char *jobName - - void - - Matches a job based on the job name and invokes DoCmdByIndex to execute the commands in the job. - - Small system -
- void DoCmdByIndex(int index, const char *cmdContent) - - int index, const char *cmdContent - - void - - Combines parameters and commands. - - Small and standard systems -
- -### Development Example +| API| Function| Supported System Type| +|:--------|:-----|:------| +|void PostTrigger(EventType type, const char *content, uint32_t contentLen)|Verifies the validity of the job name and sends a job triggering event.| Standard system| +|static void SendTriggerEvent(int type, const char *content, uint32_t contentLen)|Performs functions such as system control and starting or stopping of services based on system parameters.| Standard system| +|static void DoTriggerCmd(const struct CmdArgs *ctx)|Executes the trigger command.| Standard system| +|void DoTriggerExec(const char *triggerName)|Finds a command group based on the job name and pushes the commands in the command group to the execution queue.
This API is available only for the standard system.| Standard system| +|void DoJob(const char *jobName)|Matches a job based on the job name and invokes DoCmdByIndex
to execute the commands in the job.| Small system| +|void DoCmdByIndex(int index, const char *cmdContent)|Combines parameters and commands.| Small and standard systems| + +### Example The following is the template for configuring jobs in the .cfg file. You can use it to verify the job management function. ``` {