Merge lp:~bhdouglass/rockwork/start-js into lp:rockwork

Proposed by Brian Douglass
Status: Merged
Merged at revision: 92
Proposed branch: lp:~bhdouglass/rockwork/start-js
Merge into: lp:rockwork
Diff against target: 120 lines (+28/-6)
4 files modified
rockworkd/libpebble/appmsgmanager.cpp (+24/-4)
rockworkd/libpebble/appmsgmanager.h (+2/-0)
rockworkd/libpebble/jskit/jskitmanager.cpp (+1/-1)
rockworkd/libpebble/pebble.cpp (+1/-1)
To merge this branch: bzr merge lp:~bhdouglass/rockwork/start-js
Reviewer Review Type Date Requested Status
Michael Zanetti Pending
Review via email: mp+285885@code.launchpad.net

Description of the change

Make sure jskit is launched or killed when connection changes

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'rockworkd/libpebble/appmsgmanager.cpp'
2--- rockworkd/libpebble/appmsgmanager.cpp 2016-01-10 22:35:04 +0000
3+++ rockworkd/libpebble/appmsgmanager.cpp 2016-02-12 14:53:50 +0000
4@@ -11,10 +11,17 @@
5 : QObject(pebble),
6 m_pebble(pebble),
7 apps(apps),
8- m_connection(connection), _lastTransactionId(0), _timeout(new QTimer(this))
9+ m_connection(connection),
10+ _lastTransactionId(0),
11+ m_currentUuid(QUuid()),
12+ _timeout(new QTimer(this))
13 {
14 connect(m_connection, &WatchConnection::watchConnected,
15 this, &AppMsgManager::handleWatchConnectedChanged);
16+ connect(m_connection, &WatchConnection::watchDisconnected,
17+ this, &AppMsgManager::handleWatchConnectedChanged);
18+ connect(m_pebble, &Pebble::pebbleConnected,
19+ this, &AppMsgManager::handlePebbleConnected);
20
21 _timeout->setSingleShot(true);
22 _timeout->setInterval(3000);
23@@ -250,7 +257,9 @@
24 QByteArray ba;
25 WatchDataWriter writer(&ba);
26 writer.write<quint8>(messageType);
27- writer.writeUuid(uuid);
28+ if (!uuid.isNull()) {
29+ writer.writeUuid(uuid);
30+ }
31
32 return ba;
33 }
34@@ -282,6 +291,7 @@
35 switch (data.at(0)) {
36 case LauncherActionStart:
37 qDebug() << "App starting in watch:" << uuid;
38+ m_currentUuid = uuid;
39 emit appStarted(uuid);
40 break;
41 case LauncherActionStop:
42@@ -317,6 +327,7 @@
43 case LauncherActionStart:
44 qDebug() << "App starting in watch:" << uuid;
45 m_connection->writeToPebble(WatchConnection::EndpointLauncher, buildAckMessage(transaction));
46+ m_currentUuid = uuid;
47 emit appStarted(uuid);
48 break;
49 case LauncherActionStop:
50@@ -412,13 +423,22 @@
51
52 void AppMsgManager::handleWatchConnectedChanged()
53 {
54- // If the watch is disconnected, everything breaks loose
55- // TODO In the future we may want to avoid doing the following.
56 if (!m_connection->isConnected()) {
57+ emit appStopped(m_currentUuid);
58+
59+ // If the watch is disconnected, everything breaks loose
60+ // TODO In the future we may want to avoid doing the following.
61+
62 abortPendingTransactions();
63 }
64 }
65
66+void AppMsgManager::handlePebbleConnected()
67+{
68+ //Now that we have all the info from the pebble "relaunch" the current app
69+ emit appStarted(m_currentUuid);
70+}
71+
72 void AppMsgManager::handleTimeout()
73 {
74 // Abort the first transaction
75
76=== modified file 'rockworkd/libpebble/appmsgmanager.h'
77--- rockworkd/libpebble/appmsgmanager.h 2016-02-08 03:33:46 +0000
78+++ rockworkd/libpebble/appmsgmanager.h 2016-02-12 14:53:50 +0000
79@@ -67,6 +67,7 @@
80
81 private slots:
82 void handleWatchConnectedChanged();
83+ void handlePebbleConnected();
84 void handleTimeout();
85
86 void handleAppLaunchMessage(const QByteArray &data);
87@@ -79,6 +80,7 @@
88 WatchConnection *m_connection;
89 QHash<QUuid, MessageHandlerFunc> _handlers;
90 quint8 _lastTransactionId;
91+ QUuid m_currentUuid;
92
93 struct PendingTransaction {
94 quint8 transactionId;
95
96=== modified file 'rockworkd/libpebble/jskit/jskitmanager.cpp'
97--- rockworkd/libpebble/jskit/jskitmanager.cpp 2016-02-06 05:59:29 +0000
98+++ rockworkd/libpebble/jskit/jskitmanager.cpp 2016-02-12 14:53:50 +0000
99@@ -82,7 +82,7 @@
100 void JSKitManager::handleAppStarted(const QUuid &uuid)
101 {
102 AppInfo info = m_apps->info(uuid);
103- if (!info.uuid().isNull() && info.isJSKit()) {
104+ if (!info.uuid().isNull() && info.isJSKit() && info.uuid() != m_curApp.uuid()) {
105 qCDebug(l) << "Preparing to start JSKit app" << info.uuid() << info.shortName();
106
107 m_curApp = info;
108
109=== modified file 'rockworkd/libpebble/pebble.cpp'
110--- rockworkd/libpebble/pebble.cpp 2016-02-11 23:54:34 +0000
111+++ rockworkd/libpebble/pebble.cpp 2016-02-12 14:53:50 +0000
112@@ -536,7 +536,7 @@
113 qDebug() << "Is Unfaithful" << m_isUnfaithful;
114
115 // This is useful for debugging
116- m_isUnfaithful = true;
117+ //m_isUnfaithful = true;
118
119 if (!m_recovery) {
120 m_appManager->rescan();

Subscribers

People subscribed via source and target branches