Merge lp:~pete-woods/indicator-network/sim-unlock-debugging-lp1465214 into lp:indicator-network/15.10

Proposed by Pete Woods on 2015-06-16
Status: Merged
Approved by: Charles Kerr on 2015-06-25
Approved revision: 499
Merged at revision: 496
Proposed branch: lp:~pete-woods/indicator-network/sim-unlock-debugging-lp1465214
Merge into: lp:indicator-network/15.10
Diff against target: 211 lines (+75/-3)
4 files modified
src/indicator/nmofono/manager-impl.cpp (+24/-2)
src/indicator/nmofono/wwan/modem.cpp (+40/-0)
src/indicator/nmofono/wwan/modem.h (+6/-0)
src/indicator/sim-unlock-dialog.cpp (+5/-1)
To merge this branch: bzr merge lp:~pete-woods/indicator-network/sim-unlock-debugging-lp1465214
Reviewer Review Type Date Requested Status
Charles Kerr (community) 2015-06-16 Approve on 2015-06-25
PS Jenkins bot continuous-integration Needs Fixing on 2015-06-18
Review via email: mp+262108@code.launchpad.net

Commit Message

Wait for SIM Manager interface to be fully initialised before we try and unlock any SIMs

Description of the Change

Wait for SIM Manager interface to be fully initialised before we try and unlock any SIMs

To post a comment you must log in.
496. By Pete Woods on 2015-06-17

Wait for all SimManager properties to be set before declaring it valid

497. By Pete Woods on 2015-06-17

Log when we launch the unlock dialogue

498. By Pete Woods on 2015-06-18

Schedule the modem to tell us about the unlock, don't let it spam us

499. By Pete Woods on 2015-06-18

Just warn, rather than throw

Marcus Tomlinson (marcustomlinson) wrote :

Does this branch actually need a review? or is this just a test MP?

Charles Kerr (charlesk) :
review: Approve
Marcus Tomlinson (marcustomlinson) wrote :

I take that as a yes ;)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator/nmofono/manager-impl.cpp'
2--- src/indicator/nmofono/manager-impl.cpp 2015-04-23 10:02:23 +0000
3+++ src/indicator/nmofono/manager-impl.cpp 2015-06-18 12:30:37 +0000
4@@ -144,6 +144,15 @@
5 }
6 }
7
8+ void modemReadyToUnlock(const QString& name)
9+ {
10+ auto modem = m_ofonoLinks[name];
11+ if (modem)
12+ {
13+ p.unlockModem(modem);
14+ }
15+ }
16+
17 void modems_changed(const QStringList& value)
18 {
19 QSet<QString> modemPaths(value.toSet());
20@@ -162,6 +171,7 @@
21 {
22 m_unlockDialog->cancel();
23 m_pendingUnlocks.removeOne(modem);
24+ disconnect(modem.get(), &wwan::Modem::readyToUnlock, this, &Private::modemReadyToUnlock);
25 }
26 }
27
28@@ -172,6 +182,7 @@
29
30 auto modem = make_shared<wwan::Modem>(modemInterface);
31 m_ofonoLinks[path] = modem;
32+ connect(modem.get(), &wwan::Modem::readyToUnlock, this, &Private::modemReadyToUnlock);
33 }
34
35 Q_EMIT p.linksUpdated();
36@@ -466,10 +477,21 @@
37 return;
38
39 if (d->m_unlockDialog->state() == SimUnlockDialog::State::ready
40- && d->m_pendingUnlocks.size() == 0)
41- d->m_unlockDialog->unlock(modem);
42+ && (d->m_pendingUnlocks.size() == 0))
43+ {
44+ if (modem->isReadyToUnlock())
45+ {
46+ d->m_unlockDialog->unlock(modem);
47+ }
48+ else
49+ {
50+ modem->notifyWhenReadyToUnlock();
51+ }
52+ }
53 else
54+ {
55 d->m_pendingUnlocks.push_back(modem);
56+ }
57 } catch(const exception &e) {
58 // Something unexpected has happened. As an example, unity8 might have
59 // crashed taking the notification server with it. There is no graceful
60
61=== modified file 'src/indicator/nmofono/wwan/modem.cpp'
62--- src/indicator/nmofono/wwan/modem.cpp 2015-04-24 08:47:08 +0000
63+++ src/indicator/nmofono/wwan/modem.cpp 2015-06-18 12:30:37 +0000
64@@ -92,6 +92,10 @@
65 Modem::PinType m_requiredPin;
66 RetriesType m_retries;
67
68+ bool m_simStatusSet = false;
69+ bool m_requiredPinSet = false;
70+ bool m_retriesSet = false;
71+
72 QString m_operatorName;
73 Modem::ModemStatus m_status;
74 int8_t m_strength;
75@@ -110,6 +114,8 @@
76
77 QTimer m_updatedTimer;
78
79+ bool m_shouldTriggerUnlock = false;
80+
81 Private(Modem& parent, shared_ptr<QOfonoModem> ofonoModem)
82 : p(parent), m_ofonoModem{ofonoModem}
83 {
84@@ -142,6 +148,12 @@
85 void fireUpdate()
86 {
87 Q_EMIT p.updated(p);
88+
89+ if (p.isReadyToUnlock() && m_shouldTriggerUnlock)
90+ {
91+ m_shouldTriggerUnlock = false;
92+ Q_EMIT p.readyToUnlock(p.name());
93+ }
94 }
95
96 void connectionManagerChanged(shared_ptr<QOfonoConnectionManager> conmgr)
97@@ -249,6 +261,9 @@
98 "). Bailing out.");
99 }
100
101+ m_requiredPinSet = true;
102+
103+ bool retriesWasSet = true;
104 // update retries
105 RetriesType tmp;
106 QVariantMap retries = m_simManager->pinRetries();
107@@ -257,6 +272,10 @@
108 i.next();
109 QOfonoSimManager::PinType type = (QOfonoSimManager::PinType) i.key().toInt();
110 int count = i.value().toInt();
111+ if (count < 0)
112+ {
113+ retriesWasSet = false;
114+ }
115 switch(type)
116 {
117 case QOfonoSimManager::PinType::SimPin:
118@@ -271,6 +290,8 @@
119 }
120 setRetries(tmp);
121
122+ m_retriesSet = retriesWasSet;
123+
124 // update simStatus
125 bool present = m_simManager->present();
126 if (!present)
127@@ -294,10 +315,16 @@
128 }
129 }
130
131+ m_simStatusSet = true;
132+
133 } else {
134 setRequiredPin(PinType::none);
135 setRetries({});
136 setSimStatus(SimStatus::not_available);
137+
138+ m_requiredPinSet = false;
139+ m_retriesSet = false;
140+ m_simStatusSet = false;
141 }
142
143 if (m_networkRegistration)
144@@ -695,6 +722,19 @@
145 {
146 return 0;
147 }
148+
149+bool
150+Modem::isReadyToUnlock() const
151+{
152+ return d->m_simStatusSet && d->m_requiredPinSet && d->m_retriesSet
153+ && (d->m_requiredPin != PinType::none);
154+}
155+
156+void
157+Modem::notifyWhenReadyToUnlock()
158+{
159+ d->m_shouldTriggerUnlock = true;
160+}
161 }
162
163 }
164
165=== modified file 'src/indicator/nmofono/wwan/modem.h'
166--- src/indicator/nmofono/wwan/modem.h 2015-04-24 08:47:08 +0000
167+++ src/indicator/nmofono/wwan/modem.h 2015-06-18 12:30:37 +0000
168@@ -144,6 +144,10 @@
169
170 Id id() const override;
171
172+ bool isReadyToUnlock() const;
173+
174+ void notifyWhenReadyToUnlock();
175+
176 Q_SIGNALS:
177 void onlineUpdated(bool);
178
179@@ -174,6 +178,8 @@
180 void resetPinSuceeded();
181
182 void resetPinFailed(const QString& error);
183+
184+ bool readyToUnlock(const QString& name);
185 };
186
187 }
188
189=== modified file 'src/indicator/sim-unlock-dialog.cpp'
190--- src/indicator/sim-unlock-dialog.cpp 2015-05-13 15:46:54 +0000
191+++ src/indicator/sim-unlock-dialog.cpp 2015-06-18 12:30:37 +0000
192@@ -435,7 +435,8 @@
193 {
194 if (d->m_modem)
195 {
196- throw std::logic_error("Unlocking already in progress.");
197+ qWarning() << "Unlocking already in progress.";
198+ return;
199 }
200
201 d->m_modem = modem;
202@@ -474,6 +475,9 @@
203 pukRetries = retries[wwan::Modem::PinType::puk];
204 }
205
206+ qDebug() << __PRETTY_FUNCTION__ << modem->name() << "pinRetries ="
207+ << pinRetries << "pukRetries =" << pukRetries;
208+
209 // remind the user
210 if (type == wwan::Modem::PinType::pin && pinRetries == 1)
211 {

Subscribers

People subscribed via source and target branches