const char *widget_id;
widget_t *widget;
char *error_desc;
+ int cnt;
if (!kb) {
LOGE("invalid argument");
goto error;
}
- instance_id = bundle_get_val(kb, AUL_K_WIDGET_INSTANCE_ID);
- if (!instance_id) {
- LOGE("widget instance is NULL");
- error_desc = "instance id";
- goto error;
- }
-
command = bundle_get_val(kb, AUL_K_WIDGET_OPERATION);
if (!command) {
LOGE("widget command is NULL");
if (strcmp(command, "create") == 0)
return 0;
+ instance_id = bundle_get_val(kb, AUL_K_WIDGET_INSTANCE_ID);
+ if (instance_id == NULL) {
+ /*
+ Only the update command allows NULL instance ID.
+ Null instance ID means update all running instances.
+ */
+ if (strcmp(command, "update") == 0) {
+ cnt = __widget_count(widget_id,
+ amd_request_get_uid(req));
+ if (cnt == 0) {
+ LOGE("invalid update: %s - no running instance",
+ widget_id);
+ error_desc = "invalid command";
+ goto error;
+ }
+ return 0;
+ }
+ LOGE("widget instance is NULL");
+ error_desc = "instance id";
+ goto error;
+ }
+
widget = __find_instance(widget_id, instance_id);
if (!widget) {
LOGE("invalid command: %s - target instance %s is not exist",