Add VIS vehicle signal support 46/27646/1
authorScott Murray <scott.murray@konsulko.com>
Tue, 7 Jun 2022 19:51:47 +0000 (15:51 -0400)
committerScott Murray <scott.murray@konsulko.com>
Mon, 4 Jul 2022 21:16:10 +0000 (21:16 +0000)
Use the new VehicleSignals API from libqtappfw to replace the
previous signal-composer usage.

Bug-AGL: SPEC-4409

Change-Id: Id5aaa6e9789f75a0aaecd4cfc560bbc4bae3f4c5
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
(cherry picked from commit 61e3d69532099d7215410c5b38e29ba3525dec46)

app/MediaPlayer.qml
app/app.pro
app/main.cpp

index 177fe36..95bc22b 100644 (file)
@@ -49,6 +49,8 @@ ApplicationWindow {
     Component.onCompleted : {
         // Let the mediaplayer backend know we're ready for metadata events
         mediaplayer.start()
+
+        VehicleSignals.connect()
     }
 
     Connections {
@@ -86,6 +88,33 @@ ApplicationWindow {
         }
     }
 
+    Connections {
+        target: VehicleSignals
+
+        onConnected: {
+           VehicleSignals.authorize()
+        }
+
+        onAuthorized: {
+           VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Media.Action")
+       }
+
+        onSignalNotification: {
+            if (path === "Vehicle.Cabin.Infotainment.Media.Action") {
+                if (value == "SkipForward") {
+                    mediaplayer.next()
+                } else if (value == "SkipBackward") {
+                    mediaplayer.previous()
+                } else if (value == "NextSource") {
+                    if (player.av_connected)
+                        mediaplayer.connect()
+                    else
+                        mediaplayer.disconnect()
+                }
+            }
+        }
+    }
+
     Timer {
         id: timer
         interval: 250
index d14bdb6..dee1c5a 100644 (file)
@@ -3,7 +3,7 @@ TARGET = mediaplayer
 QT = qml quickcontrols2
 CONFIG += c++11 link_pkgconfig
 
-PKGCONFIG += qtappfw-mediaplayer
+PKGCONFIG += qtappfw-mediaplayer qtappfw-vehicle-signals
 
 SOURCES = main.cpp
 
index 771ce3a..2058ff9 100644 (file)
@@ -24,6 +24,7 @@
 #include <QQuickWindow>
 
 #include <mediaplayer.h>
+#include <vehiclesignals.h>
 
 #include <unistd.h>
 
@@ -38,6 +39,8 @@ int main(int argc, char *argv[])
     QQmlContext *context = engine.rootContext();
     context->setContextProperty("AlbumArt", "");
     context->setContextProperty("mediaplayer", new Mediaplayer(context));
+    VehicleSignalsConfig vsConfig("mediaplayer");
+    context->setContextProperty("VehicleSignals", new VehicleSignals(vsConfig));
 
     engine.load(QUrl(QStringLiteral("qrc:/MediaPlayer.qml")));