va_end(va_args);
}
+static void _activity_reply (int reply, json_object *msg_j) {
+ AGL_DEBUG("REPLY:reply=%d", reply);
+ AGL_DEBUG("REPLY:json %s", json_object_to_json_string(msg_j));
+}
+
void RunXDG::notify_ivi_control_cb (ilmObjectType object, t_ilm_uint id,
t_ilm_bool created)
{
m_launcher->register_surfpid(surf_pid);
if (m_launcher->m_rid &&
surf_pid == m_launcher->find_surfpid_by_rid(m_launcher->m_rid)) {
- setup_surface(id);
+ m_ivi_id = id;
+ setup_surface();
}
m_surfaces[surf_pid] = id;
} else if (object == ILM_LAYER) {
else
AGL_DEBUG("ivi layer: %d destroyed.", id);
}
+
+ //static std::function<int(int)> reply = _reply;
+ AGL_DEBUG("REPLY: %p, %p", _activity_reply, &_activity_reply);
+ int ret;
+ ret = this->m_lc->getActivityStatus("hvac", &_activity_reply);
+ if (!ret) {
+ AGL_DEBUG("Success!! maybe reply late!!!");
+ } else {
+ AGL_DEBUG("Error!! getActivityStatus(hvac)");
+ }
+#if 0
+ {
+ //Test for AGL LifeCycle Management
+ const char* state;
+ int ret;
+ ret = this->m_wm->getActivityStatus("hvac", &state);
+ if (ret == 0) {
+ AGL_DEBUG("Check HVAC state (%s)", state);
+ } else {
+ AGL_DEBUG("Error!! getActivityStatus(hvac)");
+ }
+ ret = this->m_wm->getActivityStatus("dashboard", &state);
+ if (ret == 0) {
+ AGL_DEBUG("Check Dashboard state (%s)", state);
+ } else {
+ AGL_DEBUG("Error!! getActivityStatus(dashboard)");
+ }
+ ret = this->m_wm->getActivityStatus("mediaplayer", &state);
+ if (ret == 0) {
+ AGL_DEBUG("Check MediaPlayer state (%s)", state);
+ } else {
+ AGL_DEBUG("Error!! getActivityStatus(mediaplayer)");
+ }
+ ret = this->m_wm->getActivityStatus("setting", &state);
+ if (ret == 0) {
+ AGL_DEBUG("Check Settting state (%s)", state);
+ } else {
+ AGL_DEBUG("Error!! getActivityStatus(setting)");
+ }
+ }
+#endif
}
void RunXDG::notify_ivi_control_cb_static (ilmObjectType object, t_ilm_uint id,
return -1;
}
- std::function< void(json_object*) > h_active = [](json_object* object) {
+ std::function< void(json_object*) > h_active = [this](json_object* object) {
AGL_DEBUG("Got Event_Active");
+ t_ilm_surface s_ids[1] = { this->m_ivi_id };
+ ilm_setInputFocus(s_ids, 1, ILM_INPUT_DEVICE_KEYBOARD, ILM_TRUE);
};
- std::function< void(json_object*) > h_inactive = [](json_object* object) {
+ std::function< void(json_object*) > h_inactive = [this](json_object* object) {
AGL_DEBUG("Got Event_Inactive");
+ t_ilm_surface s_ids[1] = { this->m_ivi_id };
+ ilm_setInputFocus(s_ids, 1, ILM_INPUT_DEVICE_KEYBOARD, ILM_FALSE);
};
std::function< void(json_object*) > h_visible = [](json_object* object) {
m_wm->set_event_handler(LibWindowmanager::Event_SyncDraw, h_syncdraw);
m_wm->set_event_handler(LibWindowmanager::Event_FlushDraw, h_flushdraw);
+ // Test code of lifecycle
+ // Register lifecycle observer for 'HVAC' & 'Dashboard'
+ this->m_lc->registerActivityObserver("hvac");
+ this->m_lc->registerActivityObserver("dashboard");
+
+ std::function< void(json_object*) > h_statusChanged =
+ [this](json_object* object)
+ {
+ json_object* j_state;
+ json_object* j_target;
+ if (!json_object_object_get_ex(object, "state", &j_state) ||
+ !json_object_object_get_ex(object, "target", &j_target)) {
+ AGL_DEBUG("Get Event_StatusChanged but invalid");
+ } else {
+ const char *state = json_object_get_string(j_state);
+ const char *target = json_object_get_string(j_target);
+ AGL_DEBUG("Get Event_StatusChanged(%s, %s)", state, target);
+ }
+ };
+
+ m_lc->set_event_handler(h_statusChanged);
return 0;
}
// Setup ilmController API
m_ic = new ILMControl(notify_ivi_control_cb_static, this);
+ m_lc = new LifeCycleObserver;
+
AGL_DEBUG("RunXDG created.");
}
-void RunXDG::setup_surface (int id)
+void RunXDG::setup_surface (void)
{
- std::string sid = std::to_string(id);
+ std::string sid = std::to_string(m_ivi_id);
// This surface is mine, register pair app_name and ivi id.
- AGL_DEBUG("requestSurfaceXDG(%s,%d)", m_role.c_str(), id);
- m_wm->requestSurfaceXDG(this->m_role.c_str(), id);
+ AGL_DEBUG("requestSurfaceXDG(%s,%d)", m_role.c_str(), m_ivi_id);
+ m_wm->requestSurfaceXDG(this->m_role.c_str(), (unsigned int)m_ivi_id);
if (m_pending_create) {
// Recovering 1st time tap_shortcut is dropped because
AGL_DEBUG("waiting for notification: surafce created");
m_pending_create = true;
+ ilm_commitChanges();
+
// in case, target app has already run
if (m_launcher->m_rid) {
pid_t surf_pid = m_launcher->find_surfpid_by_rid(m_launcher->m_rid);
int id = itr->second;
AGL_DEBUG("surface %d for <%s> already exists", id,
m_role.c_str());
- setup_surface(id);
+ m_ivi_id = id;
+ setup_surface();
}
}
}
+
+ ilm_commitChanges();
m_launcher->loop(e_flag);
}