summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2022-06-17 20:30:05 -0400
committerScott Murray <scott.murray@konsulko.com>2022-07-04 21:23:37 +0000
commite490ff1e1e31b4a837cb8063f7346dc65ffe073e (patch)
tree083e89ee22258db4c91fc8398a6cbbbd5aa14afb
parentc35327b02a28a83536450a664326d183662e89e1 (diff)
Add VIS vehicle signal support
Update the volume control code to use to use VIS signalling instead of the previous agl-service-audiomixer binding usage. Bug-AGL: SPEC-4409 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ifc622a51991110c7786b80ee0af574ed6ca80561 (cherry picked from commit e3b392b8a0767f35e6dbbdb1e9d126294aebdcb5)
-rw-r--r--homescreen/homescreen.pro2
-rw-r--r--homescreen/qml/MediaAreaBlank.qml12
-rw-r--r--homescreen/src/main.cpp1
-rw-r--r--homescreen/src/mastervolume.cpp122
-rw-r--r--homescreen/src/mastervolume.h21
5 files changed, 74 insertions, 84 deletions
diff --git a/homescreen/homescreen.pro b/homescreen/homescreen.pro
index fd53072..00ed5e7 100644
--- a/homescreen/homescreen.pro
+++ b/homescreen/homescreen.pro
@@ -17,7 +17,7 @@ TEMPLATE = app
TARGET = homescreen
QT = qml quick gui-private dbus
CONFIG += c++11 link_pkgconfig wayland-scanner
-PKGCONFIG += wayland-client qtappfw-weather qtappfw-network qtappfw-bt
+PKGCONFIG += wayland-client qtappfw-weather qtappfw-network qtappfw-bt qtappfw-vehicle-signals
DBUS_INTERFACES = $$[QT_SYSROOT]/usr/share/dbus-1/interfaces/org.automotivelinux.AppLaunch.xml
diff --git a/homescreen/qml/MediaAreaBlank.qml b/homescreen/qml/MediaAreaBlank.qml
index 7a9e8af..b758a7d 100644
--- a/homescreen/qml/MediaAreaBlank.qml
+++ b/homescreen/qml/MediaAreaBlank.qml
@@ -19,9 +19,7 @@ import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0
import AGL.Demo.Controls 1.0
-/*
import MasterVolume 1.0
-*/
Image {
anchors.fill: parent
@@ -68,16 +66,13 @@ Image {
transitions: Transition {
NumberAnimation { property: "opacity"; duration: 500}
}
-/*
+
MasterVolume {
id: mv
objectName: "mv"
onVolumeChanged: slider.value = volume
- Component.onCompleted: {
- mv.open(bindingAddress);
- }
}
-*/
+
Item {
id: master_volume
anchors.fill: parent
@@ -108,10 +103,9 @@ Image {
to: 100
stepSize: 1
snapMode: Slider.SnapOnRelease
-/*
onValueChanged: mv.volume = value
Component.onCompleted: value = mv.volume
-*/
+
onPressedChanged: {
if (pressed) {volume_timer.stop()}
else {volume_timer.restart()}
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp
index 4e3073f..74ec4f4 100644
--- a/homescreen/src/main.cpp
+++ b/homescreen/src/main.cpp
@@ -248,6 +248,7 @@ load_agl_shell_app(QPlatformNativeInterface *native,
int main(int argc, char *argv[])
{
setenv("QT_QPA_PLATFORM", "wayland", 1);
+ setenv("QT_QUICK_CONTROLS_STYLE", "AGL", 1);
QGuiApplication a(argc, argv);
const char *screen_name;
bool is_demo_val = false;
diff --git a/homescreen/src/mastervolume.cpp b/homescreen/src/mastervolume.cpp
index de8d75d..8d7ecb4 100644
--- a/homescreen/src/mastervolume.cpp
+++ b/homescreen/src/mastervolume.cpp
@@ -18,25 +18,21 @@
#include <QTimer>
#include <QtDebug>
-#define MASTER_CONTROL "Master Playback"
-
-MasterVolume::MasterVolume(QObject* parent)
- : QObject(parent)
- , m_volume{50}
+MasterVolume::MasterVolume(QObject* parent) :
+ QObject(parent),
+ m_volume(50)
{
-#if 0
- connect(&m_client, SIGNAL(connected()), this, SLOT(onClientConnected()));
- connect(&m_client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected()));
- connect(&m_client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onClientError(QAbstractSocket::SocketError)));
- connect(&m_client, SIGNAL(eventReceived(QString, const QJsonValue&)), this, SLOT(onClientEventReceived(QString, const QJsonValue&)));
-#endif
-}
+ VehicleSignalsConfig vsConfig("homescreen");
+ m_vs = new VehicleSignals(vsConfig);
-#if 0
-void MasterVolume::open(const QUrl& url)
-{
+ if (m_vs) {
+ QObject::connect(m_vs, &VehicleSignals::connected, this, &MasterVolume::onConnected);
+ QObject::connect(m_vs, &VehicleSignals::authorized, this, &MasterVolume::onAuthorized);
+ QObject::connect(m_vs, &VehicleSignals::disconnected, this, &MasterVolume::onDisconnected);
+
+ m_vs->connect();
+ }
}
-#endif
qint32 MasterVolume::getVolume() const
{
@@ -45,72 +41,70 @@ qint32 MasterVolume::getVolume() const
void MasterVolume::setVolume(qint32 volume)
{
- if (m_volume != volume)
- {
- m_volume = volume;
-#if 0
- QJsonObject arg;
- arg.insert("control", MASTER_CONTROL);
- double v = (double) volume / 100.0;
- arg.insert("value", v);
- m_client.call("audiomixer", "volume", arg);
-#endif
- }
-}
+ if (m_volume == volume)
+ return;
-#if 0
+ m_volume = volume;
-void MasterVolume::onClientConnected()
-{
+ if (!(m_vs && m_connected))
+ return;
- QJsonObject arg;
- arg.insert("control", MASTER_CONTROL);
- m_client.call("audiomixer", "volume", arg, [this](bool r, const QJsonValue& v) {
- if (r && v.isObject()) {
- int volume = v.toObject()["response"].toObject()["volume"].toDouble() * 100;
- volume = qBound(0, volume, 100);
- if (m_volume != volume)
- {
- m_volume = volume;
- emit VolumeChanged();
- }
- }
-
- QJsonObject arg;
- arg.insert("event", "volume_changed");
- m_client.call("audiomixer", "subscribe", arg);
- });
+ m_vs->set("Vehicle.Cabin.Infotainment.Media.Volume", QString::number(volume));
}
-void MasterVolume::onClientDisconnected()
+void MasterVolume::onConnected()
{
- qDebug() << "MasterVolume::onClientDisconnected!";
- QTimer::singleShot(1000, this, SLOT(TryOpen()));
+ if (!m_vs)
+ return;
+
+ m_vs->authorize();
}
-void MasterVolume::onClientError(QAbstractSocket::SocketError se)
+void MasterVolume::onAuthorized()
{
- qDebug() << "MasterVolume::onClientError: " << se;
+ if (!m_vs)
+ return;
+
+ m_connected = true;
+
+ QObject::connect(m_vs, &VehicleSignals::getSuccessResponse, this, &MasterVolume::onGetSuccessResponse);
+ QObject::connect(m_vs, &VehicleSignals::signalNotification, this, &MasterVolume::onSignalNotification);
+
+ m_vs->subscribe("Vehicle.Cabin.Infotainment.Media.Volume");
+ m_vs->get("Vehicle.Cabin.Infotainment.Media.Volume");
}
-void MasterVolume::onClientEventReceived(QString name, const QJsonValue& data)
+void MasterVolume::onDisconnected()
{
- qDebug() << "MasterVolume::onClientEventReceived[" << name << "]: " << data;
- if (name == "audiomixer/volume_changed")
- {
- QString ctlName = data.toObject()["control"].toString();
+ QObject::disconnect(m_vs, &VehicleSignals::signalNotification, this, &MasterVolume::onGetSuccessResponse);
+ QObject::disconnect(m_vs, &VehicleSignals::signalNotification, this, &MasterVolume::onSignalNotification);
- if (ctlName != MASTER_CONTROL)
- return;
+ m_connected = false;
+}
- int volume = data.toObject()["value"].toDouble() * 100;
+void MasterVolume::updateVolume(QString value)
+{
+ bool ok;
+ qint32 volume = value.toInt(&ok);
+ if (ok) {
volume = qBound(0, volume, 100);
- if (m_volume != volume)
- {
+ if (m_volume != volume) {
m_volume = volume;
emit VolumeChanged();
}
}
}
-#endif
+void MasterVolume::onGetSuccessResponse(QString path, QString value, QString timestamp)
+{
+ if (path == "Vehicle.Cabin.Infotainment.Media.Volume") {
+ updateVolume(value);
+ emit VolumeChanged();
+ }
+}
+
+void MasterVolume::onSignalNotification(QString path, QString value, QString timestamp)
+{
+ if (path == "Vehicle.Cabin.Infotainment.Media.Volume")
+ updateVolume(value);
+}
diff --git a/homescreen/src/mastervolume.h b/homescreen/src/mastervolume.h
index 04ce3b5..fbbab4b 100644
--- a/homescreen/src/mastervolume.h
+++ b/homescreen/src/mastervolume.h
@@ -16,32 +16,33 @@
#include <QtCore/QObject>
#include <QQmlEngine>
+#include "vehiclesignals.h"
-class MasterVolume
- : public QObject
+class MasterVolume : public QObject
{
Q_OBJECT
Q_PROPERTY (uint32_t volume READ getVolume WRITE setVolume NOTIFY VolumeChanged)
private:
qint32 m_volume;
+ VehicleSignals *m_vs;
+ bool m_connected;
+
+ void updateVolume(QString value);
public:
MasterVolume(QObject* parent = nullptr);
~MasterVolume() = default;
- //Q_INVOKABLE void open(const QUrl& url);
Q_INVOKABLE qint32 getVolume() const;
Q_INVOKABLE void setVolume(qint32 val);
private slots:
-#if 0
- void onClientConnected();
- void onClientDisconnected();
- void onClientError(QAbstractSocket::SocketError se);
- void onClientEventReceived(QString name, const QJsonValue& data);
- void TryOpen();
-#endif
+ void onConnected();
+ void onAuthorized();
+ void onDisconnected();
+ void onGetSuccessResponse(QString path, QString value, QString timestamp);
+ void onSignalNotification(QString path, QString value, QString timestamp);
signals:
void VolumeChanged();