homescreenhandler: Do not attempt to start launcher 91/27091/3
authorMarius Vlad <marius.vlad@collabora.com>
Mon, 17 Jan 2022 11:46:38 +0000 (13:46 +0200)
committerMarius Vlad <marius.vlad@collabora.com>
Tue, 18 Jan 2022 18:37:38 +0000 (20:37 +0200)
Our launcher application is started by systemd as a user session, and
attempting to start it again would result into being started once more,
but this by applaunchd.
Until we merge homescreen and launcher together avoid starting it and
just activate it whenever necessary.

Bug-AGL: SPEC-4215

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I90806457b74a2439cb8bdc88068954eb7ef1d532

homescreen/src/homescreenhandler.cpp

index 9111ebb..4a8b9cd 100644 (file)
@@ -24,6 +24,9 @@
 
 #define APPLAUNCH_DBUS_IFACE     "org.automotivelinux.AppLaunch"
 #define APPLAUNCH_DBUS_OBJECT    "/org/automotivelinux/AppLaunch"
+/* LAUNCHER_APP_ID shouldn't be started by applaunchd as it is started as a
+ * user session by systemd */
+#define LAUNCHER_APP_ID          "launcher"
 
 void* HomescreenHandler::myThis = 0;
 
@@ -63,20 +66,27 @@ getWlOutput(QPlatformNativeInterface *native, QScreen *screen)
 
 void HomescreenHandler::tapShortcut(QString application_id)
 {
+    QDBusPendingReply<> reply;
     HMI_DEBUG("HomeScreen","tapShortcut %s", application_id.toStdString().c_str());
 
-    QDBusPendingReply<> reply = applaunch_iface->start(application_id);
+    if (application_id == LAUNCHER_APP_ID)
+        goto activate_app;
+
+    reply = applaunch_iface->start(application_id);
     reply.waitForFinished();
+
     if (reply.isError()) {
         HMI_ERROR("HomeScreen","Unable to start application '%s': %s",
             application_id.toStdString().c_str(),
             reply.error().message().toStdString().c_str());
-    } else {
-        if (mp_launcher) {
-            mp_launcher->setCurrent(application_id);
-        }
-        appStarted(application_id);
+        return;
+    }
+
+activate_app:
+    if (mp_launcher) {
+        mp_launcher->setCurrent(application_id);
     }
+    appStarted(application_id);
 }
 
 void HomescreenHandler::appStarted(const QString& application_id)