diff --git a/services/include/param/init_param.h b/services/include/param/init_param.h index 4f0bb4181b970ba964a1a431cdcaa216b6485831..f280086dc503bf037a3c69932c5e6a07d7ab2974 100644 --- a/services/include/param/init_param.h +++ b/services/include/param/init_param.h @@ -36,8 +36,6 @@ extern "C" { #define PARAM_NAME_LEN_MAX 96 #endif -typedef uint32_t ParamHandle; - typedef enum { PARAM_CODE_ERROR = -1, PARAM_CODE_SUCCESS = 0, @@ -166,21 +164,6 @@ int SystemSetParameter(const char *name, const char *value); */ #define SystemGetParameter SystemReadParam -/** - * 对外接口 - * 查询参数,主要用于其他进程使用,找到对应属性的handle。 - * - */ -int SystemFindParameter(const char *name, ParamHandle *handle); - -/** - * 对外接口 - * 根据handle获取对应数据的修改标识。 - * commitId 获取计数变化 - * - */ -int SystemGetParameterCommitId(ParamHandle handle, uint32_t *commitId); - /** * 外部接口 * 遍历参数。 @@ -198,13 +181,6 @@ int SystemTraversalParameter(const char *prefix, */ int SystemGetParameterName(ParamHandle handle, char *name, unsigned int len); -/** - * 外部接口 - * 获取参数值。 - * - */ -int SystemGetParameterValue(ParamHandle handle, char *value, unsigned int *len); - /** * 外部接口 * 等待某个参数值被修改,阻塞直到参数值被修改或超时 @@ -216,7 +192,6 @@ typedef void (*ParameterChangePtr)(const char *key, const char *value, void *con int SystemWatchParameter(const char *keyprefix, ParameterChangePtr change, void *context); int SystemCheckParamExist(const char *name); -long long GetSystemCommitId(void); void SystemDumpParameters(int verbose, int (*dump)(const char *fmt, ...)); diff --git a/services/include/param/sys_param.h b/services/include/param/sys_param.h index c68aaeb8956068bd7dbd0d8528ff1d2d84c2bad6..505cd2bebc36b113532e96bc9cdc822d115dcb93 100644 --- a/services/include/param/sys_param.h +++ b/services/include/param/sys_param.h @@ -23,6 +23,8 @@ extern "C" { #endif #endif +typedef uint32_t ParamHandle; + typedef struct { uint8_t updaterMode; void (*logFunc)(int logLevel, uint32_t domain, const char *tag, const char *fmt, va_list vargs); @@ -45,6 +47,31 @@ int SystemReadParam(const char *name, char *value, uint32_t *len); * parameter client初始化接口 供服务调用 */ void InitParameterClient(void); + +/** + * 对外接口 + * 查询参数,主要用于其他进程使用,找到对应属性的handle。 + * + */ +int SystemFindParameter(const char *name, ParamHandle *handle); + +/** + * 对外接口 + * 根据handle获取对应数据的修改标识。 + * commitId 获取计数变化 + * + */ +int SystemGetParameterCommitId(ParamHandle handle, uint32_t *commitId); + +/** + * 外部接口 + * 获取参数值。 + * + */ +int SystemGetParameterValue(ParamHandle handle, char *value, unsigned int *len); + +long long GetSystemCommitId(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/services/modules/reboot/reboot.c b/services/modules/reboot/reboot.c index 61e567e5fb191449762fe9c6ae24b32ba92fe9a5..49939c4f71e8302d146029d60dd2afe39669101f 100644 --- a/services/modules/reboot/reboot.c +++ b/services/modules/reboot/reboot.c @@ -12,7 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include +#include #include +#include #include "reboot_adp.h" #include "init_cmdexecutor.h" @@ -103,11 +107,23 @@ static int DoRebootSuspend(int id, const char *name, int argc, const char **argv return DoRoot_("suspend", RB_AUTOBOOT); } +static int DoRebootOther(int id, const char *name, int argc, const char **argv) +{ + UNUSED(id); + UNUSED(name); + PLUGIN_CHECK(argc >= 1, return -1, "Invalid parameter argc %d", argc); + const char *cmd = strstr(argv[0], "reboot,"); + PLUGIN_CHECK(cmd != NULL, return -1, "Invalid parameter argc %s", argv[0]); + PLUGIN_LOGI("DoRebootOther argv %s", argv[0]); + return syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, cmd + strlen("reboot,")); +} + static void RebootAdpInit(void) { // sample {"reboot,shutdown", "reboot.shutdown", "reboot.shutdown"}, // add default reboot cmd (void)AddCmdExecutor("reboot", DoReboot); + (void)AddCmdExecutor("reboot.other", DoRebootOther); AddRebootCmdExecutor("shutdown", DoRebootShutdown); AddRebootCmdExecutor("flashd", DoRebootFlashed); AddRebootCmdExecutor("updater", DoRebootUpdater); diff --git a/services/param/base/param_base.c b/services/param/base/param_base.c index 4c828f385cf125bf0acf6bdd49dc48330f73594e..9db6183671dc4a88855ca117365dab9419557213 100644 --- a/services/param/base/param_base.c +++ b/services/param/base/param_base.c @@ -293,3 +293,40 @@ INIT_LOCAL_API int AddWorkSpace(const char *name, int onlyRead, uint32_t spaceSi PARAM_LOGV("AddWorkSpace %s %s", name, ret == 0 ? "success" : "fail"); return ret; } + +int SystemFindParameter(const char *name, ParamHandle *handle) +{ + PARAM_CHECK(name != NULL && handle != NULL, return -1, "The name or handle is null"); + int ret = ReadParamWithCheck(name, DAC_READ, handle); + if (ret != PARAM_CODE_NOT_FOUND && ret != 0 && ret != PARAM_CODE_NODE_EXIST) { + PARAM_CHECK(ret == 0, return ret, "Forbid to access parameter %s", name); + } + return ret; +} + +int SystemGetParameterCommitId(ParamHandle handle, uint32_t *commitId) +{ + PARAM_CHECK(handle != 0 && commitId != NULL, return -1, "The handle is null"); + + ParamNode *entry = (ParamNode *)GetTrieNodeByHandle(handle); + if (entry == NULL) { + return PARAM_CODE_NOT_FOUND; + } + *commitId = ReadCommitId(entry); + return 0; +} + +long long GetSystemCommitId(void) +{ + WorkSpace *space = GetWorkSpace(WORKSPACE_NAME_DAC); + if (space == NULL || space->area == NULL) { + return 0; + } + return ATOMIC_LOAD_EXPLICIT(&space->area->commitId, memory_order_acquire); +} + +int SystemGetParameterValue(ParamHandle handle, char *value, unsigned int *len) +{ + PARAM_CHECK(len != NULL && handle != 0, return -1, "The value is null"); + return ReadParamValue(handle, value, len); +} \ No newline at end of file diff --git a/services/param/linux/param_request.c b/services/param/linux/param_request.c index 4bc08b286ba9a7b4d01bdaa7f747d172ea71fb6e..a87683962069cd26cf3cd9ca94be2a1d19f1cf1a 100644 --- a/services/param/linux/param_request.c +++ b/services/param/linux/param_request.c @@ -246,16 +246,6 @@ int SystemCheckParamExist(const char *name) return SysCheckParamExist(name); } -int SystemFindParameter(const char *name, ParamHandle *handle) -{ - PARAM_CHECK(name != NULL && handle != NULL, return -1, "The name or handle is null"); - int ret = ReadParamWithCheck(name, DAC_READ, handle); - if (ret != PARAM_CODE_NOT_FOUND && ret != 0 && ret != PARAM_CODE_NODE_EXIST) { - PARAM_CHECK(ret == 0, return ret, "Forbid to access parameter %s", name); - } - return ret; -} - int WatchParamCheck(const char *keyprefix) { PARAM_CHECK(keyprefix != NULL, return PARAM_CODE_INVALID_PARAM, "Invalid keyprefix"); diff --git a/services/param/liteos/param_client.c b/services/param/liteos/param_client.c index 70fe5d4ccb18278d9186870a4452765f1cb417bb..5743c46c6e2d35b2693c251128e68145443d4531 100644 --- a/services/param/liteos/param_client.c +++ b/services/param/liteos/param_client.c @@ -124,13 +124,3 @@ int SystemCheckParamExist(const char *name) { return SysCheckParamExist(name); } - -int SystemFindParameter(const char *name, ParamHandle *handle) -{ - PARAM_CHECK(name != NULL && handle != NULL, return -1, "The name or handle is null"); - int ret = ReadParamWithCheck(name, DAC_READ, handle); - if (ret != PARAM_CODE_NOT_FOUND && ret != 0 && ret != PARAM_CODE_NODE_EXIST) { - PARAM_CHECK(ret == 0, return ret, "Forbid to access parameter %s", name); - } - return ret; -} diff --git a/services/param/manager/param_manager.c b/services/param/manager/param_manager.c index 8ebdbf76eaa04f76f7bc4380788088f1e7db5a6c..bd765eb45ef4b4026449ba918ef7ffca8c626148 100644 --- a/services/param/manager/param_manager.c +++ b/services/param/manager/param_manager.c @@ -299,7 +299,7 @@ static int GetServiceCtrlInfoForPowerCtrl(const char *name, const char *value, S } // not found reboot, so reboot by normal valueOffset = strlen(OHOS_SERVICE_CTRL_PREFIX) + strlen("reboot") + 1; - return CreateCtrlInfo(ctrlInfo, "reboot", valueOffset, 1, "%s%s.%s", OHOS_SERVICE_CTRL_PREFIX, "reboot", value); + return CreateCtrlInfo(ctrlInfo, "reboot.other", valueOffset, 1, "%s%s.%s", OHOS_SERVICE_CTRL_PREFIX, "reboot", value); } INIT_LOCAL_API int GetServiceCtrlInfo(const char *name, const char *value, ServiceCtrlInfo **ctrlInfo) @@ -376,35 +376,8 @@ INIT_LOCAL_API int CheckParameterSet(const char *name, return ret; } -int SystemGetParameterCommitId(ParamHandle handle, uint32_t *commitId) -{ - PARAM_CHECK(handle != 0 && commitId != NULL, return -1, "The handle is null"); - - ParamNode *entry = (ParamNode *)GetTrieNodeByHandle(handle); - if (entry == NULL) { - return PARAM_CODE_NOT_FOUND; - } - *commitId = ReadCommitId(entry); - return 0; -} - -long long GetSystemCommitId(void) -{ - WorkSpace *space = GetWorkSpace(WORKSPACE_NAME_DAC); - if (space == NULL || space->area == NULL) { - return 0; - } - return ATOMIC_LOAD_EXPLICIT(&space->area->commitId, memory_order_acquire); -} - int SystemGetParameterName(ParamHandle handle, char *name, unsigned int len) { PARAM_CHECK(name != NULL && handle != 0, return -1, "The name is null"); return ReadParamName(handle, name, len); } - -int SystemGetParameterValue(ParamHandle handle, char *value, unsigned int *len) -{ - PARAM_CHECK(len != NULL && handle != 0, return -1, "The value is null"); - return ReadParamValue(handle, value, len); -} \ No newline at end of file