From a24034bdfea259cdc09c74217be75d4f9de0dce5 Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 28 Dec 2015 04:31:57 +0100 Subject: trying list of apps in host xml --- hostmanagerconn.cc | 64 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 7 deletions(-) (limited to 'hostmanagerconn.cc') diff --git a/hostmanagerconn.cc b/hostmanagerconn.cc index 1f87ef2..0e1f7bb 100644 --- a/hostmanagerconn.cc +++ b/hostmanagerconn.cc @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -10,6 +11,7 @@ static watchfish::WallTimeMonitor *monitor = 0; #endif +#include "sapmanager.h" #include "sappeer.h" #include "hostmanagerconn.h" @@ -23,6 +25,16 @@ HostManagerConn::HostManagerConn(SAPConnection *conn, QObject *parent) connect(_socket, SIGNAL(messageReceived()), SLOT(handleMessageReceived())); } +HostManagerConn::DeviceInfo HostManagerConn::parseDeviceInfo(const QString &xmlData) +{ + QXmlStreamReader r(xmlData); + DeviceInfo info; + + // TODO + + return info; +} + void HostManagerConn::sendMessage(const QJsonObject &msg) { QJsonDocument doc(msg); @@ -37,10 +49,15 @@ void HostManagerConn::handleMessage(const QJsonObject &msg) qDebug() << "Got JSON msg" << msgId; if (msgId == "mgr_watch_info_res") { QJsonObject reply; - reply["timestamp"] = QLatin1String("1407542281196=B:L>:<=LAMO"); + QDateTime timestamp = QLocale("C").toDateTime(QString::fromLatin1(__DATE__ " " __TIME__).simplified(), + "MMM d yyyy HH:mm:ss"); + reply["timestamp"] = QString("%1_%2").arg(timestamp.toTime_t()) + .arg(_conn->peer()->localName().right(2)); reply["type"] = QLatin1String("connect"); reply["msgId"] = QLatin1String("mgr_wearable_status_req"); sendMessage(reply); + } else if (msgId == "mgr_wearable_status_res") { + // Do nothing; watch will next ask for host status } else if (msgId == "mgr_host_status_req") { QJsonObject reply; reply["type"] = QLatin1String("connect"); @@ -72,14 +89,14 @@ void HostManagerConn::performTimeSync() msg["safety_voice"] = QLatin1String("0"); msg["safetyVersion"] = QLatin1String("0"); msg["safety"] = QLatin1String("false"); - msg["tablet"] = QLatin1String("true"); + msg["tablet"] = QLatin1String("false"); msg["incomingCall"] = QLatin1String("false"); msg["usingCamera"] = QLatin1String("false"); msg["safety_cam"] = QLatin1String("0"); QLocale l = QLocale::system(); msg["locale"] = l.name(); // i.e. es_ES - msg["data1224"] = l.timeFormat().contains('a', Qt::CaseInsensitive) ? QLatin1String("12") : QLatin1String("24"); + msg["date1224"] = l.timeFormat().contains('a', Qt::CaseInsensitive) ? QLatin1String("12") : QLatin1String("24"); msg["dateformat"] = QLocale::system().dateFormat(QLocale::ShortFormat); #if SAILFISH @@ -113,16 +130,49 @@ QString HostManagerConn::generateHostXml() w.writeTextElement("devicePlatform", "android"); w.writeTextElement("devicePlatformVersion", "4.4.2"); w.writeTextElement("deviceType", "Host"); - w.writeTextElement("modelNumber", "EvilPhone"); - w.writeTextElement("swVersion", "1.0"); + w.writeTextElement("modelNumber", "GT-I9500"); + w.writeTextElement("swVersion", "android 4.4.2"); w.writeEmptyElement("connectivity"); - w.writeEmptyElement("apps"); + +#if 0 + w.writeStartElement("apps"); + SAPManager *manager = SAPManager::instance(); + foreach (const SAPManager::RegisteredApplication &app, manager->allPackages()) { + w.writeStartElement("app"); + w.writeTextElement("name", app.name); + w.writeTextElement("packagename", app.package); + w.writeTextElement("version", QString::number(app.version)); + w.writeTextElement("preloaded", app.preinstalled ? QLatin1String("true") : QLatin1String("false")); + w.writeTextElement("isAppWidget", "false"); + w.writeStartElement("features"); + w.writeTextElement("Installed", "true"); + w.writeEndElement(); + w.writeEndElement(); + } + w.writeEndElement(); +#else + xml.append(QString::fromLatin1("" + "Actualizar el software del Gearcom.sec.android.fotaprovider2falsefalse" + "ConnectionManagercom.sec.android.service.connectionmanager1004falsefalse" + "goproviderscom.samsung.accessory.goproviders61falsefalse" + "SAFileTransferCorecom.samsung.accessory.safiletransfer1falsefalse" + "SANotiProvidercom.samsung.accessory.sanotiprovider1falsefalse" + "saproviderscom.samsung.accessory.saproviders64falsefalseTextTemplateProvidercom.samsung.accessory.texttemplateprovider1300falsefalse" + "com.samsung.accessory.saproviders64com.samsung.w-calendar2truecom.samsung.accessory.goproviders61com.samsung.wfmdtrue" + "com.sec.android.weatherprovidercom.samsung.weatherfalse" + "com.samsung.accessory.goproviders61com.samsung.w-contacts2truecom.samsung.accessory.saproviders64com.samsung.w-media-controllertrue" + "com.samsung.accessory.saproviders64com.samsung.alarmtruecom.samsung.accessory.saproviders64com.samsung.messagetrue" + "com.samsung.accessory.saproviders64com.samsung.w-logs2truecom.samsung.accessory.saproviders64com.samsung.idle-clock-eventtrue" + "com.sec.android.weatherprovidercom.samsung.w-idle-clock-weather2falsecom.samsung.accessory.saproviders64com.samsung.idle-clock-dualtrue" + "com.samsung.accessory.saproviders64com.samsung.svoice-wtrue" + "")); +#endif w.writeStartElement("deviceFeature"); w.writeTextElement("telephony", "true"); w.writeTextElement("messaging", "true"); - w.writeTextElement("tablet", "true"); + w.writeTextElement("tablet", "false"); w.writeTextElement("autolock", "true"); w.writeTextElement("smartrelay", "true"); w.writeTextElement("safetyassistance", "false"); -- cgit v1.2.3