From 0bdd39b247661c1a0406d450d578d4ff3fd171b0 Mon Sep 17 00:00:00 2001 From: Jan-Simon Moeller Date: Fri, 8 Nov 2019 11:08:35 +0000 Subject: Revert "Add push to talk support to homescreen" It turned out the homescreen won't show. So we need to revisit this patch. https://gerrit.automotivelinux.org/gerrit/#/c/apps/homescreen/+/21182/ This reverts commit f3de2f5cad06a772ee55f58694d559a7cb012c02. Change-Id: Ic8829e5009e9fb74b49ad1dd79125b45a872a838 --- homescreen/homescreen.pro | 12 +- homescreen/qml/MediaArea.qml | 4 +- homescreen/qml/MediaAreaBlank.qml | 18 +- homescreen/qml/SpeechChrome.qml | 120 -------- homescreen/qml/images/SpeechChrome/bar.png | Bin 23826 -> 0 bytes .../qml/images/SpeechChrome/push_to_talk.svg | 322 --------------------- .../qml/images/SpeechChrome/speechchrome.qrc | 6 - homescreen/qml/main.qml | 2 +- homescreen/qml/qml.qrc | 1 - homescreen/src/aglsocketwrapper.cpp | 90 ------ homescreen/src/aglsocketwrapper.h | 35 --- homescreen/src/chromecontroller.cpp | 159 ---------- homescreen/src/chromecontroller.h | 42 --- homescreen/src/constants.h | 42 --- homescreen/src/main.cpp | 4 - package/config.xml | 1 - 16 files changed, 10 insertions(+), 848 deletions(-) delete mode 100644 homescreen/qml/SpeechChrome.qml delete mode 100644 homescreen/qml/images/SpeechChrome/bar.png delete mode 100644 homescreen/qml/images/SpeechChrome/push_to_talk.svg delete mode 100644 homescreen/qml/images/SpeechChrome/speechchrome.qrc delete mode 100644 homescreen/src/aglsocketwrapper.cpp delete mode 100644 homescreen/src/aglsocketwrapper.h delete mode 100644 homescreen/src/chromecontroller.cpp delete mode 100644 homescreen/src/chromecontroller.h delete mode 100644 homescreen/src/constants.h diff --git a/homescreen/homescreen.pro b/homescreen/homescreen.pro index 773271e..8baa90d 100644 --- a/homescreen/homescreen.pro +++ b/homescreen/homescreen.pro @@ -30,19 +30,14 @@ SOURCES += \ src/statusbarserver.cpp \ src/applicationlauncher.cpp \ src/mastervolume.cpp \ - src/homescreenhandler.cpp \ - src/aglsocketwrapper.cpp \ - src/chromecontroller.cpp + src/homescreenhandler.cpp HEADERS += \ src/statusbarmodel.h \ src/statusbarserver.h \ src/applicationlauncher.h \ src/mastervolume.h \ - src/homescreenhandler.h \ - src/aglsocketwrapper.h \ - src/chromecontroller.h \ - src/constants.h + src/homescreenhandler.h OTHER_FILES += \ README.md @@ -54,5 +49,4 @@ RESOURCES += \ qml/images/Shortcut/shortcut.qrc \ qml/images/Status/status.qrc \ qml/images/images.qrc \ - qml/qml.qrc \ - qml/images/SpeechChrome/speechchrome.qrc \ No newline at end of file + qml/qml.qrc diff --git a/homescreen/qml/MediaArea.qml b/homescreen/qml/MediaArea.qml index 3b6d18a..0447589 100644 --- a/homescreen/qml/MediaArea.qml +++ b/homescreen/qml/MediaArea.qml @@ -20,8 +20,8 @@ import QtQuick.Controls 2.0 StackView { id: root - width: parent.width - height: parent.height + width: 1080 + height: 215 initialItem: blank diff --git a/homescreen/qml/MediaAreaBlank.qml b/homescreen/qml/MediaAreaBlank.qml index 60d0c92..ebddb0c 100644 --- a/homescreen/qml/MediaAreaBlank.qml +++ b/homescreen/qml/MediaAreaBlank.qml @@ -22,8 +22,8 @@ import AGL.Demo.Controls 1.0 import MasterVolume 1.0 Image { - width: parent.width - height: parent.height + width: 1080 + height: 215 source: './images/Utility_Logo_Background-01.svg' property bool displayVolume: false; @@ -40,14 +40,14 @@ Image { } Image { - id: logo_image + id: logo_image anchors.centerIn: parent source: './images/Utility_Logo_Grey-01.svg' } Timer { id: volume_timer - interval: 3000; running: false; repeat: false + interval: 5000; running: false; repeat: false onTriggered: displayVolume = false } @@ -56,13 +56,11 @@ Image { PropertyChanges { target: master_volume; opacity: 1.0 } PropertyChanges { target: slider; enabled: true } PropertyChanges { target: logo_image; opacity: 0.0 } - PropertyChanges { target: speech_chrome; visible: false } }, State { when: !displayVolume; PropertyChanges { target: master_volume; opacity: 0.0 } PropertyChanges { target: slider; enabled: false } PropertyChanges { target: logo_image; opacity: 1.0 } - PropertyChanges { target: speech_chrome; visible: speech_chrome.agentPresent } } ] @@ -123,12 +121,4 @@ Image { } } } - - SpeechChrome { - id: speech_chrome - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: parent.height - } } diff --git a/homescreen/qml/SpeechChrome.qml b/homescreen/qml/SpeechChrome.qml deleted file mode 100644 index 911d481..0000000 --- a/homescreen/qml/SpeechChrome.qml +++ /dev/null @@ -1,120 +0,0 @@ -import QtQuick 2.0 -import SpeechChrome 1.0 - -Item { - id: root - - clip: true - - property bool agentPresent: speechChromeController.agentPresent - - visible: agentPresent - - Image { - id: chromeBarImage - - anchors.top: parent.top - source: "./images/SpeechChrome/bar.png" - - Behavior on x { - NumberAnimation { duration: 250 } - } - Behavior on opacity { - NumberAnimation { duration: 250 } - } - } - - Image { - id: pushToTalk - - height: parent.height * 0.80 - width: height - - anchors.left: parent.left - anchors.leftMargin: parent.width / 128 - anchors.verticalCenter: parent.verticalCenter - source: "./images/SpeechChrome/push_to_talk.svg" - - MouseArea { - anchors.fill: parent - onPressed: speechChromeController.pushToTalk() - } - - Behavior on opacity { - NumberAnimation { duration: 250 } - } - } - - states: [ - State { - name: "Idle" - when: speechChromeController.chromeState == SpeechChromeController.Idle - PropertyChanges { - target: chromeBarImage - opacity: 0.0 - x: 0 - } - PropertyChanges { - target: pushToTalk - opacity: 1.0 - enabled: true - } - }, - State { - name: "Listening" - when: speechChromeController.chromeState == SpeechChromeController.Listening - PropertyChanges { - target: chromeBarImage - opacity: 1.0 - x: 0 - } - PropertyChanges { - target: pushToTalk - opacity: 0.0 - enabled: false - } - }, - State { - name: "Thinking" - when: speechChromeController.chromeState == SpeechChromeController.Thinking - PropertyChanges { - target: chromeBarImage - opacity: 1.0 - x: root.width - chromeBarImage.width - } - PropertyChanges { - target: pushToTalk - opacity: 0.0 - enabled: false - } - }, - State { - name: "Speaking" - when: speechChromeController.chromeState == SpeechChromeController.Speaking - PropertyChanges { - target: chromeBarImage - opacity: 1.0 - x: (root.width - chromeBarImage.width) * 0.5 - } - PropertyChanges { - target: pushToTalk - opacity: 0.0 - enabled: false - } - }, - State { - name: "MicrophoneOff" - when: speechChromeController.chromeState == SpeechChromeController.MicrophoneOff - PropertyChanges { - target: chromeBarImage - opacity: 0.0 - x: 0 - } - PropertyChanges { - target: pushToTalk - opacity: 1.0 - enabled: true - } - } - ] -} diff --git a/homescreen/qml/images/SpeechChrome/bar.png b/homescreen/qml/images/SpeechChrome/bar.png deleted file mode 100644 index caabde1..0000000 Binary files a/homescreen/qml/images/SpeechChrome/bar.png and /dev/null differ diff --git a/homescreen/qml/images/SpeechChrome/push_to_talk.svg b/homescreen/qml/images/SpeechChrome/push_to_talk.svg deleted file mode 100644 index 0c775a1..0000000 --- a/homescreen/qml/images/SpeechChrome/push_to_talk.svg +++ /dev/null @@ -1,322 +0,0 @@ - - - -image/svg+xml \ No newline at end of file diff --git a/homescreen/qml/images/SpeechChrome/speechchrome.qrc b/homescreen/qml/images/SpeechChrome/speechchrome.qrc deleted file mode 100644 index 42357f1..0000000 --- a/homescreen/qml/images/SpeechChrome/speechchrome.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - bar.png - push_to_talk.svg - - diff --git a/homescreen/qml/main.qml b/homescreen/qml/main.qml index 233ee4f..7d40276 100644 --- a/homescreen/qml/main.qml +++ b/homescreen/qml/main.qml @@ -99,7 +99,7 @@ Window { } } - Timer { + Timer { id:notificationTimer interval: 3000 running: false diff --git a/homescreen/qml/qml.qrc b/homescreen/qml/qml.qrc index d901481..e60ea63 100644 --- a/homescreen/qml/qml.qrc +++ b/homescreen/qml/qml.qrc @@ -10,6 +10,5 @@ StatusArea.qml TopArea.qml IconItem.qml - SpeechChrome.qml diff --git a/homescreen/src/aglsocketwrapper.cpp b/homescreen/src/aglsocketwrapper.cpp deleted file mode 100644 index 8352660..0000000 --- a/homescreen/src/aglsocketwrapper.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "aglsocketwrapper.h" -#include "constants.h" - -#include -#include -#include -#include -#include - -#include - -namespace { -enum MessageTypes { - Call = 2, - Success = 3, - Error = 4, - Event = 5 -}; -} - -AglSocketWrapper::AglSocketWrapper(QObject *parent) : - QObject(parent) - , m_socket(new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this)) -{ - connect(m_socket, &QWebSocket::connected, this, &AglSocketWrapper::connected); - connect(m_socket, &QWebSocket::disconnected, this, &AglSocketWrapper::disconnected); - connect(m_socket, QOverload::of(&QWebSocket::error), - [](QAbstractSocket::SocketError error) -> void { - qWarning() << "AglSocketWrapper internal socket error" << error; - }); - connect(m_socket, &QWebSocket::textMessageReceived, - this, [this](const QString &msg) -> void { - const QJsonDocument doc = QJsonDocument::fromJson(msg.toUtf8()); - if (doc.isArray()) { - const QJsonArray msgArray = doc.array(); - if (msgArray.count() >= 3) { - const int msgType = msgArray.at(0).toInt(); - switch (msgType) { - case Success: - case Error: { - auto callbackIt = m_callbacks.find( msgArray.at(1).toString()); - if (callbackIt != m_callbacks.constEnd()) { - (*callbackIt)(msgType == Success, msgArray.at(2)); - m_callbacks.erase(callbackIt); - } - } - break; - case Event: { - const QJsonObject eventObj = msgArray.at(2).toObject(); - emit eventReceived(msgArray.at(1).toString(), eventObj.value(vshl::DATA_TAG)); - } - break; - default: - break; - } - return; - } - } - qWarning() << "Unsupported message format:" << msg; - }); -} - -void AglSocketWrapper::open(const QUrl &url) -{ - m_socket->open(url); -} - -void AglSocketWrapper::close() -{ - m_socket->close(); -} - -void AglSocketWrapper::apiCall(const QString &api, const QString &verb, const QJsonValue &args, - AglSocketWrapper::ApiCallback callback) -{ - const QString id = QUuid::createUuid().toString(); - if (callback) - m_callbacks.insert(id, callback); - - QJsonArray callData; - callData.append(Call); - callData.append(id); - callData.append(api + QLatin1String("/") + verb); - callData.append(args); - - const QString msg = QLatin1String(QJsonDocument(callData).toJson(QJsonDocument::Compact)); - m_socket->sendTextMessage(msg); - - qDebug() << Q_FUNC_INFO << "Data sent:" << msg; -} diff --git a/homescreen/src/aglsocketwrapper.h b/homescreen/src/aglsocketwrapper.h deleted file mode 100644 index 4807cd5..0000000 --- a/homescreen/src/aglsocketwrapper.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef AGLSOCKETWRAPPER_H -#define AGLSOCKETWRAPPER_H - -#include -#include -#include -#include - -#include - -class QWebSocket; -class AglSocketWrapper : public QObject -{ - Q_OBJECT -public: - explicit AglSocketWrapper(QObject *parent = nullptr); - - void open(const QUrl &url); - void close(); - - using ApiCallback = std::function; - void apiCall(const QString &api, const QString &verb, const QJsonValue &args = QJsonValue(), - ApiCallback callback = nullptr); - -signals: - void connected(); - void disconnected(); - void eventReceived(const QString &eventName, const QJsonValue &data); - -private: - QWebSocket *m_socket; - QMap m_callbacks; -}; - -#endif // AGLSOCKETWRAPPER_H diff --git a/homescreen/src/chromecontroller.cpp b/homescreen/src/chromecontroller.cpp deleted file mode 100644 index b604dae..0000000 --- a/homescreen/src/chromecontroller.cpp +++ /dev/null @@ -1,159 +0,0 @@ -#include "chromecontroller.h" -#include "aglsocketwrapper.h" -#include "constants.h" - -#include -#include -#include - -ChromeController::ChromeController(const QUrl &bindingUrl, QObject *parent) : - QObject(parent) - , m_aglSocket(new AglSocketWrapper(this)) -{ - //Alexa voice agent subscription---------------------------------------------------------------- - { - connect(m_aglSocket, &AglSocketWrapper::connected, - this, [this]() -> void { - m_aglSocket->apiCall(vshl::API, vshl::VOICE_AGENT_ENUMERATION_VERB, QJsonValue(), - [this](bool result, const QJsonValue &data) -> void { - qDebug() << (vshl::API + QLatin1String(":") + vshl::VOICE_AGENT_ENUMERATION_VERB) - << "result: " << result << " val: " << data; - if (!result) { - qWarning() << "Failed to enumerate voice agents"; - return; - } - - QJsonObject dataObj = data.toObject(); - auto objIt = dataObj.find(vshl::RESPONSE_TAG); - if (objIt == dataObj.constEnd()) { - qWarning() << "Voice agent enumeration response tag missing." - << dataObj; - return; - } - - // Get default voice agent - dataObj = objIt.value().toObject(); - QJsonObject responseObj = dataObj; - objIt = dataObj.find(vshl::DEFAULT_TAG); - if (objIt == dataObj.constEnd()) { - qWarning() << "Voice agent enumeration default agent tag missing." - << dataObj; - return; - } - QString agentId = objIt.value().toString(); - if (agentId.isEmpty()) { - qWarning() << "Default voice agent not found"; - return; - } - qDebug() << (vshl::API + QLatin1String(":") + vshl::VOICE_AGENT_ENUMERATION_VERB) << "default: " << agentId; - - objIt = dataObj.find(vshl::AGENTS_TAG); - if (objIt == dataObj.constEnd()) { - qWarning() << "Voice agent enumeration agents tag missing." - << dataObj; - return; - } - - // Sanity check that the default agent is actually listed - bool agentFound = false; - const QJsonArray agents = objIt.value().toArray(); - for (const QJsonValue &agent : agents) { - const QJsonObject agentObj = agent.toObject(); - auto agentIt = agentObj.find(vshl::ID_TAG); - if (agentIt == agentObj.constEnd()) - continue; - if (agentId.compare(agentIt.value().toString()) == 0) { - agentFound = true; - break; - } - } - if (!agentFound) { - qWarning() << "Default voice agent configuration not found"; - return; - } - m_agentPresent = true; - emit agentPresentChanged(); - - //Voice agent subscription------------------------------------------------------ - { - m_voiceAgentId = agentId; - const QJsonObject args { - { vshl::VOICE_AGENT_ID_ARG, agentId }, - { vshl::VOICE_AGENT_EVENTS_ARG, vshl::VOICE_AGENT_EVENTS_ARRAY } - }; - m_aglSocket->apiCall(vshl::API, vshl::SUBSCRIBE_VERB, args, - [](bool result, const QJsonValue &data) -> void { - qDebug() << (vshl::API + QLatin1String(":") + vshl::SUBSCRIBE_VERB) - << "result: " << result << " val: " << data; - }); - } - //------------------------------------------------------------------------------ - }); - }); - } - //----------------------------------------------------------------------------------------------< - - //Socket connection management------------------------------------------------------------------ - { - auto connectToBinding = [bindingUrl, this]() -> void { - m_aglSocket->open(bindingUrl); - qDebug() << "Connecting to:" << bindingUrl; - }; - connect(m_aglSocket, &AglSocketWrapper::disconnected, this, [connectToBinding]() -> void { - QTimer::singleShot(2500, connectToBinding); - }); - connectToBinding(); - } - //---------------------------------------------------------------------------------------------- - - //Speech chrome state change event handling----------------------------------------------------- - { - connect(m_aglSocket, &AglSocketWrapper::eventReceived, - this, [this](const QString &eventName, const QJsonValue &data) -> void { - if (eventName.compare(vshl::VOICE_DIALOG_STATE_EVENT + m_voiceAgentId) == 0) { - const QJsonObject dataObj = QJsonDocument::fromJson(data.toString().toUtf8()).object(); - auto objIt = dataObj.find(vshl::STATE_TAG); - if (objIt == dataObj.constEnd()) { - qWarning() << "Voice dialog state event state missing."; - return; - } - const QString stateStr = objIt.value().toString(); - if (stateStr.compare(vshl::VOICE_DIALOG_IDLE) == 0) { - setChromeState(Idle); - } else if (stateStr.compare(vshl::VOICE_DIALOG_LISTENING) == 0) { - setChromeState(Listening); - } else if (stateStr.compare(vshl::VOICE_DIALOG_THINKING) == 0) { - setChromeState(Thinking); - } else if (stateStr.compare(vshl::VOICE_DIALOG_SPEAKING) == 0) { - setChromeState(Speaking); - } else if (stateStr.compare(vshl::VOICE_DIALOG_MICROPHONEOFF) == 0) { - setChromeState(MicrophoneOff); - } - } - }); - } - //---------------------------------------------------------------------------------------------- -} - -void ChromeController::pushToTalk() -{ - m_aglSocket->apiCall(vshl::API, vshl::TAP_TO_TALK_VERB, QJsonValue(), - [](bool result, const QJsonValue &data) -> void { - qDebug() << (vshl::API + QLatin1String(":") + vshl::TAP_TO_TALK_VERB) - << "result: " << result << " val: " << data; - }); -} - -void ChromeController::setChromeState(ChromeController::ChromeState state) -{ - const char* ChromeStateNames[MicrophoneOff + 1] = { "Idle", "Listening", "Thinking", "Speaking", "MicrophoneOff" }; - - if (m_chromeState != state) { - m_chromeState = state; - emit chromeStateChanged(); - if(state <= MicrophoneOff) - qDebug() << "new state = " << ChromeStateNames[state]; - else - qDebug() << "new state = " << state; - } -} diff --git a/homescreen/src/chromecontroller.h b/homescreen/src/chromecontroller.h deleted file mode 100644 index 2a76002..0000000 --- a/homescreen/src/chromecontroller.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include -#include - -class AglSocketWrapper; -class ChromeController : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool agentPresent READ agentPresent NOTIFY agentPresentChanged) - Q_PROPERTY(int chromeState READ chromeState NOTIFY chromeStateChanged) - -public: - enum ChromeState { - Idle = 0, - Listening, - Thinking, - Speaking, - MicrophoneOff - }; - Q_ENUM(ChromeState) - - explicit ChromeController(const QUrl &bindingUrl, QObject *parent = nullptr); - bool agentPresent() const { return m_agentPresent; } - int chromeState() const { return m_chromeState; } - -public slots: - void pushToTalk(); - -signals: - void agentPresentChanged(); - void chromeStateChanged(); - -private: - void setChromeState(ChromeState state); - - AglSocketWrapper *m_aglSocket; - QString m_voiceAgentId; - bool m_agentPresent = false; - ChromeState m_chromeState = Idle; -}; diff --git a/homescreen/src/constants.h b/homescreen/src/constants.h deleted file mode 100644 index a43bf6d..0000000 --- a/homescreen/src/constants.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef CONSTANTS_H -#define CONSTANTS_H - -#include -#include -#include - -namespace vshl { -const QString API = QLatin1String("vshl-core"); -const QString VOICE_AGENT_ENUMERATION_VERB = QLatin1String("enumerateVoiceAgents"); -const QString SUBSCRIBE_VERB = QLatin1String("subscribe"); -const QString TAP_TO_TALK_VERB = QLatin1String("startListening"); - -const QString ALEXA_AGENT_NAME = QLatin1String("Alexa"); - -const QString DATA_TAG = QLatin1String("data"); -const QString RESPONSE_TAG = QLatin1String("response"); -const QString AGENTS_TAG = QLatin1String("agents"); -const QString DEFAULT_TAG = QLatin1String("default"); -const QString NAME_TAG = QLatin1String("name"); -const QString ID_TAG = QLatin1String("id"); -const QString STATE_TAG = QLatin1String("state"); - -const QString VOICE_AGENT_ID_ARG = QLatin1String("va_id"); -const QString VOICE_AGENT_EVENTS_ARG = QLatin1String("events"); -const QString VOICE_AGENT_ACTIONS_ARG = QLatin1String("actions"); - -const QJsonArray VOICE_AGENT_EVENTS_ARRAY = { - QLatin1String("voice_authstate_event"), - QLatin1String("voice_dialogstate_event"), - QLatin1String("voice_connectionstate_event") -}; - -const QString VOICE_DIALOG_STATE_EVENT = QLatin1String("vshl-core/voice_dialogstate_event#"); -const QString VOICE_DIALOG_IDLE = QLatin1String("IDLE"); -const QString VOICE_DIALOG_LISTENING = QLatin1String("LISTENING"); -const QString VOICE_DIALOG_THINKING = QLatin1String("THINKING"); -const QString VOICE_DIALOG_SPEAKING = QLatin1String("SPEAKING"); -const QString VOICE_DIALOG_MICROPHONEOFF = QLatin1String("MICROPHONEOFF"); -} - -#endif // CONSTANTS_H diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index 5c819f9..5f283fb 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -32,7 +32,6 @@ #include "mastervolume.h" #include "homescreenhandler.h" #include "hmi-debug.h" -#include "chromecontroller.h" // XXX: We want this DBus connection to be shared across the different // QML objects, is there another way to do this, a nice way, perhaps? @@ -92,8 +91,6 @@ int main(int argc, char *argv[]) // qmlRegisterType("HomeScreen", 1, 0, "ApplicationLauncher"); qmlRegisterType("HomeScreen", 1, 0, "StatusBarModel"); qmlRegisterType("MasterVolume", 1, 0, "MasterVolume"); - qmlRegisterUncreatableType("SpeechChrome", 1, 0, "SpeechChromeController", - QLatin1String("SpeechChromeController is uncreatable.")); ApplicationLauncher *launcher = new ApplicationLauncher(); QLibWindowmanager* layoutHandler = new QLibWindowmanager(); @@ -143,7 +140,6 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("launcher", launcher); engine.rootContext()->setContextProperty("weather", new Weather(bindingAddress)); engine.rootContext()->setContextProperty("bluetooth", new Bluetooth(bindingAddress, engine.rootContext())); - engine.rootContext()->setContextProperty("speechChromeController", new ChromeController(bindingAddress, &engine)); engine.rootContext()->setContextProperty("screenInfo", &screenInfo); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/package/config.xml b/package/config.xml index 441cc8d..3ebe39b 100644 --- a/package/config.xml +++ b/package/config.xml @@ -13,7 +13,6 @@ - -- cgit 1.2.3-korg