Merge lp:~ken-vandine/ubuntu-system-settings/sim_pin_retries_lp1415850 into lp:ubuntu-system-settings
- sim_pin_retries_lp1415850
- Merge into trunk
Proposed by
Ken VanDine
Status: | Merged |
---|---|
Approved by: | Jonas G. Drange |
Approved revision: | 1360 |
Merged at revision: | 1367 |
Proposed branch: | lp:~ken-vandine/ubuntu-system-settings/sim_pin_retries_lp1415850 |
Merge into: | lp:ubuntu-system-settings |
Diff against target: |
272 lines (+160/-25) 2 files modified
plugins/security-privacy/SimPin.qml (+65/-15) tests/autopilot/ubuntu_system_settings/tests/ofono.py (+95/-10) |
To merge this branch: | bzr merge lp:~ken-vandine/ubuntu-system-settings/sim_pin_retries_lp1415850 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonas G. Drange (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+254407@code.launchpad.net |
Commit message
* Fixed handling of pinRetries
* Improved dbusmock template for ofono to support testing LockPin, UnlockPin, ChangePin and EnterPin
Description of the change
* Fixed handling of pinRetries
* Improved dbusmock template for ofono to support testing LockPin, UnlockPin, ChangePin and EnterPin
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
- 1361. By Ken VanDine
-
removed extra debugging
- 1362. By Ken VanDine
-
merged trunk
- 1363. By Ken VanDine
-
changed string for SimPin retries 0
- 1364. By Ken VanDine
-
Handle cases where curSim.
pinRetries[ OfonoSimManager .SimPin] might be undefined - 1365. By Ken VanDine
-
fixed warnings about missing string
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugins/security-privacy/SimPin.qml' | |||
2 | --- plugins/security-privacy/SimPin.qml 2015-01-28 15:17:09 +0000 | |||
3 | +++ plugins/security-privacy/SimPin.qml 2015-04-01 18:25:56 +0000 | |||
4 | @@ -45,11 +45,18 @@ | |||
5 | 45 | id: changePinDialog | 45 | id: changePinDialog |
6 | 46 | title: i18n.tr("Change SIM PIN") | 46 | title: i18n.tr("Change SIM PIN") |
7 | 47 | 47 | ||
13 | 48 | property string errorText: i18n.tr( | 48 | property string errorText: { |
14 | 49 | "Incorrect PIN. %1 attempt remaining.", | 49 | if (curSim.pinRetries[OfonoSimManager.SimPin] > 0) |
15 | 50 | "Incorrect PIN. %1 attempts remaining.", | 50 | return i18n.tr( |
16 | 51 | curSim.pinRetries[OfonoSimManager.SimPin] || 3 | 51 | "Incorrect PIN. %1 attempt remaining.", |
17 | 52 | ).arg(curSim.pinRetries[OfonoSimManager.SimPin] || 3) | 52 | "Incorrect PIN. %1 attempts remaining.", |
18 | 53 | curSim.pinRetries[OfonoSimManager.SimPin] === 1 | ||
19 | 54 | ).arg(curSim.pinRetries[OfonoSimManager.SimPin]) | ||
20 | 55 | else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0) | ||
21 | 56 | return i18n.tr("No more attempts allowed") | ||
22 | 57 | else | ||
23 | 58 | return "" | ||
24 | 59 | } | ||
25 | 53 | property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin) | 60 | property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin) |
26 | 54 | property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin) | 61 | property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin) |
27 | 55 | 62 | ||
28 | @@ -69,6 +76,7 @@ | |||
29 | 69 | console.warn("Change PIN failed with: " + error); | 76 | console.warn("Change PIN failed with: " + error); |
30 | 70 | incorrect.visible = true; | 77 | incorrect.visible = true; |
31 | 71 | changePinDialog.enabled = true; | 78 | changePinDialog.enabled = true; |
32 | 79 | confirmButton.enabled = false; | ||
33 | 72 | currentInput.forceActiveFocus(); | 80 | currentInput.forceActiveFocus(); |
34 | 73 | currentInput.selectAll(); | 81 | currentInput.selectAll(); |
35 | 74 | return; | 82 | return; |
36 | @@ -88,13 +96,29 @@ | |||
37 | 88 | echoMode: TextInput.Password | 96 | echoMode: TextInput.Password |
38 | 89 | inputMethodHints: Qt.ImhDialableCharactersOnly | 97 | inputMethodHints: Qt.ImhDialableCharactersOnly |
39 | 90 | maximumLength: simMax | 98 | maximumLength: simMax |
40 | 99 | onTextChanged: confirmButton.enabled = | ||
41 | 100 | (acceptableInput && | ||
42 | 101 | confirmInput.acceptableInput && | ||
43 | 102 | confirmInput.text.length >= simMin && | ||
44 | 103 | (confirmInput.text === newInput.text) && | ||
45 | 104 | (!curSim.pinRetries[OfonoSimManager.SimPin] || | ||
46 | 105 | (curSim.pinRetries[OfonoSimManager.SimPin] > 0))) | ||
47 | 91 | } | 106 | } |
48 | 92 | 107 | ||
49 | 93 | Label { | 108 | Label { |
50 | 94 | id: retries | 109 | id: retries |
54 | 95 | text: i18n.tr("%1 attempt allowed.", "%1 attempts allowed.", | 110 | text: { |
55 | 96 | curSim.pinRetries[OfonoSimManager.SimPin] || 3).arg( | 111 | if (curSim.pinRetries[OfonoSimManager.SimPin] > 0) |
56 | 97 | curSim.pinRetries[OfonoSimManager.SimPin] || 3) | 112 | return i18n.tr( |
57 | 113 | "%1 attempt allowed.", | ||
58 | 114 | "%1 attempts allowed.", | ||
59 | 115 | curSim.pinRetries[OfonoSimManager.SimPin] === 1 | ||
60 | 116 | ).arg(curSim.pinRetries[OfonoSimManager.SimPin]) | ||
61 | 117 | else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0) | ||
62 | 118 | return i18n.tr("No more attempts allowed") | ||
63 | 119 | else | ||
64 | 120 | return "" | ||
65 | 121 | } | ||
66 | 98 | visible: !incorrect.visible | 122 | visible: !incorrect.visible |
67 | 99 | } | 123 | } |
68 | 100 | 124 | ||
69 | @@ -130,7 +154,10 @@ | |||
70 | 130 | onTextChanged: confirmButton.enabled = | 154 | onTextChanged: confirmButton.enabled = |
71 | 131 | (acceptableInput && | 155 | (acceptableInput && |
72 | 132 | text.length >= simMin && | 156 | text.length >= simMin && |
74 | 133 | (text === newInput.text)) | 157 | (text === newInput.text) && |
75 | 158 | (!curSim.pinRetries[OfonoSimManager.SimPin] || | ||
76 | 159 | (curSim.pinRetries[OfonoSimManager.SimPin] > 0))) | ||
77 | 160 | |||
78 | 134 | } | 161 | } |
79 | 135 | 162 | ||
80 | 136 | Label { | 163 | Label { |
81 | @@ -185,9 +212,18 @@ | |||
82 | 185 | i18n.tr("Enter SIM PIN") : | 212 | i18n.tr("Enter SIM PIN") : |
83 | 186 | i18n.tr("Enter Previous SIM PIN") | 213 | i18n.tr("Enter Previous SIM PIN") |
84 | 187 | 214 | ||
88 | 188 | property string errorText: i18n.tr( | 215 | property string errorText: { |
89 | 189 | "Incorrect PIN. %1 attempts remaining." | 216 | if (curSim.pinRetries[OfonoSimManager.SimPin] > 0) |
90 | 190 | ).arg(curSim.pinRetries[OfonoSimManager.SimPin] || 3) | 217 | return i18n.tr( |
91 | 218 | "Incorrect PIN. %1 attempt remaining.", | ||
92 | 219 | "Incorrect PIN. %1 attempts remaining.", | ||
93 | 220 | curSim.pinRetries[OfonoSimManager.SimPin] === 1 | ||
94 | 221 | ).arg(curSim.pinRetries[OfonoSimManager.SimPin]) | ||
95 | 222 | else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0) | ||
96 | 223 | return i18n.tr("No more attempts allowed") | ||
97 | 224 | else | ||
98 | 225 | return "" | ||
99 | 226 | } | ||
100 | 191 | 227 | ||
101 | 192 | property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin) | 228 | property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin) |
102 | 193 | property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin) | 229 | property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin) |
103 | @@ -208,6 +244,7 @@ | |||
104 | 208 | console.warn("Lock PIN failed with: " + error); | 244 | console.warn("Lock PIN failed with: " + error); |
105 | 209 | incorrect.visible = true; | 245 | incorrect.visible = true; |
106 | 210 | lockPinDialog.enabled = true; | 246 | lockPinDialog.enabled = true; |
107 | 247 | lockButton.enabled = false; | ||
108 | 211 | prevInput.forceActiveFocus(); | 248 | prevInput.forceActiveFocus(); |
109 | 212 | prevInput.selectAll(); | 249 | prevInput.selectAll(); |
110 | 213 | return; | 250 | return; |
111 | @@ -221,6 +258,7 @@ | |||
112 | 221 | console.warn("Unlock PIN failed with: " + error); | 258 | console.warn("Unlock PIN failed with: " + error); |
113 | 222 | incorrect.visible = true; | 259 | incorrect.visible = true; |
114 | 223 | lockPinDialog.enabled = true; | 260 | lockPinDialog.enabled = true; |
115 | 261 | lockButton.enabled = false; | ||
116 | 224 | prevInput.forceActiveFocus(); | 262 | prevInput.forceActiveFocus(); |
117 | 225 | prevInput.selectAll(); | 263 | prevInput.selectAll(); |
118 | 226 | return; | 264 | return; |
119 | @@ -240,13 +278,25 @@ | |||
120 | 240 | 278 | ||
121 | 241 | // Doesn't get updated if you set this in enabled of confirmButton | 279 | // Doesn't get updated if you set this in enabled of confirmButton |
122 | 242 | onTextChanged: lockButton.enabled = | 280 | onTextChanged: lockButton.enabled = |
124 | 243 | (acceptableInput && text.length >= simMin) | 281 | (acceptableInput && (text.length >= simMin) && |
125 | 282 | (!curSim.pinRetries[OfonoSimManager.SimPin] || | ||
126 | 283 | (curSim.pinRetries[OfonoSimManager.SimPin] > 0))) | ||
127 | 244 | } | 284 | } |
128 | 245 | 285 | ||
129 | 246 | Label { | 286 | Label { |
130 | 247 | horizontalAlignment: Text.AlignHCenter | 287 | horizontalAlignment: Text.AlignHCenter |
133 | 248 | text: i18n.tr("%1 attempts allowed.").arg( | 288 | text: { |
134 | 249 | curSim.pinRetries[OfonoSimManager.SimPin] || 3) | 289 | if (curSim.pinRetries[OfonoSimManager.SimPin] > 0) |
135 | 290 | return i18n.tr( | ||
136 | 291 | "%1 attempt allowed.", | ||
137 | 292 | "%1 attempts allowed.", | ||
138 | 293 | curSim.pinRetries[OfonoSimManager.SimPin] === 1 | ||
139 | 294 | ).arg(curSim.pinRetries[OfonoSimManager.SimPin]) | ||
140 | 295 | else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0) | ||
141 | 296 | return i18n.tr("No more attempts allowed") | ||
142 | 297 | else | ||
143 | 298 | return "" | ||
144 | 299 | } | ||
145 | 250 | visible: !incorrect.visible | 300 | visible: !incorrect.visible |
146 | 251 | width: parent.width | 301 | width: parent.width |
147 | 252 | } | 302 | } |
148 | 253 | 303 | ||
149 | === modified file 'tests/autopilot/ubuntu_system_settings/tests/ofono.py' | |||
150 | --- tests/autopilot/ubuntu_system_settings/tests/ofono.py 2014-08-27 16:13:12 +0000 | |||
151 | +++ tests/autopilot/ubuntu_system_settings/tests/ofono.py 2015-04-01 18:25:56 +0000 | |||
152 | @@ -81,6 +81,7 @@ | |||
153 | 81 | ]) | 81 | ]) |
154 | 82 | obj = dbusmock.mockobject.objects[path] | 82 | obj = dbusmock.mockobject.objects[path] |
155 | 83 | obj.name = name | 83 | obj.name = name |
156 | 84 | obj.sim_pin = "2468" | ||
157 | 84 | add_simmanager_api(obj) | 85 | add_simmanager_api(obj) |
158 | 85 | add_voice_call_api(obj) | 86 | add_voice_call_api(obj) |
159 | 86 | add_netreg_api(obj) | 87 | add_netreg_api(obj) |
160 | @@ -110,19 +111,103 @@ | |||
161 | 110 | ('SetProperty', 'sv', '', 'self.Set("%(i)s", args[0], args[1]); ' | 111 | ('SetProperty', 'sv', '', 'self.Set("%(i)s", args[0], args[1]); ' |
162 | 111 | 'self.EmitSignal("%(i)s", "PropertyChanged", "sv", [args[0], ' | 112 | 'self.EmitSignal("%(i)s", "PropertyChanged", "sv", [args[0], ' |
163 | 112 | 'args[1]])' % {'i': iface}), | 113 | 'args[1]])' % {'i': iface}), |
174 | 113 | ('ChangePin', 'sss', '', ''), | 114 | ('ResetPin', 'sss', '', '') |
165 | 114 | ('EnterPin', 'ss', '', ''), | ||
166 | 115 | ('ResetPin', 'sss', '', ''), | ||
167 | 116 | ('LockPin', 'ss', '', 'if args[1] == "2468": self.Set("%(i)s",' | ||
168 | 117 | '"LockedPins", dbus.Array(["pin"])); self.EmitSignal("%(i)s",' | ||
169 | 118 | '"PropertyChanged", "sv", ["LockedPins", self.Get("%(i)s", ' | ||
170 | 119 | '"LockedPins")])' % {'i': iface}), | ||
171 | 120 | ('UnlockPin', 'ss', '', 'if args[1] == "2468": self.Set("%(i)s",' | ||
172 | 121 | '"LockedPins", ""); self.EmitSignal("%(i)s", "PropertyChanged", "sv",' | ||
173 | 122 | ' ["LockedPins", self.Get("%(i)s", "LockedPins")])' % {'i': iface}) | ||
175 | 123 | ]) | 115 | ]) |
176 | 124 | 116 | ||
177 | 125 | 117 | ||
178 | 118 | @dbus.service.method('org.ofono.SimManager', | ||
179 | 119 | in_signature='ss', out_signature='') | ||
180 | 120 | def LockPin(self, pin_type, pin): | ||
181 | 121 | iface = 'org.ofono.SimManager' | ||
182 | 122 | print('XXX LockPin', pin_type, pin) | ||
183 | 123 | |||
184 | 124 | if (pin == self.sim_pin): | ||
185 | 125 | print('XXX LockPin pin matches') | ||
186 | 126 | self.Set(iface, "LockedPins", dbus.Array(["pin"])) | ||
187 | 127 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
188 | 128 | ["LockedPins", self.Get(iface, "LockedPins")]) | ||
189 | 129 | self.Set(iface, "Retries", {'pin': dbus.Byte(3)}) | ||
190 | 130 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
191 | 131 | ["Retries", self.Get(iface, "Retries")]) | ||
192 | 132 | else: | ||
193 | 133 | retries = self.Get(iface, "Retries")['pin'] | ||
194 | 134 | if (retries > 0): | ||
195 | 135 | self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)}) | ||
196 | 136 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
197 | 137 | ["Retries", self.Get(iface, "Retries")]) | ||
198 | 138 | raise dbus.exceptions.DBusException("", "Failed", | ||
199 | 139 | name="org.ofono.Error.Failed") | ||
200 | 140 | print('XXX LockPin', self.Get(iface, "Retries")['pin']) | ||
201 | 141 | |||
202 | 142 | |||
203 | 143 | @dbus.service.method('org.ofono.SimManager', | ||
204 | 144 | in_signature='ss', out_signature='') | ||
205 | 145 | def UnlockPin(self, pin_type, pin): | ||
206 | 146 | iface = 'org.ofono.SimManager' | ||
207 | 147 | print('XXX UnlockPin', pin_type, pin) | ||
208 | 148 | |||
209 | 149 | if (pin == self.sim_pin): | ||
210 | 150 | print('XXX UnlockPin pin matches') | ||
211 | 151 | self.Set(iface, "LockedPins", "") | ||
212 | 152 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
213 | 153 | ["LockedPins", self.Get(iface, "LockedPins")]) | ||
214 | 154 | self.Set(iface, "Retries", {'pin': dbus.Byte(3)}) | ||
215 | 155 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
216 | 156 | ["Retries", self.Get(iface, "Retries")]) | ||
217 | 157 | else: | ||
218 | 158 | retries = self.Get(iface, "Retries")['pin'] | ||
219 | 159 | if (retries > 0): | ||
220 | 160 | self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)}) | ||
221 | 161 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
222 | 162 | ["Retries", self.Get(iface, "Retries")]) | ||
223 | 163 | raise dbus.exceptions.DBusException("", "Failed", | ||
224 | 164 | name="org.ofono.Error.Failed") | ||
225 | 165 | print('XXX UnlockPin', self.Get(iface, "Retries")['pin']) | ||
226 | 166 | |||
227 | 167 | |||
228 | 168 | @dbus.service.method('org.ofono.SimManager', | ||
229 | 169 | in_signature='sss', out_signature='') | ||
230 | 170 | def ChangePin(self, pin_type, pin, pin2): | ||
231 | 171 | iface = 'org.ofono.SimManager' | ||
232 | 172 | print('XXX ChangePin', pin_type, pin, pin2) | ||
233 | 173 | |||
234 | 174 | if (pin == self.sim_pin): | ||
235 | 175 | print('XXX ChangePin pin matches') | ||
236 | 176 | self.sim_pin = pin2 | ||
237 | 177 | self.Set(iface, "Retries", {'pin': dbus.Byte(3)}) | ||
238 | 178 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
239 | 179 | ["Retries", self.Get(iface, "Retries")]) | ||
240 | 180 | else: | ||
241 | 181 | retries = self.Get(iface, "Retries")['pin'] | ||
242 | 182 | if (retries > 0): | ||
243 | 183 | self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)}) | ||
244 | 184 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
245 | 185 | ["Retries", self.Get(iface, "Retries")]) | ||
246 | 186 | raise dbus.exceptions.DBusException("", "Failed", | ||
247 | 187 | name="org.ofono.Error.Failed") | ||
248 | 188 | |||
249 | 189 | |||
250 | 190 | @dbus.service.method('org.ofono.SimManager', | ||
251 | 191 | in_signature='ss', out_signature='') | ||
252 | 192 | def EnterPin(self, pin_type, pin): | ||
253 | 193 | iface = 'org.ofono.SimManager' | ||
254 | 194 | print('XXX EnterPin', pin) | ||
255 | 195 | |||
256 | 196 | if (pin == self.sim_pin): | ||
257 | 197 | print('XXX EnterPin pin matches') | ||
258 | 198 | self.Set(iface, "Retries", {'pin': dbus.Byte(3)}) | ||
259 | 199 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
260 | 200 | ["Retries", self.Get(iface, "Retries")]) | ||
261 | 201 | else: | ||
262 | 202 | retries = self.Get(iface, "Retries")['pin'] | ||
263 | 203 | if (retries > 0): | ||
264 | 204 | self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)}) | ||
265 | 205 | self.EmitSignal(iface, "PropertyChanged", "sv", | ||
266 | 206 | ["Retries", self.Get(iface, "Retries")]) | ||
267 | 207 | raise dbus.exceptions.DBusException("", "Failed", | ||
268 | 208 | name="org.ofono.Error.Failed") | ||
269 | 209 | |||
270 | 210 | |||
271 | 126 | def add_voice_call_api(mock): | 211 | def add_voice_call_api(mock): |
272 | 127 | '''Add org.ofono.VoiceCallManager API to a mock''' | 212 | '''Add org.ofono.VoiceCallManager API to a mock''' |
273 | 128 | 213 |
PASSED: Continuous integration, rev:1360 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- ci/2038/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 2021 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- vivid-i386- ci/308 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 1782 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2019 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2019/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 19253
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- ci/2038/ rebuild
http://