if (!watchface_complication::util::CheckWatchFeatureEnabled())
return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
- if (handle == NULL) {
- LOGE("handle is null");
+ if (handle == NULL || is_editing == NULL) {
+ LOGE("Null parameter");
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
}
if (!watchface_complication::util::CheckWatchFeatureEnabled())
return WATCHFACE_COMPLICATION_ERROR_NOT_SUPPORTED;
- ret = app_control_get_extra_data(handle, SETUP_CONTEXT_DATA_KEY, &value);
+ if (handle == NULL || context == NULL) {
+ LOGE("Null parameter");
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = app_control_get_extra_data(handle, SETUP_EDITOR_APPID_KEY, &value);
if (ret != APP_CONTROL_ERROR_NONE) {
if (ret == APP_CONTROL_ERROR_OUT_OF_MEMORY) {
LOGE("Out of memory");
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
- LOGE("Fail to get context data (%d)", ret);
+ LOGE("Fail to get setup editor appid (%d)", ret);
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
}
+ free(value);
+
+ ret = app_control_get_extra_data(handle, SETUP_CONTEXT_DATA_KEY, &value);
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ if (ret == APP_CONTROL_ERROR_OUT_OF_MEMORY) {
+ LOGE("Out of memory");
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ } else if (ret == APP_CONTROL_ERROR_KEY_NOT_FOUND) {
+ *context = NULL;
+ return WATCHFACE_COMPLICATION_ERROR_NONE;
+ } else {
+ LOGE("Fail to get context data (%d)", ret);
+ return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
+ }
+ }
data = bundle_decode(reinterpret_cast<const bundle_raw*>(value),
strlen(value));
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
-static int _add_extra_data(app_control_h* service, const char* key,
+static int _add_extra_data(app_control_h service, const char* key,
const char* value) {
- int ret = app_control_add_extra_data(*service, key, value);
+ int ret = app_control_add_extra_data(service, key, value);
if (ret != APP_CONTROL_ERROR_NONE) {
if (ret == APP_CONTROL_ERROR_OUT_OF_MEMORY) {
- LOGE("Fail to get context data");
+ LOGE("Fail to add extra data - out of memory");
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
- LOGE("Fail to get context data");
+ LOGE("Fail to add extra data %d", ret);
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
}
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
LOGI("LAUNCH !!! %s", appid.c_str());
- context_data = (ed->GetContext()).get();
- app_control_set_app_id(service, appid.c_str());
+ int ret = app_control_set_app_id(service, appid.c_str());
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ LOGE("Fail to set appid");
+ app_control_destroy(service);
+ return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
+ }
- int ret = _add_extra_data(&service, SETUP_EDITOR_APPID_KEY,
+ ret = _add_extra_data(service, SETUP_EDITOR_APPID_KEY,
util::GetAppId().c_str());
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
- LOGE("Fail to add appid ");
+ LOGE("Fail to add setup appid ");
app_control_destroy(service);
return ret;
}
snprintf(ed_id, sizeof(ed_id), "%d", ed->GetEditableId());
LOGI("add ed_id %s", ed_id);
- ret = _add_extra_data(&service, SETUP_EDITABLE_ID_KEY, ed_id);
+ ret = _add_extra_data(service, SETUP_EDITABLE_ID_KEY, ed_id);
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
LOGE("Fail to add ed_id %s", ed_id);
app_control_destroy(service);
return ret;
}
- ret = _add_extra_data(&service, SETUP_CONTEXT_DATA_KEY,
- context_data == nullptr ? "" : context_data->ToString());
- if (ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
- LOGE("Fail to add setup_context_data %d", ret);
- app_control_destroy(service);
- return ret;
+ context_data = (ed->GetContext()).get();
+ if (context_data != nullptr) {
+ ret = _add_extra_data(service, SETUP_CONTEXT_DATA_KEY,
+ context_data->ToString());
+ if (ret != WATCHFACE_COMPLICATION_ERROR_NONE) {
+ LOGE("Fail to add setup_context_data %d", ret);
+ app_control_destroy(service);
+ return ret;
+ }
}
ret = app_control_send_launch_request(service, NULL, NULL);