aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.cpp')
-rw-r--r--src/app.cpp86
1 files changed, 64 insertions, 22 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 7f20825..5021c05 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -434,13 +434,36 @@ void App::stop_timer(){
}
}
-bool App::do_allocate_window_resource(unsigned req_num)
+bool App::lm_release(const struct WMAction &action)
+{
+ return true;
+}
+
+bool App::lm_layout_change(const struct WMAction &action)
+{
+ const char *msg = this->check_surface_exist(action.role.c_str());
+
+ /*
+ lm_.updateLayout(action);
+ TODO: emit syncDraw with application*/
+ if (msg)
+ {
+ HMI_SEQ_DEBUG(app_list.currentSequenceNumber(), msg);
+ //app_list.removeRequest(req_num);
+ return false;
+ }
+ this->lm_layout_change(action.role.c_str());
+ return true;
+}
+
+bool App::do_transition(unsigned req_num)
{
/*
* Check Policy
*/
- // get current trigger
+ // get current trigger
auto trigger = app_list.getRequest(req_num);
+ bool is_activate = true;
/* get new status from Policy Manager
@@ -458,28 +481,47 @@ bool App::do_allocate_window_resource(unsigned req_num)
} */
HMI_SEQ_NOTICE(req_num, "ATM, Policy manager does't exist, then set WMAction as is");
- bool ret = app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area);
-
+ if (TASK_RELEASE == trigger.task)
+ {
+ is_activate = false;
+ }
+ bool ret = app_list.setAction(req_num, trigger.appid, trigger.role, trigger.area, is_activate);
app_list.req_dump();
- /*
- lm_.updateLayout(jobj);
- TODO: emit syncDraw with application
+ if(!ret){
+ HMI_SEQ_ERROR(req_num, "Failed to set action");
+ return ret;
+ }
- client->emit_syncdraw(role); */
+ /*client->emit_syncdraw(role); */
// layer manager task
- const char *msg = this->check_surface_exist(req_num, trigger.appid.c_str());
-
- if (msg)
+ for (const auto &y : app_list.getActions(req_num))
{
- HMI_SEQ_DEBUG(req_num, msg);
- app_list.removeRequest(req_num);
- return false;
+ // do_task(y); but current we can't do this
+ if (y.visible)
+ {
+ ret = lm_layout_change(y);
+ if(!ret){
+ HMI_SEQ_ERROR(req_num, "Failed layout change: %s", y.appid.c_str());
+ app_list.removeRequest(req_num);
+ break;
+ // TODO: if transition fails, what should we do?
+ }
+ }
+ else{
+ ret = lm_release(y);
+ if (!ret)
+ {
+ HMI_SEQ_ERROR(req_num, "Failed release resource: %s", y.appid.c_str());
+ app_list.removeRequest(req_num);
+ break;
+ // TODO: if transition fails, what should we do?
+ }
+ }
}
- this->lm_layout_change(req_num, trigger.appid.c_str());
- if (ret && (msg == nullptr)) {
+ if (ret) {
this->set_timer();
} else {
//this->emit_error(request_seq, 0 /*error_num*/, "error happens"); // test
@@ -487,7 +529,7 @@ bool App::do_allocate_window_resource(unsigned req_num)
return ret;
}
-void App::lm_layout_change(unsigned req_num, const char* drawing_name)
+void App::lm_layout_change(const char* drawing_name)
{
auto const &surface_id = this->lookup_id(drawing_name);
auto layer_id = this->layers.get_layer_id(*surface_id);
@@ -632,7 +674,7 @@ void App::lm_layout_change(unsigned req_num, const char* drawing_name)
}
}
-const char* App::check_surface_exist(unsigned req_num, const char* drawing_name)
+const char* App::check_surface_exist(const char* drawing_name)
{
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id)
@@ -716,10 +758,10 @@ void App::api_activate_surface(char const *appid, char const *drawing_name, char
/*
* Do allocate tasks
*/
- bool ret = this->do_allocate_window_resource(new_req);
+ bool ret = this->do_transition(new_req);
if(!ret){
- HMI_SEQ_ERROR(new_req, "failed to do_allocate_window_resource");
+ HMI_SEQ_ERROR(new_req, "failed to do_transition");
//this->emit_error()
}
}
@@ -770,7 +812,7 @@ void App::api_deactivate_surface(char const *appid, char const *drawing_name, co
/*
* Do allocate tasks
*/
- //bool ret = this->do_allocate_window_resource(new_req);
+ //bool ret = this->do_transition(new_req);
auto const &surface_id = this->lookup_id(drawing_name);
if (!surface_id)
@@ -926,7 +968,7 @@ void App::process_request()
{
unsigned req = app_list.currentSequenceNumber();
HMI_SEQ_DEBUG(req, "Do next request");
- do_allocate_window_resource(req);
+ do_transition(req);
}
void App::api_enddraw(char const *appid, char const *drawing_name)