result.period,
InternalData_(result)
);
- } else {
+ } else if ('AlarmAbsolute' === result.type) {
var date = new Date(
result.year,
result.month,
);
alarm = new tizen.AlarmAbsolute(date, result.second, InternalData_(result));
+ } else {
+ alarm = new Alarm(InternalData_(result));
}
_warningLogs.allow();
return alarm;
data.forEach(function(i) {
if ('AlarmRelative' === i.type) {
md.push(new tizen.AlarmRelative(i.delay, i.period, InternalData_(i)));
- } else {
+ } else if ('AlarmAbsolute' === i.type) {
var date = new Date(i.year, i.month, i.day, i.hour, i.min, i.sec);
md.push(new tizen.AlarmAbsolute(date, i.second, InternalData_(i)));
+ } else {
+ md.push(new Alarm(InternalData_(i)));
}
});
_warningLogs.allow();
const char* kAlarmTypeValueRelative = "RELATIVE";
const char* kAlarmRelativeDelayKey = "RELATIVE_DELAY";
-}
+} // namespace
AlarmManager::AlarmManager() {
ScopeLogger();
}
}
+ obj.insert(std::make_pair("id", picojson::value(std::to_string(id))));
+
ret = app_control_get_extra_data(app_control, kAlarmKeyType, &alarm_type);
if (APP_CONTROL_ERROR_NONE != ret) {
- return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Unknown error occurred.",
- ("Getting data failed: %d (%s)", ret, get_error_message(ret)));
+ // This is not always an error.
+ // Sometimes an application adds an alarm without alarm type set in appcontrol's extra data
+ // (possibly, when the alarm is set by a C service app, which doesn't set this value in extra
+ // data). In such cases, we return the alarm as an "Alarm" JS object, having only ID
+ LoggerW("Getting extra data (%s) failed: [%d](%s)", kAlarmKeyType, ret, get_error_message(ret));
+ return PlatformResult(ErrorCode::NO_ERROR);
}
- obj.insert(std::make_pair("id", picojson::value(std::to_string(id))));
-
if (!strcmp(alarm_type, kAlarmTypeValueAbsolute)) {
struct tm date;
memset(&date, 0, sizeof(tm));