5 Upgrading App to System Permission
Calling system-related APIs, such as power.reboot('reboot_test'), requires system permissions. The information is relatively scattered, and you may even encounter some issues. The following are the steps to configure system permissions.
To upgrade an APP to system permission, two locations need to be modified: one is adding requestPermissions in DevEco Studio, and the other is configuring it as system in the OpenHarmony sdk. The following uses the reboot interface power.reboot('reboot_test'); as an example.
A. Use the interface in DevEco Studio related business code:
try {
console.info('onPageShow reboot start.')
// @ts-ignore
power.reboot('reboot_test')
} catch (err) {
console.error('reboot failed, err: ' + err)
}B. Add permission ohos.permission.REBOOT in module.json5:
"module": {
-----
"requestPermissions":[
{
"name" : "ohos.permission.REBOOT"
}
]
----
}C. Modify the UnsgnedReleasedProfileTemplate.json file in OpenHarmony sdk. The file address here is:
D:\SDKs\OpenHarmony\sdk\10\toolchains\libModify "bundle-name" to the application package name, and apl to "system_core":
"bundle-name":"com.smdt.ostools.agingtest",
"apl":"system_core",
"app-feature":"hos_system_app"D. Regenerate the key: DevEco Studio-->Project Structure -> project -> Signing Configs. Note here that you need to uncheck Support HarmonyOS, enter the related folder, check the modification time of the newly generated key to confirm whether it was regenerated. If not regenerated, first delete the old key, then regenerate.

F. Run the APP. If the installation is successful and "reboot failed, err" is not printed, the reboot is successful, and the System permission upgrade is complete.
G. System Signature

Find the file in the sdk directory as shown above and modify it as follows:

