Merge lp:~boiko/dialer-app/fix_calling_emergency_numbers into lp:dialer-app

Proposed by Gustavo Pichorim Boiko
Status: Superseded
Proposed branch: lp:~boiko/dialer-app/fix_calling_emergency_numbers
Merge into: lp:dialer-app
Prerequisite: lp:~tiagosh/dialer-app/sim-lock
Diff against target: 345 lines (+122/-62)
5 files modified
src/qml/DialerPage/DialerPage.qml (+11/-29)
src/qml/Dialogs/SetDefaultSIMCardDialog.qml (+2/-2)
src/qml/LiveCallPage/LiveCall.qml (+7/-1)
src/qml/dialer-app.qml (+98/-30)
tests/autopilot/dialer_app/tests/test_calls.py (+4/-0)
To merge this branch: bzr merge lp:~boiko/dialer-app/fix_calling_emergency_numbers
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Tiago Salem Herrmann (community) Approve
Review via email: mp+236434@code.launchpad.net

This proposal supersedes a proposal from 2014-09-29.

This proposal has been superseded by a proposal from 2014-10-06.

Commit message

Remove some code duplication and make sure emergency calling is always available.

Description of the change

Remove some code duplication and make sure emergency calling is always available.

== Checklist ==
Are there any related MPs required for this MP to build/function as expected? Please list.
Yes: https://code.launchpad.net/~tiagosh/telephony-service/sim-lock/+merge/235505

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
Yes

If you changed UI labels, did you update the pot file?
No, it will be updated later

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
281. By Gustavo Pichorim Boiko

Fix autopilot test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
282. By Gustavo Pichorim Boiko

Fix the path to the dialogs.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
283. By Gustavo Pichorim Boiko

Fix calling the dialogs.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
284. By Gustavo Pichorim Boiko

Use the correct variable.

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

Looks good and works as expected.

--Checklist--
Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
No, but not related to the changes.

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
285. By Gustavo Pichorim Boiko

Wait longer for the calls to appear. In the case where we are leaving flight mode
the modem takes longer to be ready and to place the call.

286. By Gustavo Pichorim Boiko

Increase the waiting interval if switching from flight mode.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/DialerPage/DialerPage.qml'
2--- src/qml/DialerPage/DialerPage.qml 2014-10-03 18:42:54 +0000
3+++ src/qml/DialerPage/DialerPage.qml 2014-10-03 18:42:55 +0000
4@@ -31,6 +31,7 @@
5
6 property alias dialNumber: keypadEntry.value
7 property alias input: keypadEntry.input
8+ property alias callAnimationRunning: callAnimation.running
9 property var mmiPlugins: []
10 property list<Action> actionsGreeter
11 property list<Action> actionsNormal: [
12@@ -81,6 +82,10 @@
13 target: addContact
14 visible: false
15 }
16+ PropertyChanges {
17+ target: keypadEntry
18+ value: ""
19+ }
20 },
21 State {
22 name: "normalMode"
23@@ -145,6 +150,10 @@
24 return index;
25 }
26
27+ function triggerCallAnimation() {
28+ callAnimation.start();
29+ }
30+
31 Connections {
32 target: mainView
33 onPendingNumberToDialChanged: {
34@@ -368,34 +377,7 @@
35 }
36 onClicked: {
37 console.log("Starting a call to " + keypadEntry.value);
38- // check if at least one account is selected
39- if (multipleAccounts && !mainView.account) {
40- Qt.inputMethod.hide()
41- PopupUtils.open(Qt.createComponent("../Dialogs/NoSIMCardSelectedDialog.qml").createObject(page))
42- return
43- }
44-
45- if (multipleAccounts && !telepathyHelper.defaultCallAccount && !settings.dialPadDontAsk) {
46- var properties = {}
47- properties["phoneNumber"] = dialNumber
48- properties["accountId"] = mainView.account.accountId
49- PopupUtils.open(Qt.createComponent("../Dialogs/SetDefaultSIMCardDialog.qml").createObject(page), footer, properties)
50- return
51- }
52-
53- if (mainView.account && !greeter.greeterActive && !mainView.isEmergencyNumber(dialNumber) && mainView.account.simLocked) {
54- var properties = {}
55- properties["accountId"] = mainView.account.accountId
56- PopupUtils.open(Qt.createComponent("../Dialogs/SimLockedDialog.qml").createObject(page), footer, properties)
57- return
58- }
59-
60- // avoid cleaning the keypadEntry in case there is no signal
61- if (!mainView.account.connected) {
62- PopupUtils.open(noNetworkDialog)
63- return
64- }
65- callAnimation.start()
66+ mainView.call(keypadEntry.value);
67 }
68 enabled: {
69 if (dialNumber == "") {
70@@ -436,7 +418,7 @@
71 }
72 ScriptAction {
73 script: {
74- mainView.call(keypadEntry.value, mainView.account.accountId);
75+ mainView.switchToLiveCall()
76 keypadEntry.value = ""
77 callButton.iconRotation = 0.0
78 keypadContainer.opacity = 1.0
79
80=== modified file 'src/qml/Dialogs/SetDefaultSIMCardDialog.qml'
81--- src/qml/Dialogs/SetDefaultSIMCardDialog.qml 2014-08-20 14:00:01 +0000
82+++ src/qml/Dialogs/SetDefaultSIMCardDialog.qml 2014-10-03 18:42:55 +0000
83@@ -41,7 +41,7 @@
84 color: UbuntuColors.orange
85 onClicked: {
86 PopupUtils.close(dialogue)
87- mainView.call(phoneNumber, accountId)
88+ mainView.call(phoneNumber, true)
89 Qt.inputMethod.hide()
90 }
91 }
92@@ -52,7 +52,7 @@
93 onClicked: {
94 telepathyHelper.setDefaultAccount(TelepathyHelper.Call, mainView.account)
95 PopupUtils.close(dialogue)
96- mainView.call(phoneNumber, accountId)
97+ mainView.call(phoneNumber, true)
98 Qt.inputMethod.hide()
99 }
100 }
101
102=== modified file 'src/qml/LiveCallPage/LiveCall.qml'
103--- src/qml/LiveCallPage/LiveCall.qml 2014-09-22 21:55:49 +0000
104+++ src/qml/LiveCallPage/LiveCall.qml 2014-10-03 18:42:55 +0000
105@@ -239,11 +239,17 @@
106
107 Component.onCompleted: {
108 callManager.callIndicatorVisible = !active;
109+
110+ // if this view is visible in flight mode, it is very likely an emergency call
111+ // so wait longer for the call to appear before giving up
112+ if (telepathyHelper.flightMode) {
113+ callWatcher.interval = 30000;
114+ }
115 }
116
117 Timer {
118 id: callWatcher
119- interval: 7000
120+ interval: 10000
121 repeat: false
122 running: true
123 onTriggered: {
124
125=== modified file 'src/qml/dialer-app.qml'
126--- src/qml/dialer-app.qml 2014-10-03 18:42:54 +0000
127+++ src/qml/dialer-app.qml 2014-10-03 18:42:55 +0000
128@@ -54,7 +54,6 @@
129 signal closeUSSDProgressIndicator
130
131 property string pendingNumberToDial: ""
132- property string pendingAccountId: ""
133 property bool accountReady: false
134
135 onApplicationActiveChanged: {
136@@ -119,9 +118,12 @@
137 ]
138
139 function isEmergencyNumber(number) {
140- for (var i in mainView.account.emergencyNumbers) {
141- if (phoneUtils.comparePhoneNumbers(number, mainView.account.emergencyNumbers[i])) {
142- return true;
143+ for (var i in telepathyHelper.accounts) {
144+ var account = telepathyHelper.accounts[i];
145+ for (var j in account.emergencyNumbers) {
146+ if (phoneUtils.comparePhoneNumbers(number, account.emergencyNumbers[j])) {
147+ return true;
148+ }
149 }
150 }
151 return false;
152@@ -153,7 +155,7 @@
153 if (greeter.greeterActive) {
154 return;
155 }
156- call(mainView.account.voicemailNumber, mainView.account.accountId);
157+ call(mainView.account.voicemailNumber);
158 }
159
160 function checkUSSD(number) {
161@@ -187,38 +189,82 @@
162 return false
163 }
164
165- function call(number, accountId) {
166+ function callEmergency(number) {
167+ animateLiveCall();
168+
169+ // if we are in flight mode, we first need to disable it and wait for
170+ // the modems to update
171+ if (telepathyHelper.flightMode) {
172+ pendingNumberToDial = number;
173+ telepathyHelper.flightMode = false;
174+ return;
175+ }
176+
177+ // now try to use one of the connected accounts
178+ var account = null;
179+ if (telepathyHelper.activeAccounts.length > 0) {
180+ account = telepathyHelper.activeAccounts[0];
181+ } else {
182+ // if no account is active, use any account that can make emergency calls
183+ for (var i in telepathyHelper.accounts) {
184+ if (telepathyHelper.accounts[i].emergencyCallsAvailable) {
185+ account = telepathyHelper.accounts[i];
186+ break;
187+ }
188+ }
189+ }
190+
191+ // not sure what to do when no accounts can make emergency calls
192+ if (account == null) {
193+ pendingNumberToDial = number;
194+ return;
195+ }
196+
197+ if (!accountReady) {
198+ pendingNumberToDial = number;
199+ return;
200+ }
201+
202+ callManager.startCall(number, account.accountId);
203+ }
204+
205+ function call(number, skipDefaultSimDialog) {
206 // clear the values here so that the changed signals are fired when the new value is set
207 pendingNumberToDial = "";
208- pendingAccountId = "";
209-
210
211 if (number === "") {
212 return
213 }
214
215+ if (isEmergencyNumber(number)) {
216+ callEmergency(number);
217+ return;
218+ }
219+
220+ // check if at least one account is selected
221 if (multipleAccounts && !mainView.account) {
222+ Qt.inputMethod.hide()
223 PopupUtils.open(Qt.createComponent("Dialogs/NoSIMCardSelectedDialog.qml").createObject(mainView))
224 return
225 }
226
227- var account = telepathyHelper.accountForId(accountId);
228- if (account && !greeter.greeterActive && !mainView.isEmergencyNumber(number) && account.simLocked) {
229- PopupUtils.open(Qt.createComponent("Dialogs/SimLockedDialog.qml").createObject(mainView))
230- return
231- }
232-
233- if (!telepathyHelper.connected && !isEmergencyNumber((number))) {
234- pendingNumberToDial = number;
235- pendingAccountId = accountId;
236- return;
237- }
238-
239- if (!account) {
240- account = telepathyHelper.accounts[0];
241- }
242-
243- if (!account.connected) {
244+ if (multipleAccounts && !telepathyHelper.defaultCallAccount && !settings.dialPadDontAsk && !skipDefaultSimDialog) {
245+ var properties = {}
246+ properties["phoneNumber"] = number
247+ properties["accountId"] = mainView.account.accountId
248+ PopupUtils.open(Qt.createComponent("Dialogs/SetDefaultSIMCardDialog.qml").createObject(mainView), mainView, properties)
249+ return
250+ }
251+
252+ if (mainView.account && !greeter.greeterActive && mainView.account.simLocked) {
253+ var properties = {}
254+ properties["accountId"] = mainView.account.accountId
255+ PopupUtils.open(Qt.createComponent("Dialogs/SimLockedDialog.qml").createObject(mainView), mainView, properties)
256+ return
257+ }
258+
259+ // avoid cleaning the keypadEntry in case there is no signal
260+ if (!mainView.account.connected) {
261 PopupUtils.open(noNetworkDialog)
262 return
263 }
264@@ -229,11 +275,10 @@
265 return
266 }
267
268- switchToLiveCall();
269+ animateLiveCall();
270
271 if (!accountReady) {
272 pendingNumberToDial = number;
273- pendingAccountId = accountId;
274 return;
275 }
276
277@@ -262,6 +307,14 @@
278 }
279 }
280
281+ function animateLiveCall() {
282+ if (pageStack.currentPage && pageStack.currentPage.triggerCallAnimation) {
283+ pageStack.currentPage.triggerCallAnimation();
284+ } else {
285+ switchToLiveCall();
286+ }
287+ }
288+
289 function switchToLiveCall() {
290 // pop the stack if the live call is not the visible view
291 // FIXME: using the objectName here is not pretty, change by something less prone to errors
292@@ -373,10 +426,20 @@
293 }
294
295 if (pendingNumberToDial != "") {
296- callManager.startCall(pendingNumberToDial, pendingAccountId);
297+ callManager.startCall(pendingNumberToDial, mainView.account.accountId);
298 }
299 pendingNumberToDial = "";
300- pendingAccountId = "";
301+ }
302+
303+ onEmergencyCallsAvailableChanged: {
304+ if (telepathyHelper.emergencyCallsAvailable && pendingNumberToDial !== "") {
305+ if (!isEmergencyNumber(pendingNumberToDial)) {
306+ return;
307+ }
308+
309+ callEmergency(pendingNumberToDial);
310+ pendingNumberToDial = "";
311+ }
312 }
313 }
314
315@@ -387,7 +450,12 @@
316 return;
317 }
318
319- // load the live call
320+ // if we are animating the dialpad view, do not switch to livecall directly
321+ if (pageStack.currentPage && pageStack.currentPage.callAnimationRunning) {
322+ return;
323+ }
324+
325+ // if not, just open the live call
326 switchToLiveCall();
327 }
328 }
329
330=== modified file 'tests/autopilot/dialer_app/tests/test_calls.py'
331--- tests/autopilot/dialer_app/tests/test_calls.py 2014-09-02 21:09:04 +0000
332+++ tests/autopilot/dialer_app/tests/test_calls.py 2014-10-03 18:42:55 +0000
333@@ -130,8 +130,12 @@
334 elapsed_time = self.main_view.live_call_page.get_elapsed_call_time()
335 self.assertIn("00:0", elapsed_time)
336
337+ # wait for the live call view to be gone
338+ self.main_view.dialer_page.active.wait_for(True)
339+
340 # after remote hangs up, should switch to call log page and show call
341 # to number
342+ self.main_view.dialer_page.reveal_bottom_edge_page()
343 self.assertThat(self.history_list.visible, Eventually(Equals(True)))
344 self.assertThat(self.history_list.count, Eventually(Equals(1)))
345 self.assertThat(self.get_history_for_number(number), NotEquals(None))

Subscribers

People subscribed via source and target branches