diff options
author | Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> | 2017-07-13 03:01:41 +0900 |
---|---|---|
committer | Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> | 2017-07-13 15:23:29 +0000 |
commit | b28064e1f04eac99995e1462771fb43b7bba8545 (patch) | |
tree | a004b18679d80d3af2b564f5246e739365648a58 | |
parent | 7e47c84270b7bd22aab1f6bd20e01e9e8f68f489 (diff) |
Fix the issue early launched apps before HomeScreendab_4.0.0dab_3.99.3dab/4.0.0dab/3.99.34.0.03.99.3
WindowManager uses the pid to manage app's surface
and layer and the pid is from creatorPid of
ivi-surface. It used to be the same value as
afm-util returns when apps launched via HomeScreen.
After new AGL application framework has come,
afm-util no longer returns the same value as
creatorPid.
So commit 4cb274 and bb3369 are introduced, then
WindowManager started to use process group or
session instead of pid which is returned by afm-util.
But inside WindowManager pid which returned by afm-util
is still used to detect ivi surface for app. It is
registered when app is launched via HomeScreen and
it is retrived by app's process group or session
from creatorPid when ivi-surface has been created.
Because this logic of pid conversion was incomplete,
it caused the issue which early launched app has
never been shown even when user try to launch
it via HomeScreen.
This patch introduces quick hack to resolve this
issue and improve the surface management in
WindowManager.
Bug-AGL: SPEC-745
Change-Id: Iafa2e56c07b3c3a2eff23ff75cdedb3226d7f55a
Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
-rw-r--r-- | windowmanager/src/windowmanager.cpp | 162 | ||||
-rw-r--r-- | windowmanager/src/windowmanager.hpp | 8 |
2 files changed, 111 insertions, 59 deletions
diff --git a/windowmanager/src/windowmanager.cpp b/windowmanager/src/windowmanager.cpp index 6510b74..ea5a279 100644 --- a/windowmanager/src/windowmanager.cpp +++ b/windowmanager/src/windowmanager.cpp @@ -60,6 +60,9 @@ WindowManager::WindowManager(int displayId, QObject *parent) : , m_appSurfaces(), m_appLayers(), +#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) + m_appPid2surfPid(), +#endif m_keepApps(), m_bgApps(), m_pending_to_show(-1) @@ -136,13 +139,18 @@ t_ilm_layer* WindowManager::getLayerRenderOrder(int& num_layers) for (i = 0; i < n_bg; i++) { if (m_bgApps[i] != 0) { QMap<pid_t, t_ilm_layer>::const_iterator i_layers; - i_layers = m_appLayers.find(m_bgApps[i]); + QMap<pid_t, pid_t>::const_iterator i_surf_pids; + + i_surf_pids = m_appPid2surfPid.find(m_bgApps[i]); + if (i_surf_pids != m_appPid2surfPid.end()) { + i_layers = m_appLayers.find(i_surf_pids.value()); /* m_showLayers[2] means layer for apps */ if (i_layers != m_appLayers.end() && i_layers.value() != 0 && i_layers.value() != m_showLayers[2]) { qDebug(" m_bgApps[%d]=%d", i, i_layers.value()); id_array[num_layers++] = i_layers.value(); } + } } } @@ -233,21 +241,21 @@ t_ilm_layer WindowManager::getAppLayerID(pid_t pid) void WindowManager::addSurface(t_ilm_surface surfaceId) { struct ilmSurfaceProperties surfaceProperties; - pid_t pid; + pid_t surf_pid; ilm_getPropertiesOfSurface(surfaceId, &surfaceProperties); - pid = surfaceProperties.creatorPid; -#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) - pid = surfPid2AppPid(pid); -#endif + surf_pid = surfaceProperties.creatorPid; - QMap<pid_t, t_ilm_surface>::const_iterator i = m_appSurfaces.find(pid); + QMap<pid_t, t_ilm_surface>::const_iterator i = m_appSurfaces.find(surf_pid); if (i == m_appSurfaces.end() || i.value() == 0) { /* Only the 1st surface is handled by Window Manager */ - qDebug("This surface (%d) is 1st one for app (%d)", surfaceId, pid); + qDebug("This surface (%d) is 1st one for app (%d)", surfaceId, surf_pid); /* update surface id */ - m_appSurfaces.insert(pid, surfaceId); + m_appSurfaces.insert(surf_pid, surfaceId); +#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) + registerAppPid2surfPid(surf_pid); +#endif /* this surface should be handled by WindowManager */ ilm_surfaceAddNotification(surfaceId, surfaceCallbackFunction_static); ilm_commitChanges(); @@ -431,9 +439,7 @@ void WindowManager::surfaceCallbackFunction_non_static(t_ilm_surface surface, t_ilm_notification_mask mask) { pid_t pid = surfaceProperties->creatorPid; -#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) - pid = surfPid2AppPid(pid); -#endif + qDebug("-=[surfaceCallbackFunction_non_static]=-"); qDebug("surfaceCallbackFunction_non_static changes for surface %d", surface); if (ILM_NOTIFICATION_VISIBILITY & mask) @@ -746,92 +752,119 @@ void WindowManager::showLayer(int layer) #endif } -void WindowManager::showAppLayer(int pid) +void WindowManager::showAppLayer(int app_pid) { qDebug("-=[showAppLayer]=-"); - qDebug("pid %d", pid); + qDebug("pid %d", app_pid); - if (pid == -1) { + if (app_pid == -1) { /* nothing to show */ return; } + #ifdef HAVE_IVI_LAYERMANAGEMENT_API +#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) + pid_t surf_pid = appPid2surfPid(app_pid); + if (surf_pid == -1) { + qDebug("Error: app's pid(%d) failed to convert surface's pid.", app_pid); + return; + } +#else + pid_t surf_pid = app_pid; +#endif + /* clear pending flag */ m_pending_to_show = -1; /* search layer id for application to show */ - QMap<pid_t, t_ilm_layer>::const_iterator i = m_appLayers.find(pid); + QMap<pid_t, t_ilm_layer>::const_iterator i = m_appLayers.find(surf_pid); if (i != m_appLayers.end()) { - qDebug("Found layer(%d) to show for app(pid=%d)", m_showLayers[2], pid); + qDebug("Found layer(%d) to show for app(pid=%d)", m_showLayers[2], surf_pid); m_showLayers[2] = i.value(); } else { - QMap<pid_t, t_ilm_surface>::const_iterator j = m_appSurfaces.find(pid); + QMap<pid_t, t_ilm_surface>::const_iterator j = m_appSurfaces.find(surf_pid); /* check if this app is registered */ if (j == m_appSurfaces.end()) { - qDebug("New app %d", pid); - m_appSurfaces.insert(pid, 0); /* register pid only so far */ + qDebug("New app %d", surf_pid); + m_appSurfaces.insert(surf_pid, 0); /* register pid only so far */ } /* check app is required keep running while background */ /* Probably app layer hasn't been made yet */ - m_pending_to_show = pid; + m_pending_to_show = app_pid; /* hide current app once, back to default screen */ m_showLayers[2] = 0; - qDebug("No layer to show for app(pid=%d)", pid); + qDebug("No layer to show for app(pid=%d)", surf_pid); } renderLayers(); #endif } -void WindowManager::showAppLayer(const QString &app_id, int pid) +void WindowManager::showAppLayer(const QString &app_id, int app_pid) { qDebug("-=[showAppLayer]=-"); - qDebug() << "id=" << app_id << ", pid=" << pid; + qDebug() << "id=" << app_id << ", pid=" << app_pid; - if (pid == -1) { + if (app_pid == -1) { /* nothing to show */ return; } #ifdef HAVE_IVI_LAYERMANAGEMENT_API +#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) + pid_t surf_pid = appPid2surfPid(app_pid); + if (surf_pid == -1) { + qDebug("NOTE: surface for this app(%d) hasn't created yet.", app_pid); + + checkBackgroundApps(app_id, app_pid); + m_pending_to_show = app_pid; + return; + } +#else + pid_t surf_pid = app_pid; +#endif /* clear pending flag */ m_pending_to_show = -1; /* search layer id for application to show */ - QMap<pid_t, t_ilm_layer>::const_iterator i = m_appLayers.find(pid); + QMap<pid_t, t_ilm_layer>::const_iterator i = m_appLayers.find(surf_pid); if (i != m_appLayers.end()) { - qDebug("Found layer(%d) to show for app(pid=%d)", m_showLayers[2], pid); + qDebug("Found layer(%d) to show for app(pid=%d)", m_showLayers[2], surf_pid); m_showLayers[2] = i.value(); } else { - QMap<pid_t, t_ilm_surface>::const_iterator j = m_appSurfaces.find(pid); + QMap<pid_t, t_ilm_surface>::const_iterator j = m_appSurfaces.find(surf_pid); /* check if this app is registered */ if (j == m_appSurfaces.end()) { - qDebug("New app %d", pid); - m_appSurfaces.insert(pid, 0); /* register pid only so far */ - - /* check if rendering is always required */ - /* QML apps should be always rendered if */ - for (int k = 0; k != m_keepApps.size(); k++) { - if (app_id.indexOf(m_keepApps[k]) == 0) { - int idx = m_bgApps.indexOf(pid); - if (idx == -1) { - m_bgApps.append(pid); - } - } - } - } /* check app is required keep running while background */ + qDebug("New app %d", surf_pid); + m_appSurfaces.insert(surf_pid, 0); /* register pid only so far */ + } + /* check app is required keep running while background */ + checkBackgroundApps(app_id, app_pid); /* Probably app layer hasn't been made yet */ - m_pending_to_show = pid; + m_pending_to_show = app_pid; /* hide current app once, back to default screen */ m_showLayers[2] = 0; - qDebug("No layer to show for app(pid=%d)", pid); + qDebug("No layer to show for app(pid=%d)", surf_pid); } renderLayers(); #endif } #ifdef HAVE_IVI_LAYERMANAGEMENT_API +void WindowManager::checkBackgroundApps(const QString &app_id, int app_pid) +{ + /* check if rendering is always required */ + /* QML apps should be always rendered if */ + for (int k = 0; k != m_keepApps.size(); k++) { + if (app_id.indexOf(m_keepApps[k]) == 0) { + int idx = m_bgApps.indexOf(app_pid); + if (idx == -1) { + m_bgApps.append(app_pid); + } + } + } +} #if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) bool WindowManager::otherPids(pid_t pid, pid_t &gpid, pid_t &spid) @@ -863,31 +896,44 @@ bool WindowManager::otherPids(pid_t pid, pid_t &gpid, pid_t &spid) return true; } -pid_t WindowManager::surfPid2AppPid(pid_t pid) +void WindowManager::registerAppPid2surfPid(pid_t surf_pid) { + /* Register app's and surface's pid to conversion table */ pid_t gpid, spid; - QMap<pid_t, t_ilm_surface>::const_iterator i; - i = m_appSurfaces.find(pid); - if (i == m_appSurfaces.end() && otherPids(pid, gpid, spid)) { + if (otherPids(surf_pid, gpid, spid)) { + QMap<pid_t, pid_t>::const_iterator i; #if !defined(NO_PROCESS_GROUP) - i = m_appSurfaces.find(gpid); - if (i != m_appSurfaces.end()) { - qDebug("translate pid %d to Gpid %d", pid, gpid); - return gpid; + i == m_appPid2surfPid.find(gpid); + if (i != m_appPid2surfPid.end()) { + m_appPid2surfPid.insert(gpid, surf_pid); } #endif #if !defined(NO_PROCESS_SESSION) - i = m_appSurfaces.find(spid); - if (i != m_appSurfaces.end()) { - qDebug("translate pid %d to Spid %d", pid, spid); - return spid; + i == m_appPid2surfPid.find(spid); + if (i != m_appPid2surfPid.end()) { + m_appPid2surfPid.insert(spid, surf_pid); } #endif } - return pid; } -#endif +pid_t WindowManager::appPid2surfPid(pid_t app_pid) +{ + if (app_pid == 0) { + /* pid = 0 means it is HomeScreen itself */ + return app_pid; + } + QMap<pid_t, pid_t>::const_iterator j; + j = m_appPid2surfPid.find(app_pid); + if (j != m_appPid2surfPid.end()) { + /* app pid has already been registered. */ + return j.value(); + } + + return -1; +} #endif + +#endif // HAVE_IVI_LAYMERMANAGEMENT_API diff --git a/windowmanager/src/windowmanager.hpp b/windowmanager/src/windowmanager.hpp index 0826627..12643e7 100644 --- a/windowmanager/src/windowmanager.hpp +++ b/windowmanager/src/windowmanager.hpp @@ -52,6 +52,9 @@ private: t_ilm_layer* m_showLayers; QMap<pid_t, t_ilm_surface> m_appSurfaces; QMap<pid_t, t_ilm_layer> m_appLayers; +#if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) + QMap<pid_t, pid_t>m_appPid2surfPid; +#endif QList<QString> m_keepApps; /* Apps needs to keep rendering */ QList<pid_t> m_bgApps; @@ -72,9 +75,12 @@ private: void configureAppSurface(const pid_t pid, const t_ilm_surface surface, const t_ilm_int width, const t_ilm_int height); void renderLayers(); + void checkBackgroundApps(const QString &app_id, int app_pid); + #if !defined(NO_PROCESS_GROUP) || !defined(NO_PROCESS_SESSION) bool otherPids(pid_t pid, pid_t &gpid, pid_t &spid); - pid_t surfPid2AppPid(pid_t pid); + void registerAppPid2surfPid(pid_t surf_pid); + pid_t appPid2surfPid(pid_t app_pid); #endif #endif void updateScreen(); |