From: Sangyoon Jang Date: Wed, 7 Dec 2016 11:22:35 +0000 (+0900) Subject: Add debug mode request X-Git-Tag: accepted/tizen/common/20170110.085159~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd8aa934b2d84eaf1acf15ca5ee678a07e628ee2;p=platform%2Fcore%2Fappfw%2Fslp-pkgmgr.git Add debug mode request Change-Id: I39577120dfa29c360a28fb3974324012eb41f23c Signed-off-by: Sangyoon Jang --- diff --git a/client/include/package-manager.h b/client/include/package-manager.h index ef17c7e..b962425 100644 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -984,6 +984,19 @@ int pkgmgr_client_usr_get_pkg_restriction_mode(pkgmgr_client *pc, const char *pk int pkgmgr_client_set_app_label(pkgmgr_client *pc, char *appid, char *label); int pkgmgr_client_usr_set_app_label(pkgmgr_client *pc, char *appid, char *label, uid_t uid); +/** + * @brief Set debug mode + * + * This API sets debug mode value for request.\n + * + * @param[in] pc The pointer to pkgmgr_client instance + * @param[in] debug_mode indicates the request is debug mode or not + * @return 0 if success, error code(<0) if fail\n + * @retval PKGMGR_R_OK success + * @retval PKGMGR_R_EINVAL invalid argument + */ +int pkgmgr_client_set_debug_mode(pkgmgr_client *pc, bool debug_mode); + /** @} */ diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index feb8dd5..e1551f2 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -490,6 +490,8 @@ API int pkgmgr_client_usr_install(pkgmgr_client *pc, const char *pkg_type, g_variant_builder_add(builder, "s", client->tep_move ? "tep_move" : "tep_copy"); } + if (client->debug_mode) + g_variant_builder_add(builder, "s", "-G"); args = g_variant_new("as", builder); g_variant_builder_unref(builder); @@ -2162,3 +2164,17 @@ API int pkgmgr_client_set_app_label(pkgmgr_client *pc, char *appid, char *label) { return pkgmgr_client_usr_set_app_label(pc, appid, label, _getuid()); } + +API int pkgmgr_client_set_debug_mode(pkgmgr_client *pc, bool debug_mode) +{ + struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc; + + if (pc == NULL) { + ERR("invalid parameter"); + return PKGMGR_R_EINVAL; + } + + client->debug_mode = debug_mode; + + return PKGMGR_R_OK; +} diff --git a/client/src/pkgmgr_client_internal.h b/client/src/pkgmgr_client_internal.h index 4949a01..7f5766d 100644 --- a/client/src/pkgmgr_client_internal.h +++ b/client/src/pkgmgr_client_internal.h @@ -53,6 +53,7 @@ struct pkgmgr_client_t { GList *cb_info_list; char *tep_path; bool tep_move; + bool debug_mode; }; int pkgmgr_client_connection_connect(struct pkgmgr_client_t *pc); diff --git a/installer/pkgmgr_installer.c b/installer/pkgmgr_installer.c index 0e94bf8..dadd55d 100644 --- a/installer/pkgmgr_installer.c +++ b/installer/pkgmgr_installer.c @@ -60,7 +60,7 @@ #define OPTVAL_PARTIAL_RW 1005 /* Supported options */ -const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:b:e:M:y:u:w:D:A:q"; +const char *short_opts = "k:l:i:d:c:m:t:o:r:p:s:b:e:M:y:u:w:D:A:qG"; const struct option long_opts[] = { { "session-id", 1, NULL, 'k' }, { "license-path", 1, NULL, 'l' }, @@ -78,6 +78,7 @@ const struct option long_opts[] = { { "direct-manifest-install", 1, NULL, 'y' }, { "mount-install", 1, NULL, 'w' }, { "recovery", 1, NULL, 'b' }, + { "debug-mode", 0, NULL, 'G' }, { "preload", 0, NULL, OPTVAL_PRELOAD }, /* for preload RO */ { "force-remove", 0, NULL, OPTVAL_FORCE_REMOVAL }, /* for preload RO/RW */ { "preload-rw", 0, NULL, OPTVAL_PRELOAD_RW }, /* for preload RW */ @@ -105,6 +106,7 @@ struct pkgmgr_installer { int no_removal; int keep_rwdata; int partial_rw; + int debug_mode; GDBusConnection *conn; }; @@ -564,6 +566,10 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi, pi->target_uid = (uid_t)atoi(optarg); break; + case 'G': /* debug mode */ + pi->debug_mode = 1; + break; + /* Otherwise */ case '?': /* Not an option */ break; @@ -684,6 +690,12 @@ API int pkgmgr_installer_get_partial_rw(pkgmgr_installer *pi) return pi->partial_rw; } +API int pkgmgr_installer_get_debug_mode(pkgmgr_installer *pi) +{ + CHK_PI_RET(PKGMGR_REQ_INVALID); + return pi->debug_mode; +} + API int pkgmgr_installer_send_app_uninstall_signal(pkgmgr_installer *pi, const char *pkg_type, const char *pkgid, diff --git a/installer/pkgmgr_installer.h b/installer/pkgmgr_installer.h index f45cd1a..d602940 100644 --- a/installer/pkgmgr_installer.h +++ b/installer/pkgmgr_installer.h @@ -734,6 +734,41 @@ int main(int argc, char **argv) int pkgmgr_installer_get_partial_rw(pkgmgr_installer *pi); /** + @brief Get debug mode value + @pre pkgmgr_installer_receive_request() must be called. + @post None + @see pkgmgr_installer_receive_request + @param[in] pi pkgmgr_installer object + @return Operation result + @retval 0 if a request is not debug mode + @retval 1 if a request is debug mode + @remark None + @code +#include +int main(int argc, char **argv) +{ + pkgmgr_installer *pi; + int r = 0; + int force_remove = 0; + + pi = pkgmgr_installer_new(); + if(!pi) return -1; + if(pkgmgr_installer_receive_request(pi, argc, argv)) { + r = -1; + goto CLEANUP_RET; + } + force_remove = pkgmgr_installer_get_debug_mode(pi); + + // Do something... + + pkgmgr_installer_free(pi); + return r; +} + @endcode +*/ +int pkgmgr_installer_get_debug_mode(pkgmgr_installer *pi); + +/** @brief Send a app status signal @pre None @post None