summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-12-28 04:31:57 +0100
committerJavier <dev.git@javispedro.com>2015-12-28 04:31:57 +0100
commita24034bdfea259cdc09c74217be75d4f9de0dce5 (patch)
treed5caed7e9f437ecdde4755bd1dd13594e6cc11d4
parentd14723bc3ec4c96ed02a08d1ff74c25e88225ef6 (diff)
downloadsapd-a24034bdfea259cdc09c74217be75d4f9de0dce5.tar.gz
sapd-a24034bdfea259cdc09c74217be75d4f9de0dce5.zip
trying list of apps in host xml
-rw-r--r--capabilitypeer.cc2
-rw-r--r--hostmanagerconn.cc64
-rw-r--r--hostmanagerconn.h35
-rw-r--r--main.cc5
-rw-r--r--rpm/sapd.yaml2
-rw-r--r--sapmanager.cc30
-rw-r--r--sapmanager.h19
7 files changed, 144 insertions, 13 deletions
diff --git a/capabilitypeer.cc b/capabilitypeer.cc
index 0290b69..8dfe603 100644
--- a/capabilitypeer.cc
+++ b/capabilitypeer.cc
@@ -169,7 +169,7 @@ void CapabilityPeer::handleMessageReceived()
break;
}
default:
- qWarning() << "Unknown message to capability socket";
+ qWarning() << "Unknown message" << int(data[0]) << "to capability socket";
break;
}
}
diff --git a/hostmanagerconn.cc b/hostmanagerconn.cc
index 1f87ef2..0e1f7bb 100644
--- a/hostmanagerconn.cc
+++ b/hostmanagerconn.cc
@@ -1,6 +1,7 @@
#include <QtCore/QDebug>
#include <QtCore/QDateTime>
#include <QtCore/QTimeZone>
+#include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamWriter>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
@@ -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("<apps>"
+ "<app><name>Actualizar el software del Gear</name><packagename>com.sec.android.fotaprovider</packagename><version>2</version><preloaded>false</preloaded><isAppWidget>false</isAppWidget><features/></app>"
+ "<app><name>ConnectionManager</name><packagename>com.sec.android.service.connectionmanager</packagename><version>1004</version><preloaded>false</preloaded><isAppWidget>false</isAppWidget><features/></app>"
+ "<app><name>goproviders</name><packagename>com.samsung.accessory.goproviders</packagename><version>61</version><preloaded>false</preloaded><isAppWidget>false</isAppWidget><features/></app>"
+ "<app><name>SAFileTransferCore</name><packagename>com.samsung.accessory.safiletransfer</packagename><version>1</version><preloaded>false</preloaded><isAppWidget>false</isAppWidget><features/></app>"
+ "<app><name>SANotiProvider</name><packagename>com.samsung.accessory.sanotiprovider</packagename><version>1</version><preloaded>false</preloaded><isAppWidget>false</isAppWidget><features/></app>"
+ "<app><name>saproviders</name><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><preloaded>false</preloaded><isAppWidget>false</isAppWidget><features/></app><app><name>TextTemplateProvider</name><packagename>com.samsung.accessory.texttemplateprovider</packagename><version>1300</version><preloaded>false</preloaded><isAppWidget>false</isAppWidget><features/></app>"
+ "<app><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><features><RequiringPackage>com.samsung.w-calendar2</RequiringPackage><Installed>true</Installed></features></app><app><packagename>com.samsung.accessory.goproviders</packagename><version>61</version><features><RequiringPackage>com.samsung.wfmd</RequiringPackage><Installed>true</Installed></features></app>"
+ "<app><packagename>com.sec.android.weatherprovider</packagename><features><RequiringPackage>com.samsung.weather</RequiringPackage><Installed>false</Installed></features></app>"
+ "<app><packagename>com.samsung.accessory.goproviders</packagename><version>61</version><features><RequiringPackage>com.samsung.w-contacts2</RequiringPackage><Installed>true</Installed></features></app><app><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><features><RequiringPackage>com.samsung.w-media-controller</RequiringPackage><Installed>true</Installed></features></app>"
+ "<app><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><features><RequiringPackage>com.samsung.alarm</RequiringPackage><Installed>true</Installed></features></app><app><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><features><RequiringPackage>com.samsung.message</RequiringPackage><Installed>true</Installed></features></app>"
+ "<app><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><features><RequiringPackage>com.samsung.w-logs2</RequiringPackage><Installed>true</Installed></features></app><app><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><features><RequiringPackage>com.samsung.idle-clock-event</RequiringPackage><Installed>true</Installed></features></app>"
+ "<app><packagename>com.sec.android.weatherprovider</packagename><features><RequiringPackage>com.samsung.w-idle-clock-weather2</RequiringPackage><Installed>false</Installed></features></app><app><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><features><RequiringPackage>com.samsung.idle-clock-dual</RequiringPackage><Installed>true</Installed></features></app>"
+ "<app><packagename>com.samsung.accessory.saproviders</packagename><version>64</version><features><RequiringPackage>com.samsung.svoice-w</RequiringPackage><Installed>true</Installed></features></app>"
+ "</apps>"));
+#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");
diff --git a/hostmanagerconn.h b/hostmanagerconn.h
index 6b89add..3543a6c 100644
--- a/hostmanagerconn.h
+++ b/hostmanagerconn.h
@@ -12,6 +12,41 @@ class HostManagerConn : public QObject
public:
HostManagerConn(SAPConnection *conn, QObject *parent = 0);
+protected:
+ struct AppInfo {
+ QString name;
+ QString packageName;
+ QString version;
+ bool preloaded;
+ bool isAppWidget;
+
+ QStringList requiredPackages;
+ QStringList requiringPackages;
+ bool installed;
+ };
+
+ struct DeviceInfo {
+ QString deviceId;
+ QString deviceName;
+ QString devicePlatform;
+ QString devicePlatformVersion;
+ QString deviceType;
+ QString modelNumber;
+ QString swVersion;
+
+ QList<AppInfo> apps;
+
+ bool telephony;
+ bool messaging;
+ bool tablet;
+ bool autolock;
+ bool smartrelay;
+ bool safetyassistence;
+ QString vendor;
+ };
+
+ static DeviceInfo parseDeviceInfo(const QString &xmlData);
+
private:
void sendMessage(const QJsonObject &obj);
diff --git a/main.cc b/main.cc
index b6538ea..207f3ff 100644
--- a/main.cc
+++ b/main.cc
@@ -44,6 +44,11 @@ int main(int argc, char *argv[])
SAPManager *manager = SAPManager::instance();
+ manager->registerApplicationPackage("com.samsung.accessory.goproviders");
+ manager->registerApplicationPackage("com.samsung.accessory.saproviders", "saproviders", 62);
+ manager->registerApplicationPackage("com.sec.android.weatherprovider");
+ manager->registerApplicationPackage("com.sec.android.fotaprovider");
+
CapabilityAgent::registerServices(manager);
HostManagerAgent::registerServices(manager);
WebProxyAgent::registerServices(manager);
diff --git a/rpm/sapd.yaml b/rpm/sapd.yaml
index 4c45974..c3c5a53 100644
--- a/rpm/sapd.yaml
+++ b/rpm/sapd.yaml
@@ -1,6 +1,6 @@
Name: sapd
Summary: Accesory protocol daemon
-Version: 0.1.1
+Version: 0.1.2
Release: 1
Group: Communications/Bluetooth
URL: https://gitorious.org/javispedro-jolla-misc/sapd/
diff --git a/sapmanager.cc b/sapmanager.cc
index ab3fcd0..9d72433 100644
--- a/sapmanager.cc
+++ b/sapmanager.cc
@@ -91,13 +91,13 @@ SAPServiceInfo SAPManager::serviceInfo(int agentId) const
return _agents.value(agentId).info;
}
-QSet<QString> SAPManager::allProfiles()
+QSet<QString> SAPManager::allProfiles() const
{
return QSet<QString>::fromList(_consumerProfiles.keys())
+ QSet<QString>::fromList(_providerProfiles.keys());
}
-QSet<SAPAgent*> SAPManager::allAgents()
+QSet<SAPAgent*> SAPManager::allAgents() const
{
QSet<SAPAgent*> agents;
foreach (const RegisteredAgent &ragent, _agents) {
@@ -106,6 +106,32 @@ QSet<SAPAgent*> SAPManager::allAgents()
return agents;
}
+void SAPManager::registerApplicationPackage(const RegisteredApplication &app)
+{
+ _pkgs.insert(app.package, app);
+}
+
+void SAPManager::registerApplicationPackage(const QString &package, const QString &name, int version, bool preinstalled)
+{
+ RegisteredApplication app;
+ app.package = package;
+ app.name = name;
+ if (app.name.isEmpty()) app.name = package;
+ app.version = version;
+ app.preinstalled = preinstalled;
+ registerApplicationPackage(app);
+}
+
+void SAPManager::unregisterApplicationPackage(const QString &package)
+{
+ _pkgs.remove(package);
+}
+
+QList<SAPManager::RegisteredApplication> SAPManager::allPackages() const
+{
+ return _pkgs.values();
+}
+
int SAPManager::findUnusedAgentId() const
{
if (_agents.size() > 20000) {
diff --git a/sapmanager.h b/sapmanager.h
index 31b84a0..5619e54 100644
--- a/sapmanager.h
+++ b/sapmanager.h
@@ -28,8 +28,21 @@ public:
SAPAgent *agent(int agentId);
SAPServiceInfo serviceInfo(int agentId) const;
- QSet<QString> allProfiles();
- QSet<SAPAgent*> allAgents();
+ QSet<QString> allProfiles() const;
+ QSet<SAPAgent*> allAgents() const;
+
+ struct RegisteredApplication {
+ QString package;
+ QString name;
+ int version;
+ bool preinstalled;
+ };
+
+ void registerApplicationPackage(const RegisteredApplication &app);
+ void registerApplicationPackage(const QString &package, const QString &name = QString(), int version = 1, bool preinstalled = false);
+ void unregisterApplicationPackage(const QString &package);
+
+ QList<RegisteredApplication> allPackages() const;
private:
int findUnusedAgentId() const;
@@ -46,6 +59,8 @@ private:
QHash<QString, int> _consumerProfiles;
QHash<QString, int> _providerProfiles;
+
+ QHash<QString, RegisteredApplication> _pkgs;
};
#endif // SAPMANAGER_H