summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-07-27 10:02:47 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-07-27 17:25:47 +0900
commit3d1703f9a5c9d6a356b561ea7528c70a1dc4fe2d (patch)
treebb914429501b6caf6b1b95092b6dd656ffc4adbe
parent7ee936736ec753346d8a1811a3c9c014d4be8b41 (diff)
Fix crashed application can re-launch
WM can't reset the state when application crashes, after the below commit. This patch fix the crashed application can re-launch. Related commit: https://gerrit.automotivelinux.org/gerrit/#/c/14871/ Bug-AGL: SPEC-1471 Change-Id: I46019b30cc8e9a341b4b681a0288f053b3ac1b30 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/main.cpp59
-rw-r--r--src/wayland_ivi_wm.cpp105
-rw-r--r--src/wayland_ivi_wm.hpp26
-rw-r--r--src/window_manager.cpp4
-rw-r--r--src/window_manager.hpp16
5 files changed, 98 insertions, 112 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6521c6c..b5659e2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -176,12 +176,6 @@ int binding_init() noexcept
return -1;
}
-static bool checkFirstReq(afb_req req)
-{
- WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
- return (ctxt) ? false : true;
-}
-
static void cbRemoveClientCtxt(void *data)
{
WMClientCtxt *ctxt = (WMClientCtxt *)data;
@@ -217,6 +211,20 @@ static void cbRemoveClientCtxt(void *data)
delete ctxt;
}
+static void createSecurityContext(afb_req req, const char* appid, const char* role)
+{
+ WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
+ if (!ctxt)
+ {
+ // Create Security Context at first time
+ const char *new_role = g_afb_instance->wmgr.convertRoleOldToNew(role);
+ WMClientCtxt *ctxt = new WMClientCtxt(appid, new_role);
+ HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str());
+ afb_req_session_set_LOA(req, 1);
+ afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
+ }
+}
+
void windowmanager_requestsurface(afb_req req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
@@ -238,41 +246,17 @@ void windowmanager_requestsurface(afb_req req) noexcept
return;
}
- /* Create Security Context */
- bool isFirstReq = checkFirstReq(req);
- if (!isFirstReq)
- {
- WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
- HMI_DEBUG("wm", "You're %s.", ctxt->name.c_str());
- if (ctxt->name != std::string(a_drawing_name))
- {
- afb_req_fail_f(req, "failed", "Dont request with other name: %s for now", a_drawing_name);
- HMI_DEBUG("wm", "Don't request with other name: %s for now", a_drawing_name);
- return;
- }
- }
-
+ const char *appid = afb_req_get_application_id(req);
auto ret = g_afb_instance->wmgr.api_request_surface(
- afb_req_get_application_id(req), a_drawing_name);
-
- if (isFirstReq)
- {
- WMClientCtxt *ctxt = new WMClientCtxt(afb_req_get_application_id(req), a_drawing_name);
- HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str());
- afb_req_session_set_LOA(req, 1);
- afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
- }
- else
- {
- HMI_DEBUG("wm", "session already created for %s", a_drawing_name);
- }
-
+ appid, a_drawing_name);
if (ret.is_err())
{
afb_req_fail(req, "failed", ret.unwrap_err());
return;
}
+ createSecurityContext(req, appid, a_drawing_name);
+
afb_req_success(req, json_object_new_int(ret.unwrap()), "success");
}
catch (std::exception &e)
@@ -313,15 +297,18 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept
return;
}
char const *a_ivi_id = json_object_get_string(j_ivi_id);
-
+ char const *appid = afb_req_get_application_id(req);
auto ret = g_afb_instance->wmgr.api_request_surface(
- afb_req_get_application_id(req), a_drawing_name, a_ivi_id);
+ appid, a_drawing_name, a_ivi_id);
+
if (ret != nullptr)
{
afb_req_fail(req, "failed", ret);
return;
}
+ createSecurityContext(req, appid, a_drawing_name);
+
afb_req_success(req, NULL, "success");
}
catch (std::exception &e)
diff --git a/src/wayland_ivi_wm.cpp b/src/wayland_ivi_wm.cpp
index dd6fbf8..522295d 100644
--- a/src/wayland_ivi_wm.cpp
+++ b/src/wayland_ivi_wm.cpp
@@ -216,31 +216,31 @@ void surface_visibility_changed(
void *data, struct ivi_wm * /*ivi_wm*/,
uint32_t surface_id, int32_t visibility)
{
- auto s = static_cast<struct surface *>(data);
- s->parent->surface_visibility_changed(s, visibility);
+ auto c = static_cast<struct controller *>(data);
+ c->surface_visibility_changed(surface_id, visibility);
}
void surface_opacity_changed(void *data, struct ivi_wm * /*ivi_wm*/,
uint32_t surface_id, wl_fixed_t opacity)
{
- auto s = static_cast<struct surface *>(data);
- s->parent->surface_opacity_changed(s, float(wl_fixed_to_double(opacity)));
+ auto c = static_cast<struct controller *>(data);
+ c->surface_opacity_changed(surface_id, float(wl_fixed_to_double(opacity)));
}
void surface_source_rectangle_changed(
void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
int32_t x, int32_t y, int32_t width, int32_t height)
{
- auto s = static_cast<struct surface *>(data);
- s->parent->surface_source_rectangle_changed(s, x, y, width, height);
+ auto c = static_cast<struct controller *>(data);
+ c->surface_source_rectangle_changed(surface_id, x, y, width, height);
}
void surface_destination_rectangle_changed(
void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
int32_t x, int32_t y, int32_t width, int32_t height)
{
- auto s = static_cast<struct surface *>(data);
- s->parent->surface_destination_rectangle_changed(s, x, y, width, height);
+ auto c = static_cast<struct controller *>(data);
+ c->surface_destination_rectangle_changed(surface_id, x, y, width, height);
}
void surface_created(void *data, struct ivi_wm * /*ivi_wm*/,
@@ -252,8 +252,8 @@ void surface_created(void *data, struct ivi_wm * /*ivi_wm*/,
void surface_destroyed(
void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id)
{
- auto s = static_cast<struct surface *>(data);
- s->parent->surface_destroyed(s, surface_id);
+ auto c = static_cast<struct controller *>(data);
+ c->surface_destroyed(surface_id);
}
void surface_error_detected(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t object_id,
@@ -267,52 +267,52 @@ void surface_size_changed(
void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
int32_t width, int32_t height)
{
- auto s = static_cast<struct surface *>(data);
- s->parent->surface_size_changed(s, width, height);
+ auto c = static_cast<struct controller *>(data);
+ c->surface_size_changed(surface_id, width, height);
}
void surface_stats_received(void *data, struct ivi_wm * /*ivi_wm*/,
uint32_t surface_id, uint32_t frame_count, uint32_t pid)
{
- auto s = static_cast<struct surface *>(data);
- s->parent->surface_stats_received(s, surface_id, frame_count, pid);
+ auto c = static_cast<struct controller *>(data);
+ c->surface_stats_received(surface_id, frame_count, pid);
}
void surface_added_to_layer(void *data, struct ivi_wm * /*ivi_wm*/,
uint32_t layer_id, uint32_t surface_id)
{
- auto s = static_cast<struct surface *>(data);
- s->parent->surface_added_to_layer(s, layer_id, surface_id);
+ auto c = static_cast<struct controller *>(data);
+ c->surface_added_to_layer(layer_id, surface_id);
}
void layer_visibility_changed(void *data, struct ivi_wm * /*ivi_wm*/,
uint32_t layer_id, int32_t visibility)
{
- auto l = static_cast<struct layer *>(data);
- l->parent->layer_visibility_changed(l, layer_id, visibility);
+ auto c = static_cast<struct controller *>(data);
+ c->layer_visibility_changed(layer_id, visibility);
}
void layer_opacity_changed(void *data, struct ivi_wm * /*ivi_wm*/,
uint32_t layer_id, wl_fixed_t opacity)
{
- auto l = static_cast<struct layer *>(data);
- l->parent->layer_opacity_changed(l, layer_id, float(wl_fixed_to_double(opacity)));
+ auto c = static_cast<struct controller *>(data);
+ c->layer_opacity_changed(layer_id, float(wl_fixed_to_double(opacity)));
}
void layer_source_rectangle_changed(
void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id,
int32_t x, int32_t y, int32_t width, int32_t height)
{
- auto l = static_cast<struct layer *>(data);
- l->parent->layer_source_rectangle_changed(l, layer_id, x, y, width, height);
+ auto c = static_cast<struct controller *>(data);
+ c->layer_source_rectangle_changed(layer_id, x, y, width, height);
}
void layer_destination_rectangle_changed(
void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id,
int32_t x, int32_t y, int32_t width, int32_t height)
{
- auto l = static_cast<struct layer *>(data);
- l->parent->layer_destination_rectangle_changed(l, layer_id, x, y, width, height);
+ auto c = static_cast<struct controller *>(data);
+ c->layer_destination_rectangle_changed(layer_id, x, y, width, height);
}
void layer_created(void *data, struct ivi_wm * /*ivi_wm*/,
@@ -323,8 +323,8 @@ void layer_created(void *data, struct ivi_wm * /*ivi_wm*/,
void layer_destroyed(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id)
{
- auto l = static_cast<struct layer *>(data);
- l->parent->layer_destroyed(l, layer_id);
+ auto c = static_cast<struct controller *>(data);
+ c->layer_destroyed(layer_id);
}
void layer_error_detected(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t object_id,
@@ -556,56 +556,55 @@ void controller::layer_error_detected(uint32_t object_id,
this->proxy.get(), object_id, error_code, error_text);
}
-void controller::surface_visibility_changed(struct surface *s, int32_t visibility)
+void controller::surface_visibility_changed(uint32_t id, int32_t visibility)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d v %i", __func__, s->id,
+ HMI_DEBUG("wm", "compositor::surface %s @ %d v %i", __func__, id,
visibility);
- this->sprops[s->id].visibility = visibility;
- this->chooks->surface_visibility(s->id, visibility);
+ this->sprops[id].visibility = visibility;
+ this->chooks->surface_visibility(id, visibility);
}
-void controller::surface_opacity_changed(struct surface *s, float opacity)
+void controller::surface_opacity_changed(uint32_t id, float opacity)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d o %f", __func__, s->id,
- opacity);
- this->sprops[s->id].opacity = opacity;
+ HMI_DEBUG("wm", "compositor::surface %s @ %d o %f",
+ __func__, id, opacity);
+ this->sprops[id].opacity = opacity;
}
-void controller::surface_source_rectangle_changed(struct surface *s, int32_t x,
+void controller::surface_source_rectangle_changed(uint32_t id, int32_t x,
int32_t y, int32_t width,
int32_t height)
{
HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
- s->id, x, y, width, height);
- this->sprops[s->id].src_rect = rect{width, height, x, y};
+ id, x, y, width, height);
+ this->sprops[id].src_rect = rect{width, height, x, y};
}
-void controller::surface_destination_rectangle_changed(struct surface *s, int32_t x,
+void controller::surface_destination_rectangle_changed(uint32_t id, int32_t x,
int32_t y, int32_t width,
int32_t height)
{
HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__,
- s->id, x, y, width, height);
- this->sprops[s->id].dst_rect = rect{width, height, x, y};
- this->chooks->surface_destination_rectangle(s->id, x, y, width, height);
+ id, x, y, width, height);
+ this->sprops[id].dst_rect = rect{width, height, x, y};
+ this->chooks->surface_destination_rectangle(id, x, y, width, height);
}
-void controller::surface_size_changed(struct surface *s, int32_t width,
+void controller::surface_size_changed(uint32_t id, int32_t width,
int32_t height)
{
- HMI_DEBUG("wm", "compositor::surface %s @ %d w %i h %i", __func__, s->id,
+ HMI_DEBUG("wm", "compositor::surface %s @ %d w %i h %i", __func__, id,
width, height);
- this->sprops[s->id].size = size{uint32_t(width), uint32_t(height)};
+ this->sprops[id].size = size{uint32_t(width), uint32_t(height)};
}
-void controller::surface_added_to_layer(struct surface *s,
- uint32_t layer_id, uint32_t surface_id)
+void controller::surface_added_to_layer(uint32_t layer_id, uint32_t surface_id)
{
HMI_DEBUG("wm", "compositor::surface %s @ %d l %u",
__func__, layer_id, surface_id);
}
-void controller::surface_stats_received(struct surface *s, uint32_t surface_id,
+void controller::surface_stats_received(uint32_t surface_id,
uint32_t frame_count, uint32_t pid)
{
HMI_DEBUG("wm", "compositor::surface %s @ %d f %u pid %u",
@@ -630,7 +629,7 @@ void controller::surface_created(uint32_t id)
}
}
-void controller::surface_destroyed(struct surface *s, uint32_t surface_id)
+void controller::surface_destroyed(uint32_t surface_id)
{
HMI_DEBUG("wm", "compositor::surface %s @ %d", __func__, surface_id);
this->chooks->surface_removed(surface_id);
@@ -645,19 +644,19 @@ void controller::surface_error_detected(uint32_t object_id,
this->proxy.get(), object_id, error_code, error_text);
}
-void controller::layer_visibility_changed(struct layer *l, uint32_t layer_id, int32_t visibility)
+void controller::layer_visibility_changed(uint32_t layer_id, int32_t visibility)
{
HMI_DEBUG("wm", "compositor::layer %s @ %d v %i", __func__, layer_id, visibility);
this->lprops[layer_id].visibility = visibility;
}
-void controller::layer_opacity_changed(struct layer *l, uint32_t layer_id, float opacity)
+void controller::layer_opacity_changed(uint32_t layer_id, float opacity)
{
HMI_DEBUG("wm", "compositor::layer %s @ %d o %f", __func__, layer_id, opacity);
this->lprops[layer_id].opacity = opacity;
}
-void controller::layer_source_rectangle_changed(struct layer *l, uint32_t layer_id,
+void controller::layer_source_rectangle_changed(uint32_t layer_id,
int32_t x, int32_t y,
int32_t width, int32_t height)
{
@@ -666,7 +665,7 @@ void controller::layer_source_rectangle_changed(struct layer *l, uint32_t layer_
this->lprops[layer_id].src_rect = rect{width, height, x, y};
}
-void controller::layer_destination_rectangle_changed(struct layer *l, uint32_t layer_id,
+void controller::layer_destination_rectangle_changed(uint32_t layer_id,
int32_t x, int32_t y,
int32_t width, int32_t height)
{
@@ -675,7 +674,7 @@ void controller::layer_destination_rectangle_changed(struct layer *l, uint32_t l
this->lprops[layer_id].dst_rect = rect{width, height, x, y};
}
-void controller::layer_destroyed(struct layer *l, uint32_t layer_id)
+void controller::layer_destroyed(uint32_t layer_id)
{
HMI_DEBUG("wm", "compositor::layer %s @ %d", __func__, layer_id);
this->lprops.erase(layer_id);
diff --git a/src/wayland_ivi_wm.hpp b/src/wayland_ivi_wm.hpp
index ac9a7fc..d6b47af 100644
--- a/src/wayland_ivi_wm.hpp
+++ b/src/wayland_ivi_wm.hpp
@@ -292,29 +292,29 @@ struct controller : public wayland_proxy<struct ivi_wm>
void create_screen(struct wl_output *output);
// Events
- void surface_visibility_changed(struct surface *s, int32_t visibility);
- void surface_opacity_changed(struct surface *s, float opacity);
- void surface_source_rectangle_changed(struct surface *s, int32_t x, int32_t y,
+ void surface_visibility_changed(uint32_t id, int32_t visibility);
+ void surface_opacity_changed(uint32_t id, float opacity);
+ void surface_source_rectangle_changed(uint32_t id, int32_t x, int32_t y,
int32_t width, int32_t height);
- void surface_destination_rectangle_changed(struct surface *s, int32_t x, int32_t y,
+ void surface_destination_rectangle_changed(uint32_t id, int32_t x, int32_t y,
int32_t width, int32_t height);
void surface_created(uint32_t id);
- void surface_destroyed(struct surface *s, uint32_t surface_id);
+ void surface_destroyed(uint32_t surface_id);
void surface_error_detected(uint32_t object_id,
uint32_t error_code, char const *error_text);
- void surface_size_changed(struct surface *s, int32_t width, int32_t height);
- void surface_stats_received(struct surface *s, uint32_t surface_id,
+ void surface_size_changed(uint32_t id, int32_t width, int32_t height);
+ void surface_stats_received(uint32_t surface_id,
uint32_t frame_count, uint32_t pid);
- void surface_added_to_layer(struct surface *s, uint32_t layer_id, uint32_t surface_id);
+ void surface_added_to_layer(uint32_t layer_id, uint32_t surface_id);
- void layer_visibility_changed(struct layer *l, uint32_t layer_id, int32_t visibility);
- void layer_opacity_changed(struct layer *l, uint32_t layer_id, float opacity);
- void layer_source_rectangle_changed(struct layer *l, uint32_t layer_id, int32_t x, int32_t y,
+ void layer_visibility_changed(uint32_t layer_id, int32_t visibility);
+ void layer_opacity_changed(uint32_t layer_id, float opacity);
+ void layer_source_rectangle_changed(uint32_t layer_id, int32_t x, int32_t y,
int32_t width, int32_t height);
- void layer_destination_rectangle_changed(struct layer *l, uint32_t layer_id, int32_t x, int32_t y,
+ void layer_destination_rectangle_changed(uint32_t layer_id, int32_t x, int32_t y,
int32_t width, int32_t height);
void layer_created(uint32_t id);
- void layer_destroyed(struct layer *l, uint32_t layer_id);
+ void layer_destroyed(uint32_t layer_id);
void layer_error_detected(uint32_t object_id,
uint32_t error_code, char const *error_text);
};
diff --git a/src/window_manager.cpp b/src/window_manager.cpp
index 612b544..98ebcf1 100644
--- a/src/window_manager.cpp
+++ b/src/window_manager.cpp
@@ -238,7 +238,7 @@ result<int> WindowManager::api_request_surface(char const *appid, char const *dr
HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
if (!lid)
{
- return Err<int>("Drawing name does not match any role, Fallback is disabled");
+ return Err<int>("Drawing name does not match any role, fallback is disabled");
}
}
@@ -292,7 +292,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr
HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role);
if (!lid)
{
- return "Drawing name does not match any role, Fallback is disabled";
+ return "Drawing name does not match any role, fallback is disabled";
}
}
diff --git a/src/window_manager.hpp b/src/window_manager.hpp
index 0fb1805..7f9a3b8 100644
--- a/src/window_manager.hpp
+++ b/src/window_manager.hpp
@@ -208,13 +208,13 @@ class WindowManager
int dispatch_pending_events();
void set_pending_events();
- result<int> api_request_surface(char const *appid, char const *drawing_name);
- char const *api_request_surface(char const *appid, char const *drawing_name, char const *ivi_id);
- void api_activate_surface(char const *appid, char const *drawing_name, char const *drawing_area, const reply_func &reply);
- void api_deactivate_surface(char const *appid, char const *drawing_name, const reply_func &reply);
- void api_enddraw(char const *appid, char const *drawing_name);
+ result<int> api_request_surface(char const *appid, char const *role);
+ char const *api_request_surface(char const *appid, char const *role, char const *ivi_id);
+ void api_activate_surface(char const *appid, char const *role, char const *drawing_area, const reply_func &reply);
+ void api_deactivate_surface(char const *appid, char const *role, const reply_func &reply);
+ void api_enddraw(char const *appid, char const *role);
result<json_object *> api_get_display_info();
- result<json_object *> api_get_area_info(char const *drawing_name);
+ result<json_object *> api_get_area_info(char const *role);
void api_ping();
void send_event(char const *evname, char const *label);
void send_event(char const *evname, char const *label, char const *area, int x, int y, int w, int h);
@@ -225,6 +225,7 @@ class WindowManager
void removeClient(const std::string &appid);
void exceptionProcessForTransition();
+ const char* convertRoleOldToNew(char const *role);
// Do not use this function
void timerHandler();
@@ -267,9 +268,8 @@ class WindowManager
void processNextRequest();
int loadOldRoleDb();
- const char* convertRoleOldToNew(char const *drawing_name);
- const char *check_surface_exist(const char *drawing_name);
+ const char *check_surface_exist(const char *role);
bool can_split(struct LayoutState const &state, int new_id);