diff options
author | changyu-choi <changyu.choi@samsung.com> | 2020-06-04 10:50:52 +0900 |
---|---|---|
committer | changyu-choi <changyu.choi@samsung.com> | 2020-06-04 10:50:52 +0900 |
commit | 8c96aa7f80280448989f0eb9d405ae910fb55390 (patch) | |
tree | 864200c296ffe853dcf1b57b42d8343b4138358a | |
parent | 7c66c3f23d3bc53fa934701ad51b364a349c76f6 (diff) | |
download | aul-1-8c96aa7f80280448989f0eb9d405ae910fb55390.tar.gz aul-1-8c96aa7f80280448989f0eb9d405ae910fb55390.tar.bz2 aul-1-8c96aa7f80280448989f0eb9d405ae910fb55390.zip |
improve performance aul_cmd_convert_to_string
-rwxr-xr-x | src/aul_cmd.c | 464 |
1 files changed, 171 insertions, 293 deletions
diff --git a/src/aul_cmd.c b/src/aul_cmd.c index 03f4d707..024a524a 100755 --- a/src/aul_cmd.c +++ b/src/aul_cmd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,296 +23,174 @@ API const char *aul_cmd_convert_to_string(int cmd) { - switch (cmd) { - case APP_START: - return "APP_START"; - case APP_OPEN: - return "APP_OPEN"; - case APP_RESUME: - return "APP_RESUME"; - case APP_RESUME_BY_PID: - return "APP_RESUME_BY_PID"; - case APP_TERM_BY_PID: - return "APP_TERM_BY_PID"; - case APP_TERM_BY_PID_WITHOUT_RESTART: - return "APP_TERM_BY_PID_WITHOUT_RESTART"; - case APP_RESULT: - return "APP_RESULT"; - case APP_START_RES: - return "APP_START_RES"; - case APP_CANCEL: - return "APP_CANCEL"; - case APP_KILL_BY_PID: - return "APP_KILL_BY_PID"; - case APP_UPDATE_RUA_STAT: - return "APP_UPDATE_RUA_STAT"; - case APP_ADD_HISTORY: - return "APP_ADD_HISTORY"; - case APP_REMOVE_HISTORY: - return "APP_REMOVE_HISTORY"; - case APP_RUNNING_INFO: - return "APP_RUNNING_INFO"; - case APP_RUNNING_INFO_RESULT: - return "APP_RUNNING_INFO_RESULT"; - case APP_IS_RUNNING: - return "APP_IS_RUNNING"; - case APP_GET_APPID_BYPID: - return "APP_GET_APPID_BYPID"; - case APP_GET_PKGID_BYPID: - return "APP_GET_PKGID_BYPID"; - case APP_GET_INFO_OK: - return "APP_GET_INFO_OK"; - case APP_GET_INFO_ERROR: - return "APP_GET_INFO_ERROR"; - case APP_KEY_EVENT: - return "APP_KEY_EVENT"; - case APP_KEY_RESERVE: - return "APP_KEY_RESERVE"; - case APP_KEY_RELEASE: - return "APP_KEY_RELEASE"; - case APP_STATUS_UPDATE: - return "APP_STATUS_UPDATE"; - case APP_RUNNING_LIST_UPDATE: - return "APP_RUNNING_LIST_UPDATE"; - case APP_TERM_REQ_BY_PID: - return "APP_TERM_REQ_BY_PID"; - case APP_TERM_BY_PID_ASYNC: - return "APP_TERM_BY_PID_ASYNC"; - case APP_TERM_BGAPP_BY_PID: - return "APP_TERM_BGAPP_BY_PID"; - case APP_PAUSE: - return "APP_PAUSE"; - case APP_PAUSE_BY_PID: - return "APP_PAUSE_BY_PID"; - case APP_GROUP_GET_WINDOW: - return "APP_GROUP_GET_WINDOW"; - case APP_GROUP_SET_WINDOW: - return "APP_GROUP_SET_WINDOW"; - case APP_GROUP_GET_FG: - return "APP_GROUP_GET_FG"; - case APP_GROUP_GET_LEADER_PID: - return "APP_GROUP_GET_LEADER_PID"; - case APP_GROUP_GET_LEADER_PIDS: - return "APP_GROUP_GET_LEADER_PIDS"; - case APP_GROUP_GET_GROUP_PIDS: - return "APP_GROUP_GET_GROUP_PIDS"; - case APP_GROUP_GET_IDLE_PIDS: - return "APP_GROUP_GET_IDLE_PIDS"; - case APP_GROUP_LOWER: - return "APP_GROUP_LOWER"; - case APP_GROUP_CLEAR_TOP: - return "APP_GROUP_CLEAR_TOP"; - case APP_GROUP_ACTIVATE_BELOW: - return "APP_GROUP_ACTIVATE_BELOW"; - case APP_GET_STATUS: - return "APP_GET_STATUS"; - case APP_ADD_LOADER: - return "APP_ADD_LOADER"; - case APP_REMOVE_LOADER: - return "APP_REMOVE_LOADER"; - case APP_GET_PID: - return "APP_GET_PID"; - case APP_GET_DC_SOCKET_PAIR: - return "APP_GET_DC_SOCKET_PAIR"; - case APP_GET_MP_SOCKET_PAIR: - return "APP_GET_MP_SOCKET_PAIR"; - case APP_COM_CREATE: - return "APP_COM_CREATE"; - case APP_COM_JOIN: - return "APP_COM_JOIN"; - case APP_COM_SEND: - return "APP_COM_SEND"; - case APP_COM_LEAVE: - return "APP_COM_LEAVE"; - case APP_COM_MESSAGE: - return "APP_COM_MESSAGE"; - case WIDGET_ADD: - return "WIDGET_ADD"; - case WIDGET_DEL: - return "WIDGET_DEL"; - case WIDGET_LIST: - return "WIDGET_LIST"; - case WIDGET_UPDATE: - return "WIDGET_UPDATE"; - case WIDGET_COUNT: - return "WIDGET_COUNT"; - case WIDGET_GET_CONTENT: - return "WIDGET_GET_CONTENT"; - case APP_REGISTER_PID: - return "APP_REGISTER_PID"; - case APP_WAKE: - return "APP_WAKE"; - case APP_SUSPEND: - return "APP_SUSPEND"; - case AMD_RELOAD_APPINFO: - return "AMD_RELOAD_APPINFO"; - case LAUNCHPAD_DEAD_SIGNAL: - return "LAUNCHPAD_DEAD_SIGNAL"; - case APP_ALL_RUNNING_INFO: - return "APP_ALL_RUNNING_INFO"; - case APP_SET_APP_CONTROL_DEFAULT_APP: - return "APP_SET_APP_CONTROL_DEFAULT_APP"; - case APP_UNSET_APP_CONTROL_DEFAULT_APP: - return "APP_UNSET_APP_CONTROL_DEFAULT_APP"; - case APP_START_ASYNC: - return "APP_START_ASYNC"; - case APP_SET_PROCESS_GROUP: - return "APP_SET_PROCESS_GROUP"; - case APP_PREPARE_CANDIDATE_PROCESS: - return "APP_PREPARE_CANDIDATE_PROCESS"; - case APP_TERM_BY_PID_SYNC: - return "APP_TERM_BY_PID_SYNC"; - case APP_GET_STATUS_BY_APPID: - return "APP_GET_STATUS_BY_APPID"; - case APP_GET_LAST_CALLER_PID: - return "APP_GET_LAST_CALLER_PID"; - case APP_TERM_BY_PID_SYNC_WITHOUT_RESTART: - return "APP_TERM_BY_PID_SYNC_WITHOUT_RESTART"; - case APP_RESUME_BY_PID_ASYNC: - return "APP_RESUME_BY_PID_ASYNC"; - case APP_SET_ALIAS_APPID: - return "APP_SET_ALIAS_APPID"; - case APP_UNSET_ALIAS_APPID: - return "APP_UNSET_ALIAS_APPID"; - case APP_ENABLE_ALIAS_INFO: - return "APP_ENABLE_ALIAS_INFO"; - case APP_DISABLE_ALIAS_INFO: - return "APP_DISABLE_ALIAS_INFO"; - case APP_GROUP_ACTIVATE_ABOVE: - return "APP_GROUP_ACTIVATE_ABOVE"; - case ADD_APP_SCREEN: - return "ADD_APP_SCREEN"; - case REMOVE_APP_SCREEN: - return "REMOVE_APP_SCREEN"; - case APP_UPDATE_REQUESTED: - return "APP_UPDATE_REQUESTED"; - case ADD_SCREEN_VIEWER: - return "ADD_SCREEN_VIEWER"; - case REMOVE_SCREEN_VIEWER: - return "REMOVE_SCREEN_VIEWER"; - case LAUNCHPAD_LAUNCH_SIGNAL: - return "LAUNCHPAD_LAUNCH_SIGNAL"; - case APP_RUNNING_INSTANCE_INFO: - return "APP_RUNNING_INSTANCE_INFO"; - case APP_GET_INSTANCE_ID_BYPID: - return "APP_GET_INSTANCE_ID_BYPID"; - case APP_SET_CACHE: - return "APP_SET_CACHE"; - case APP_GET_APPID_FROM_CACHE: - return "APP_GET_APPID_FROM_CACHE"; - case APP_INVALIDATE_CACHE: - return "APP_INVALIDATE_CACHE"; - case APP_STARTUP_SIGNAL: - return "APP_STARTUP_SIGNAL"; - case APP_WINDOW_ATTACH: - return "APP_WINDOW_ATTACH"; - case APP_WINDOW_DETACH: - return "APP_WINDOW_DETACH"; - case APP_START_RES_ASYNC: - return "APP_START_RES_ASYNC"; - case APP_NOTIFY_EXIT: - return "APP_NOTIFY_EXIT"; - case APP_GET_APPID_BY_SURFACE_ID: - return "APP_GET_APPID_BY_SURFACE_ID"; - case APP_GET_INSTANCE_ID_BY_SURFACE_ID: - return "APP_GET_INSTANCE_ID_BY_SURFACE_ID"; - case UPDATE_SCREEN_VIEWER_STATUS: - return "UPDATE_SCREEN_VIEWER_STATUS"; - case WIDGET_RUNNING_INFO: - return "WIDGET_RUNNING_INFO"; - case JOB_STATUS_UPDATE: - return "JOB_STATUS_UPDATE"; - case WIDGET_CHANGE_STATUS: - return "WIDGET_CHANGE_STATUS"; - case RPC_PORT_PREPARE_STUB: - return "RPC_PORT_PREPARE_STUB"; - case RPC_PORT_CREATE_SOCKET_PAIR: - return "RPC_PORT_CREATE_SOCKET_PAIR"; - case RPC_PORT_NOTIFY_RPC_FINISHED: - return "RPC_PORT_NOTIFY_RPC_FINISHED"; - case COMPLICATION_UPDATE_REQUEST: - return "COMPLICATION_UPDATE_REQUEST"; - case APP_NOTIFY_START: - return "APP_NOTIFY_START"; - case WATCHDOG_ENABLE: - return "WATCHDOG_ENABLE"; - case WATCHDOG_DISABLE: - return "WATCHDOG_DISABLE"; - case WATCHDOG_PING: - return "WATCHDOG_PING"; - case WATCHDOG_KICK: - return "WATCHDOG_KICK"; - case APP_SEND_LAUNCH_REQUEST: - return "APP_SEND_LAUNCH_REQUEST"; - case APP_SEND_LAUNCH_REQUEST_SYNC: - return "APP_SEND_LAUNCH_REQUEST_SYNC"; - case COMP_NOTIFY_START: - return "COMP_NOTIFY_START"; - case COMP_NOTIFY_EXIT: - return "COMP_NOTIFY_EXIT"; - case COMP_STATUS_UPDATE: - return "COMP_STATUS_UPDATE"; - case APP_TERM_INSTANCE_ASYNC: - return "APP_TERM_INSTANCE_ASYNC"; - case APP_GROUP_SET_WINDOW_V2: - return "APP_GROUP_SET_WINDOW_V2"; - case APP_GROUP_LOWER_V2: - return "APP_GROUP_LOWER_V2"; - case APP_GROUP_GET_LEADER_IDS: - return "APP_GROUP_GET_LEADER_IDS"; - case APP_GROUP_GET_GROUP_INFO: - return "APP_GROUP_GET_GROUP_INFO"; - case APP_GROUP_GET_IDLE_INFO: - return "APP_GROUP_GET_IDLE_INFO"; - case COMP_CONTEXT_FOREACH: - return "COMP_CONTEXT_FOREACH"; - case COMP_CONTEXT_GET: - return "COMP_CONTEXT_GET"; - case COMP_CONTEXT_IS_RUNNING: - return "COMP_CONTEXT_IS_RUNNING"; - case COMP_CONTEXT_RESUME: - return "COMP_CONTEXT_RESUME"; - case COMP_CONTEXT_PAUSE: - return "COMP_CONTEXT_PAUSE"; - case COMP_CONTEXT_TERMINATE_BG_COMP: - return "COMP_CONTEXT_TERMINATE_BG_COMP"; - case COMP_CONTEXT_TERMINATE: - return "COMP_CONTEXT_TERMINATE"; - case APP_RESUME_INSTANCE: - return "APP_RESUME_INSTANCE"; - case APP_PAUSE_INSTANCE: - return "APP_PAUSE_INSTANCE"; - case APP_TERM_BG_INSTANCE: - return "APP_TERM_BG_INSTANCE"; - case LAUNCHPAD_CHILD_PROCESS: - return "LAUNCHPAD_CHILD_PROCESS"; - case COMP_INFO_GET: - return "COMP_INFO_GET"; - case COMP_INFO_FOREACH: - return "COMP_INFO_FOREACH"; - case APP_TERMINATE: - return "APP_TERMINATE"; - case APP_IS_RUNNING_V2: - return "APP_IS_RUNNING_V2"; - case ANR_NOTIFY: - return "ANR_NOTIFY"; - case APP_GET_RUNNING_CONTEXT: - return "APP_GET_RUNNING_CONTEXT"; - case LAUNCHER_SERVICE_NOTIFY_ANIMATION_STARTED: - return "LAUNCHER_SERVICE_NOTIFY_ANIMATION_STARTED"; - case LAUNCHER_SERVICE_NOTIFY_ANIMATION_FINISHED: - return "LAUNCHER_SERVICE_NOTIFY_ANIMATION_FINISHED"; - case APP_SEND_RESUME_REQUEST: - return "APP_SEND_RESUME_REQUEST"; - case APP_PREPARE_APP_DEFINED_LOADER: - return "APP_PREPARE_APP_DEFINED_LOADER"; - case WIDGET_DISABLE: - return "WIDGET_DISABLE"; - case TRIGGER_APP_SCREEN_FOCUSED_FORCE: - return "TRIGGER_APP_SCREEN_FOCUSED_FORCE"; - case WIDGET_EVENT: - return "WIDGET_EVENT"; - default: - return "CUSTOM_COMMAND"; - } + static const char *cmd_string_table[APP_CMD_MAX + 1] = { + "APP_START", + /* 1 */ + "APP_OPEN", + "APP_RESUME", + "APP_RESUME_BY_PID", + "APP_TERM_BY_PID", + "APP_TERM_BY_PID_WITHOUT_RESTART", + "APP_RESULT", + "APP_START_RES", + "APP_CANCEL", + "APP_KILL_BY_PID", + "APP_UPDATE_RUA_STAT", + /* 11 */ + "APP_ADD_HISTORY", + "APP_REMOVE_HISTORY", + "APP_RUNNING_INFO", + "APP_RUNNING_INFO_RESULT", + "APP_IS_RUNNING", + "APP_GET_APPID_BYPID", + "APP_GET_PKGID_BYPID", + "APP_GET_INFO_OK", + "APP_GET_INFO_ERROR", + "APP_KEY_EVENT", + /* 21 */ + "APP_KEY_RESERVE", + "APP_KEY_RELEASE", + "APP_STATUS_UPDATE", + "APP_RUNNING_LIST_UPDATE", + "APP_TERM_REQ_BY_PID", + "APP_TERM_BY_PID_ASYNC", + "APP_TERM_BGAPP_BY_PID", + "APP_PAUSE", + "APP_PAUSE_BY_PID", + "APP_GROUP_GET_WINDOW", + /* 31 */ + "APP_GROUP_SET_WINDOW", + "APP_GROUP_GET_FG", + "APP_GROUP_GET_LEADER_PID", + "APP_GROUP_GET_LEADER_PIDS", + "APP_GROUP_GET_GROUP_PIDS", + "APP_GROUP_GET_IDLE_PIDS", + "APP_GROUP_LOWER", + "APP_GROUP_CLEAR_TOP", + "APP_GROUP_ACTIVATE_BELOW", + "APP_GET_STATUS", + /* 41 */ + "APP_ADD_LOADER", + "APP_REMOVE_LOADER", + "APP_GET_PID", + "APP_GET_DC_SOCKET_PAIR", + "APP_GET_MP_SOCKET_PAIR", + "APP_COM_CREATE", + "APP_COM_JOIN", + "APP_COM_SEND", + "APP_COM_LEAVE", + "APP_COM_MESSAGE", + /* 51 */ + "WIDGET_ADD", + "WIDGET_DEL", + "WIDGET_LIST", + "WIDGET_UPDATE", + "WIDGET_COUNT", + "WIDGET_GET_CONTENT", + "APP_REGISTER_PID", + "APP_WAKE", + "APP_SUSPEND", + "AMD_RELOAD_APPINFO", + /* 61 */ + "LAUNCHPAD_DEAD_SIGNAL", + "APP_ALL_RUNNING_INFO", + "APP_SET_APP_CONTROL_DEFAULT_APP", + "APP_UNSET_APP_CONTROL_DEFAULT_APP", + "APP_START_ASYNC", + "APP_SET_PROCESS_GROUP", + "APP_PREPARE_CANDIDATE_PROCESS", + "APP_TERM_BY_PID_SYNC", + "APP_GET_STATUS_BY_APPID", + "APP_GET_LAST_CALLER_PID", + /* 71 */ + "APP_TERM_BY_PID_SYNC_WITHOUT_RESTART", + "APP_RESUME_BY_PID_ASYNC", + "APP_SET_ALIAS_APPID", + "APP_UNSET_ALIAS_APPID", + "APP_ENABLE_ALIAS_INFO", + "APP_DISABLE_ALIAS_INFO", + "APP_GROUP_ACTIVATE_ABOVE", + "ADD_APP_SCREEN", + "REMOVE_APP_SCREEN", + "APP_UPDATE_REQUESTED", + /* 81 */ + "ADD_SCREEN_VIEWER", + "REMOVE_SCREEN_VIEWER", + "LAUNCHPAD_LAUNCH_SIGNAL", + "APP_RUNNING_INSTANCE_INFO", + "APP_GET_INSTANCE_ID_BYPID", + "APP_SET_CACHE", + "APP_GET_APPID_FROM_CACHE", + "APP_INVALIDATE_CACHE", + "APP_STARTUP_SIGNAL", + "APP_WINDOW_ATTACH", + /* 91 */ + "APP_WINDOW_DETACH", + "APP_START_RES_ASYNC", + "APP_NOTIFY_EXIT", + "APP_GET_APPID_BY_SURFACE_ID", + "APP_GET_INSTANCE_ID_BY_SURFACE_ID", + "UPDATE_SCREEN_VIEWER_STATUS", + "WIDGET_RUNNING_INFO", + "JOB_STATUS_UPDATE", + "WIDGET_CHANGE_STATUS", + "RPC_PORT_PREPARE_STUB", + /* 101 */ + "RPC_PORT_CREATE_SOCKET_PAIR", + "RPC_PORT_NOTIFY_RPC_FINISHED", + "COMPLICATION_UPDATE_REQUEST", + "APP_NOTIFY_START", + "WATCHDOG_ENABLE", + "WATCHDOG_DISABLE", + "WATCHDOG_PING", + "WATCHDOG_KICK", + "APP_SEND_LAUNCH_REQUEST", + "APP_SEND_LAUNCH_REQUEST_SYNC", + /* 111 */ + "COMP_NOTIFY_START", + "COMP_NOTIFY_EXIT", + "COMP_STATUS_UPDATE", + "APP_TERM_INSTANCE_ASYNC", + "APP_GROUP_SET_WINDOW_V2", + "APP_GROUP_LOWER_V2", + "APP_GROUP_GET_LEADER_IDS", + "APP_GROUP_GET_GROUP_INFO", + "APP_GROUP_GET_IDLE_INFO", + "COMP_CONTEXT_FOREACH", + /* 121 */ + "COMP_CONTEXT_GET", + "COMP_CONTEXT_IS_RUNNING", + "COMP_CONTEXT_RESUME", + "COMP_CONTEXT_PAUSE", + "COMP_CONTEXT_TERMINATE_BG_COMP", + "COMP_CONTEXT_TERMINATE", + "APP_RESUME_INSTANCE", + "APP_PAUSE_INSTANCE", + "APP_TERM_BG_INSTANCE", + "LAUNCHPAD_CHILD_PROCESS", + /* 131 */ + "COMP_INFO_GET", + "COMP_INFO_FOREACH", + "APP_TERMINATE", + "APP_IS_RUNNING_V2", + "ANR_NOTIFY", + "APP_GET_RUNNING_CONTEXT", + "LAUNCHER_SERVICE_NOTIFY_ANIMATION_STARTED", + "LAUNCHER_SERVICE_NOTIFY_ANIMATION_FINISHED", + "APP_SEND_RESUME_REQUEST", + "APP_PREPARE_APP_DEFINED_LOADER", + /* 141 */ + "WIDGET_DISABLE", + "TRIGGER_APP_SCREEN_FOCUSED_FORCE", + "WIDGET_EVENT", + "SET_PRIVATE_SHARING", + "UNSET_PRIVATE_SHARING", + + "CUSTOM_COMMAND" + }; + + if (cmd < 0 || cmd >= APP_CMD_MAX) + return cmd_string_table[APP_CMD_MAX]; + + return cmd_string_table[cmd]; } |