Merge lp:~unity-api-team/indicator-network/hotspot-cellular-enabled-properties into lp:indicator-network/15.10

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 518
Merged at revision: 525
Proposed branch: lp:~unity-api-team/indicator-network/hotspot-cellular-enabled-properties
Merge into: lp:indicator-network/15.10
Diff against target: 453 lines (+192/-12)
13 files modified
data/com.ubuntu.connectivity1.NetworkingStatus.xml (+3/-0)
debian/changelog (+7/-0)
debian/control (+1/-3)
src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp (+18/-0)
src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h (+10/-0)
src/indicator/connectivity-service/connectivity-service.cpp (+29/-0)
src/indicator/connectivity-service/connectivity-service.h (+6/-0)
src/indicator/nmofono/hotspot-manager.cpp (+27/-0)
src/indicator/nmofono/hotspot-manager.h (+8/-0)
src/indicator/nmofono/manager-impl.cpp (+54/-9)
src/indicator/nmofono/manager-impl.h (+4/-0)
src/indicator/nmofono/manager.h (+10/-0)
tests/integration/test-connectivity-api.cpp (+15/-0)
To merge this branch: bzr merge lp:~unity-api-team/indicator-network/hotspot-cellular-enabled-properties
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Needs Resubmitting
Indicator Applet Developers Pending
Review via email: mp+268775@code.launchpad.net

Commit message

Add properties to determine if modems and hotspot functionality are available.

Description of the change

Add properties to determine if modems and hotspot functionality are available.

To post a comment you must log in.
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Does this scale at all? We should be making determinations about what device can have hotspot based on its capabilities—not the device name (are there no flo devices with modems, e.g.?)

I think this also makes the API ambiguous: we now have hotspotEnabled, hotspotSwitchEnabled, hotspotAvailable and hotspotStored. To be blunt, we'd need a logical matrix to determine what to show as enabled/disabled/populated/N/A in the UI.

For mako, we should try to fix the actual bugs that are causing the hotspot to fail, and for flo wee need enumerated capabilities from somewhere (SDK) in order to hide the hotspot (and cellular, phone) entry.

review: Disapprove
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

After some discussions with Ken, I'd be happy with a resubmit with modemsAvailable only. We can use this property in System Settings to show/hide panels that require a modem (Cellular and Hotspot) when one is present.

hotspotAvailable would then be unnecessary due to the fact that the indicator would just have to know whether or not a hotspot is stored—not if it is able to be created (which is always done in System Settings). And you can't create a hotspot in System Settings if there are no modems.

This will also hide the Hotspot and Cellular entries on flo. For mako, we'll just have to support it.

Hope that makes more sense.

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.ubuntu.connectivity1.NetworkingStatus.xml'
2--- data/com.ubuntu.connectivity1.NetworkingStatus.xml 2015-08-12 15:56:35 +0000
3+++ data/com.ubuntu.connectivity1.NetworkingStatus.xml 2015-08-21 15:55:11 +0000
4@@ -9,6 +9,9 @@
5 <property name="FlightMode" type="b" access="read"/>
6 <property name="WifiEnabled" type="b" access="read"/>
7
8+ <property name="ModemAvailable" type="b" access="read"/>
9+ <property name="HotspotAvailable" type="b" access="read"/>
10+
11 <property name="HotspotSsid" type="ay" access="read"/>
12 <property name="HotspotEnabled" type="b" access="read"/>
13 <property name="HotspotMode" type="s" access="read"/>
14
15=== modified file 'debian/changelog'
16--- debian/changelog 2015-08-18 08:46:30 +0000
17+++ debian/changelog 2015-08-21 15:55:11 +0000
18@@ -1,3 +1,10 @@
19+indicator-network (0.5.4-0ubuntu0) UNRELEASED; urgency=medium
20+
21+ * Add properties to determine if modems and hotspot functionality are
22+ available. (LP: #1487158) (LP: #1487157)
23+
24+ -- Pete Woods <pete.woods@canonical.com> Fri, 21 Aug 2015 16:51:14 +0100
25+
26 indicator-network (0.5.3+15.10.20150818-0ubuntu1) wily; urgency=medium
27
28 [ Pete Woods ]
29
30=== modified file 'debian/control'
31--- debian/control 2015-08-03 13:27:40 +0000
32+++ debian/control 2015-08-21 15:55:11 +0000
33@@ -32,7 +32,7 @@
34 qtdeclarative5-dev,
35 qtdeclarative5-dev-tools,
36 valgrind [amd64 armhf i386 powerpc],
37-Standards-Version: 3.9.3
38+Standards-Version: 3.9.5
39 # If you aren't a member of ~indicator-applet-developers but need to upload
40 # packaging changes, just go ahead. ~indicator-applet-developers will notice
41 # and sync up the code again.
42@@ -89,8 +89,6 @@
43 Depends: ${misc:Depends},
44 ${shlibs:Depends},
45 indicator-network (>= ${source:Version}),
46-Recommends:
47- indicator-network (>= 0.5.1+14.10.20140819),
48 Description: Ubuntu Connectivity Qt API
49 Ubuntu Connectivity API - Qt bindings
50
51
52=== modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp'
53--- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2015-08-16 16:43:16 +0000
54+++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2015-08-21 15:55:11 +0000
55@@ -130,6 +130,14 @@
56 Q_EMIT p.statusUpdated(status);
57 Q_EMIT p.onlineUpdated(status == Status::Online);
58 }
59+ else if (name == "ModemAvailable")
60+ {
61+ Q_EMIT p.modemAvailableUpdated(value.toBool());
62+ }
63+ else if (name == "HotspotAvailable")
64+ {
65+ Q_EMIT p.hotspotAvailableUpdated(value.toBool());
66+ }
67 else if (name == "HotspotEnabled")
68 {
69 Q_EMIT p.hotspotEnabledUpdated(value.toBool());
70@@ -285,6 +293,16 @@
71 return d->m_writePropertyCache->get("HotspotPassword").toString();
72 }
73
74+bool Connectivity::hotspotAvailable() const
75+{
76+ return d->m_propertyCache->get("HotspotAvailable").toBool();
77+}
78+
79+bool Connectivity::modemAvailable() const
80+{
81+ return d->m_propertyCache->get("ModemAvailable").toBool();
82+}
83+
84 bool Connectivity::hotspotEnabled() const
85 {
86 return d->m_propertyCache->get("HotspotEnabled").toBool();
87
88=== modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h'
89--- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2015-08-14 16:03:42 +0000
90+++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2015-08-21 15:55:11 +0000
91@@ -108,6 +108,12 @@
92 Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)
93 bool hotspotSwitchEnabled() const;
94
95+ Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableUpdated)
96+ bool modemAvailable() const;
97+
98+ Q_PROPERTY(bool hotspotAvailable READ hotspotAvailable NOTIFY hotspotAvailableUpdated)
99+ bool hotspotAvailable() const;
100+
101 Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated)
102 QByteArray hotspotSsid() const;
103
104@@ -164,6 +170,10 @@
105
106 void hotspotPasswordUpdated(const QString& password);
107
108+ void modemAvailableUpdated(bool);
109+
110+ void hotspotAvailableUpdated(bool);
111+
112 void hotspotEnabledUpdated(bool);
113
114 void hotspotModeUpdated(const QString& mode);
115
116=== modified file 'src/indicator/connectivity-service/connectivity-service.cpp'
117--- src/indicator/connectivity-service/connectivity-service.cpp 2015-08-17 15:38:34 +0000
118+++ src/indicator/connectivity-service/connectivity-service.cpp 2015-08-21 15:55:11 +0000
119@@ -112,6 +112,22 @@
120 { "HotspotSsid" });
121 }
122
123+ void modemAvailableUpdated()
124+ {
125+ notifyPropertyChanged(p,
126+ DBusTypes::SERVICE_PATH,
127+ DBusTypes::SERVICE_INTERFACE,
128+ { "ModemAvailable" });
129+ }
130+
131+ void hotspotAvailableUpdated()
132+ {
133+ notifyPropertyChanged(p,
134+ DBusTypes::SERVICE_PATH,
135+ DBusTypes::SERVICE_INTERFACE,
136+ { "HotspotAvailable" });
137+ }
138+
139 void hotspotEnabledUpdated()
140 {
141 notifyPropertyChanged(p,
142@@ -207,6 +223,9 @@
143 connect(d->m_manager.get(), &Manager::wifiEnabledUpdated, d.get(), &Private::wifiEnabledUpdated);
144 connect(d->m_manager.get(), &Manager::unstoppableOperationHappeningUpdated, d.get(), &Private::unstoppableOperationHappeningUpdated);
145
146+ connect(d->m_manager.get(), &Manager::modemAvailableChanged, d.get(), &Private::modemAvailableUpdated);
147+ connect(d->m_manager.get(), &Manager::hotspotAvailableChanged, d.get(), &Private::hotspotAvailableUpdated);
148+
149 connect(d->m_manager.get(), &Manager::hotspotEnabledChanged, d.get(), &Private::hotspotEnabledUpdated);
150 connect(d->m_manager.get(), &Manager::hotspotSsidChanged, d.get(), &Private::hotspotSsidUpdated);
151 connect(d->m_manager.get(), &Manager::hotspotPasswordChanged, d.get(), &Private::hotspotPasswordUpdated);
152@@ -275,6 +294,16 @@
153 && !d->m_manager->flightMode();
154 }
155
156+bool ConnectivityService::modemAvailable() const
157+{
158+ return d->m_manager->modemAvailable();
159+}
160+
161+bool ConnectivityService::hotspotAvailable() const
162+{
163+ return d->m_manager->hotspotAvailable();
164+}
165+
166 bool ConnectivityService::hotspotEnabled() const
167 {
168 return d->m_manager->hotspotEnabled();
169
170=== modified file 'src/indicator/connectivity-service/connectivity-service.h'
171--- src/indicator/connectivity-service/connectivity-service.h 2015-08-14 10:29:55 +0000
172+++ src/indicator/connectivity-service/connectivity-service.h 2015-08-21 15:55:11 +0000
173@@ -65,6 +65,12 @@
174 Q_PROPERTY(bool HotspotSwitchEnabled READ hotspotSwitchEnabled)
175 bool hotspotSwitchEnabled() const;
176
177+ Q_PROPERTY(bool ModemAvailable READ modemAvailable)
178+ bool modemAvailable() const;
179+
180+ Q_PROPERTY(bool HotspotAvailable READ hotspotAvailable)
181+ bool hotspotAvailable() const;
182+
183 Q_PROPERTY(bool HotspotEnabled READ hotspotEnabled)
184 bool hotspotEnabled() const;
185
186
187=== modified file 'src/indicator/nmofono/hotspot-manager.cpp'
188--- src/indicator/nmofono/hotspot-manager.cpp 2015-08-17 11:01:23 +0000
189+++ src/indicator/nmofono/hotspot-manager.cpp 2015-08-21 15:55:11 +0000
190@@ -216,6 +216,27 @@
191 return index >= 0;
192 }
193
194+ bool isKnownBadHardware()
195+ {
196+ const static QSet<QString> KNOWN_BAD_HARDWARE {"mako", "flo"};
197+
198+ QString program("getprop");
199+ QStringList arguments;
200+ arguments << "ro.hardware";
201+
202+ QProcess getprop;
203+ getprop.start(program, arguments);
204+
205+ if (!getprop.waitForFinished())
206+ {
207+ qCritical() << "getprop process failed:" << getprop.errorString();
208+ return false;
209+ }
210+
211+ QString hardware = QString::fromUtf8(getprop.readAllStandardOutput()).trimmed();
212+ return KNOWN_BAD_HARDWARE.contains(hardware);
213+ }
214+
215 /**
216 * True if changed successfully, or there was no need. Otherwise false.
217 * Supported modes are 'p2p', 'sta' and 'ap'.
218@@ -636,6 +657,7 @@
219 QPowerd::RequestSPtr m_wakelock;
220
221 bool m_isHybrisWlan = false;
222+ bool m_isKnownBadHardware = false;
223 bool m_disconnectWifi = false;
224
225 /**
226@@ -661,6 +683,7 @@
227 QObject(parent), d(new Priv(*this))
228 {
229 d->m_isHybrisWlan = d->isHybrisWlan();
230+ d->m_isKnownBadHardware = d->isKnownBadHardware();
231
232 d->m_manager = make_unique<OrgFreedesktopNetworkManagerInterface>(
233 NM_DBUS_SERVICE, NM_DBUS_PATH, connection);
234@@ -780,6 +803,10 @@
235
236 }
237
238+bool HotspotManager::knownBadHardware() const {
239+ return d->m_isKnownBadHardware;
240+}
241+
242 bool HotspotManager::enabled() const {
243 return d->m_enabled;
244 }
245
246=== modified file 'src/indicator/nmofono/hotspot-manager.h'
247--- src/indicator/nmofono/hotspot-manager.h 2015-08-17 11:01:23 +0000
248+++ src/indicator/nmofono/hotspot-manager.h 2015-08-21 15:55:11 +0000
249@@ -118,6 +118,10 @@
250 READ disconnectWifi
251 NOTIFY disconnectWifiChanged)
252
253+ Q_PROPERTY( bool knownBadHardware
254+ READ knownBadHardware
255+ NOTIFY knownBadHardwareChanged)
256+
257 public:
258 typedef std::shared_ptr<HotspotManager> SPtr;
259
260@@ -137,6 +141,8 @@
261
262 bool disconnectWifi() const;
263
264+ bool knownBadHardware() const;
265+
266 Q_SIGNALS:
267 void enabledChanged(bool enabled);
268
269@@ -150,6 +156,8 @@
270
271 void disconnectWifiChanged(bool disconnect);
272
273+ void knownBadHardwareChanged(bool knownBadHardware);
274+
275 /*
276 * The mapping of code to string is taken from
277 * http://bazaar.launchpad.net/~vcs-imports/
278
279=== modified file 'src/indicator/nmofono/manager-impl.cpp'
280--- src/indicator/nmofono/manager-impl.cpp 2015-08-18 08:39:29 +0000
281+++ src/indicator/nmofono/manager-impl.cpp 2015-08-21 15:55:11 +0000
282@@ -69,6 +69,9 @@
283 bool m_wifiEnabled = false;
284 KillSwitch::Ptr m_killSwitch;
285
286+ bool m_modemAvailable = false;
287+ bool m_hotspotAvailable = false;
288+
289 QSet<Link::Ptr> m_nmLinks;
290 QMap<QString, wwan::Modem::Ptr> m_ofonoLinks;
291
292@@ -144,6 +147,32 @@
293 Q_EMIT p.wifiEnabledUpdated(m_wifiEnabled);
294 }
295
296+ void updateModemAvailable()
297+ {
298+ bool modemAvailable = !m_ofonoLinks.empty();
299+
300+ if (m_modemAvailable == modemAvailable)
301+ {
302+ return;
303+ }
304+
305+ m_modemAvailable = modemAvailable;
306+ Q_EMIT p.modemAvailableChanged(m_modemAvailable);
307+ }
308+
309+ void updateHotspotAvailable()
310+ {
311+ bool hotspotAvailable = !m_ofonoLinks.empty() && !m_hotspotManager->knownBadHardware();
312+
313+ if (m_hotspotAvailable == hotspotAvailable)
314+ {
315+ return;
316+ }
317+
318+ m_hotspotAvailable = hotspotAvailable;
319+ Q_EMIT p.hotspotAvailableChanged(m_hotspotAvailable);
320+ }
321+
322 void setFlightMode(bool newStatus)
323 {
324 if (m_flightMode == newStatus)
325@@ -211,6 +240,9 @@
326
327 Q_EMIT p.linksUpdated();
328 m_unlockDialog->setShowSimIdentifiers(m_ofonoLinks.size() > 1);
329+
330+ updateModemAvailable();
331+ updateHotspotAvailable();
332 }
333 };
334
335@@ -250,6 +282,16 @@
336 d->m_unlockDialog = make_shared<SimUnlockDialog>(notificationManager);
337 connect(d->m_unlockDialog.get(), &SimUnlockDialog::ready, d.get(), &Private::sim_unlock_ready);
338
339+ d->m_hotspotManager = make_shared<HotspotManager>(systemConnection);
340+ connect(d->m_hotspotManager.get(), &HotspotManager::enabledChanged, this, &Manager::hotspotEnabledChanged);
341+ connect(d->m_hotspotManager.get(), &HotspotManager::ssidChanged, this, &Manager::hotspotSsidChanged);
342+ connect(d->m_hotspotManager.get(), &HotspotManager::passwordChanged, this, &Manager::hotspotPasswordChanged);
343+ connect(d->m_hotspotManager.get(), &HotspotManager::modeChanged, this, &Manager::hotspotModeChanged);
344+ connect(d->m_hotspotManager.get(), &HotspotManager::storedChanged, this, &Manager::hotspotStoredChanged);
345+ connect(d->m_hotspotManager.get(), &HotspotManager::knownBadHardwareChanged, d.get(), &Private::updateHotspotAvailable);
346+
347+ connect(d->m_hotspotManager.get(), &HotspotManager::reportError, this, &Manager::reportError);
348+
349 d->m_ofono = make_shared<QOfonoManager>();
350 connect(d->m_ofono.get(), &QOfonoManager::modemsChanged, d.get(), &Private::modems_changed);
351 d->modems_changed(d->m_ofono->modems());
352@@ -262,15 +304,6 @@
353 d->m_killSwitch = make_shared<KillSwitch>(systemConnection);
354 connect(d->m_killSwitch.get(), &KillSwitch::stateChanged, d.get(), &Private::updateHasWifi);
355
356- d->m_hotspotManager = make_shared<HotspotManager>(systemConnection);
357- connect(d->m_hotspotManager.get(), &HotspotManager::enabledChanged, this, &Manager::hotspotEnabledChanged);
358- connect(d->m_hotspotManager.get(), &HotspotManager::ssidChanged, this, &Manager::hotspotSsidChanged);
359- connect(d->m_hotspotManager.get(), &HotspotManager::passwordChanged, this, &Manager::hotspotPasswordChanged);
360- connect(d->m_hotspotManager.get(), &HotspotManager::modeChanged, this, &Manager::hotspotModeChanged);
361- connect(d->m_hotspotManager.get(), &HotspotManager::storedChanged, this, &Manager::hotspotStoredChanged);
362-
363- connect(d->m_hotspotManager.get(), &HotspotManager::reportError, this, &Manager::reportError);
364-
365 connect(d->nm.get(), &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &ManagerImpl::device_added);
366 QList<QDBusObjectPath> devices(d->nm->GetDevices());
367 for(const auto &path : devices) {
368@@ -324,6 +357,18 @@
369 }
370
371 bool
372+ManagerImpl::modemAvailable() const
373+{
374+ return !d->m_ofonoLinks.empty();
375+}
376+
377+bool
378+ManagerImpl::hotspotAvailable() const
379+{
380+ return !d->m_hotspotManager->knownBadHardware();
381+}
382+
383+bool
384 ManagerImpl::hotspotEnabled() const
385 {
386 return d->m_hotspotManager->enabled();
387
388=== modified file 'src/indicator/nmofono/manager-impl.h'
389--- src/indicator/nmofono/manager-impl.h 2015-08-14 15:52:39 +0000
390+++ src/indicator/nmofono/manager-impl.h 2015-08-21 15:55:11 +0000
391@@ -71,6 +71,10 @@
392 void unlockAllModems() override;
393 void unlockModemByName(const QString &name) override;
394
395+ bool modemAvailable() const override;
396+
397+ bool hotspotAvailable() const override;
398+
399 bool hotspotEnabled() const override;
400
401 bool hotspotStored() const override;
402
403=== modified file 'src/indicator/nmofono/manager.h'
404--- src/indicator/nmofono/manager.h 2015-08-14 15:52:39 +0000
405+++ src/indicator/nmofono/manager.h 2015-08-21 15:55:11 +0000
406@@ -122,6 +122,12 @@
407
408 virtual void unlockModemByName(const QString &name) = 0;
409
410+ Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableChanged)
411+ virtual bool modemAvailable() const = 0;
412+
413+ Q_PROPERTY(bool hotspotAvailable READ hotspotAvailable NOTIFY hotspotAvailableChanged)
414+ virtual bool hotspotAvailable() const = 0;
415+
416 Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledChanged)
417 virtual bool hotspotEnabled() const = 0;
418
419@@ -150,6 +156,10 @@
420
421 void wifiEnabledUpdated(bool);
422
423+ void modemAvailableChanged(bool);
424+
425+ void hotspotAvailableChanged(bool);
426+
427 void hotspotEnabledChanged(bool enabled);
428
429 void hotspotStoredChanged(bool stored);
430
431=== modified file 'tests/integration/test-connectivity-api.cpp'
432--- tests/integration/test-connectivity-api.cpp 2015-08-17 15:38:34 +0000
433+++ tests/integration/test-connectivity-api.cpp 2015-08-21 15:55:11 +0000
434@@ -630,4 +630,19 @@
435 }
436 }
437
438+TEST_F(TestConnectivityApi, HotspotModemAvailable)
439+{
440+ setGlobalConnectedState(NM_STATE_DISCONNECTED);
441+ auto device = createWiFiDevice(NM_DEVICE_STATE_DISCONNECTED);
442+
443+ // Start the indicator
444+ ASSERT_NO_THROW(startIndicator());
445+
446+ // Connect the the service
447+ auto connectivity(newConnectivity());
448+
449+ EXPECT_TRUE(connectivity->hotspotAvailable());
450+ EXPECT_TRUE(connectivity->modemAvailable());
451+}
452+
453 }

Subscribers

People subscribed via source and target branches