#define OPTVAL_GLOBAL 1000
#define OPTVAL_CLEAR_ALL 1001
+#define OPTVAL_UID 1002
static int __process_request(uid_t uid);
static void __print_usage();
{"help", 0, NULL, 'h'},
{"debug-mode", 0, NULL, 'G'},
{"getsizeinfo", 0, NULL, 'x'},
+ {"uid", 1, NULL, OPTVAL_UID},
{0, 0, 0, 0} /* sentinel */
};
int global;
int type;
int result;
+ int uid;
bool debug_mode;
};
typedef struct pm_tool_args_t pm_tool_args;
printf("-t, --package-type provide package type\n");
printf("-T, --move-type provide move type [0: move to internal / 1: move to external]\n");
printf(" --global Global Mode [Warning: user should be privilegied to use this mode]\n");
+ printf(" --uid Specify target user's id. This only affect app activation/deactivation.\n");
printf("-e, --tep-path provide TEP package path\n");
printf("-M, --tep-move decide move/copy of TEP package [0: copy TEP package / 1: move TEP package]\n");
printf("-G, --debug-mode install the package with debug mode for sdk\n");
+ printf("-D, --deactivate disable package or app\n");
+ printf("-A, --activate enable package or app\n");
printf("-h, --help print this help\n");
printf("\n");
printf("pkgcmd -k -n <pkgid>\n");
printf("pkgcmd --clear-all (-t <pkg type>)\n");
printf("pkgcmd -X <old_pkg> -Y <new_pkg> -Z <delta_pkg>\n");
+ printf("pkgcmd -D -t <pkg type> -n <pkgid> (--global) (--uid <uid>)\n");
printf("\n");
printf("Example:\n");
printf("pkgcmd -l\n");
printf("pkgcmd -l -t tpk\n");
printf("pkgcmd -g -T 0 -n org.example.hello\n");
+ printf("pkgcmd -D -t tpk -n org.example.hellopkg\n");
+ printf("pkgcmd -D -t app -n org.example.helloapp --global\n");
printf("\n");
exit(0);
int ret = -1;
pkgmgr_client *pc = NULL;
pkgmgr_client *listen_pc = NULL;
+ pkgmgrinfo_appinfo_h appinfo_h;
char buf[1024] = {'\0'};
int pid = -1;
char pkg_old[PATH_MAX] = {0, };
}
if (strcmp(data.pkg_type, "app") == 0) {
- if (data.global)
- /* enable global app for this user only */
- ret = pkgmgr_client_activate_global_app_for_uid(pc, data.pkgid,
- __app_return_cb, NULL, __get_current_user_id());
- else
- /* enable app which belongs to this user */
- ret = pkgmgr_client_usr_activate_app(pc, data.pkgid, __app_return_cb, NULL, target_uid);
+ if (data.global && data.uid != -1) {
+ if (data.uid != __get_current_user_id()) {
+ printf("Invalid uid : %d\n", data.uid);
+ ret = -1;
+ break;
+ } else {
+ target_uid = data.uid;
+ }
+ }
+ ret = pkgmgrinfo_appinfo_get_usr_disabled_appinfo(data.pkgid,
+ target_uid, &appinfo_h);
+ if (ret != PMINFO_R_OK) {
+ printf("Failed to get appinfo[%s]\n", data.pkgid);
+ ret = -1;
+ break;
+ }
+
+ if (data.global) {
+ if (data.uid != -1)
+ /* enable global app for this user only */
+ ret = pkgmgr_client_activate_global_app_for_uid(pc,
+ data.pkgid, __app_return_cb, NULL,
+ __get_current_user_id());
+ else
+ /* enable global app for all user */
+ ret = pkgmgr_client_usr_activate_app(pc, data.pkgid,
+ __app_return_cb, NULL, GLOBAL_USER);
+ } else {
+ /* enable local app */
+ ret = pkgmgr_client_usr_activate_app(pc, data.pkgid,
+ __app_return_cb, NULL, target_uid);
+ }
+
+ pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
} else {
listen_pc = pkgmgr_client_new(PC_LISTENING);
if (listen_pc == NULL) {
printf("Failed to set callback[%d]\n", ret);
break;
}
- ret = pkgmgr_client_usr_activate(pc, data.pkg_type, data.pkgid, target_uid);
+ ret = pkgmgr_client_usr_activate(pc, data.pkg_type, data.pkgid,
+ target_uid);
}
if (ret < 0)
break;
}
if (strcmp(data.pkg_type, "app") == 0) {
- if (data.global)
- /* disable global app for this user only*/
- ret = pkgmgr_client_deactivate_global_app_for_uid(pc, data.pkgid,
- __app_return_cb, NULL, __get_current_user_id());
- else
- /* disable app which belongs to this user */
- ret = pkgmgr_client_usr_deactivate_app(pc, data.pkgid, __app_return_cb, NULL, target_uid);
+ ret = pkgmgrinfo_appinfo_get_usr_appinfo(data.pkgid,
+ target_uid, &appinfo_h);
+ if (ret != PMINFO_R_OK) {
+ printf("Failed to get appinfo[%s]\n", data.pkgid);
+ ret = -1;
+ break;
+ }
+
+ if (data.global) {
+ if (data.uid != -1 && data.uid != getuid()) {
+ printf("Invalid uid : %d\n", data.uid);
+ pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
+ ret = -1;
+ break;
+ }
+ if (data.uid != -1)
+ /* disable global app for this user only */
+ ret = pkgmgr_client_deactivate_global_app_for_uid(pc,
+ data.pkgid, __app_return_cb, NULL,
+ __get_current_user_id());
+ else
+ /* disable global app for all user */
+ ret = pkgmgr_client_usr_deactivate_app(pc, data.pkgid,
+ __app_return_cb, NULL, GLOBAL_USER);
+ } else {
+ /* disable local app */
+ ret = pkgmgr_client_usr_deactivate_app(pc, data.pkgid,
+ __app_return_cb, NULL, target_uid);
+ }
+
+ pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
} else {
listen_pc = pkgmgr_client_new(PC_LISTENING);
if (listen_pc == NULL) {
printf("Failed to set callback[%d]\n", ret);
break;
}
- ret = pkgmgr_client_usr_deactivate(pc, data.pkg_type, data.pkgid, target_uid);
+ ret = pkgmgr_client_usr_deactivate(pc, data.pkg_type, data.pkgid,
+ target_uid);
}
if (ret < 0)
break;
data.global = 0; /* By default pkg_cmd will manage for the current user */
data.result = 0;
data.type = -1;
+ data.uid = -1;
while (1) {
c = getopt_long(argc, argv, short_options, long_options,
&opt_idx);
case ':': /* */
break;
+ case OPTVAL_UID: /* specify target user id */
+ data.uid = atoi(optarg);
+ break;
+
default:
break;