Merge lp:~ken-vandine/ubuntu-system-settings/sim_pin_retries_lp1415850 into lp:ubuntu-system-settings

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
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

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

WFM

review: Approve
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
=== modified file 'plugins/security-privacy/SimPin.qml'
--- plugins/security-privacy/SimPin.qml 2015-01-28 15:17:09 +0000
+++ plugins/security-privacy/SimPin.qml 2015-04-01 18:25:56 +0000
@@ -45,11 +45,18 @@
45 id: changePinDialog45 id: changePinDialog
46 title: i18n.tr("Change SIM PIN")46 title: i18n.tr("Change SIM PIN")
4747
48 property string errorText: i18n.tr(48 property string errorText: {
49 "Incorrect PIN. %1 attempt remaining.",49 if (curSim.pinRetries[OfonoSimManager.SimPin] > 0)
50 "Incorrect PIN. %1 attempts remaining.",50 return i18n.tr(
51 curSim.pinRetries[OfonoSimManager.SimPin] || 351 "Incorrect PIN. %1 attempt remaining.",
52 ).arg(curSim.pinRetries[OfonoSimManager.SimPin] || 3)52 "Incorrect PIN. %1 attempts remaining.",
53 curSim.pinRetries[OfonoSimManager.SimPin] === 1
54 ).arg(curSim.pinRetries[OfonoSimManager.SimPin])
55 else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0)
56 return i18n.tr("No more attempts allowed")
57 else
58 return ""
59 }
53 property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin)60 property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin)
54 property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin)61 property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin)
5562
@@ -69,6 +76,7 @@
69 console.warn("Change PIN failed with: " + error);76 console.warn("Change PIN failed with: " + error);
70 incorrect.visible = true;77 incorrect.visible = true;
71 changePinDialog.enabled = true;78 changePinDialog.enabled = true;
79 confirmButton.enabled = false;
72 currentInput.forceActiveFocus();80 currentInput.forceActiveFocus();
73 currentInput.selectAll();81 currentInput.selectAll();
74 return;82 return;
@@ -88,13 +96,29 @@
88 echoMode: TextInput.Password96 echoMode: TextInput.Password
89 inputMethodHints: Qt.ImhDialableCharactersOnly97 inputMethodHints: Qt.ImhDialableCharactersOnly
90 maximumLength: simMax98 maximumLength: simMax
99 onTextChanged: confirmButton.enabled =
100 (acceptableInput &&
101 confirmInput.acceptableInput &&
102 confirmInput.text.length >= simMin &&
103 (confirmInput.text === newInput.text) &&
104 (!curSim.pinRetries[OfonoSimManager.SimPin] ||
105 (curSim.pinRetries[OfonoSimManager.SimPin] > 0)))
91 }106 }
92107
93 Label {108 Label {
94 id: retries109 id: retries
95 text: i18n.tr("%1 attempt allowed.", "%1 attempts allowed.",110 text: {
96 curSim.pinRetries[OfonoSimManager.SimPin] || 3).arg(111 if (curSim.pinRetries[OfonoSimManager.SimPin] > 0)
97 curSim.pinRetries[OfonoSimManager.SimPin] || 3)112 return i18n.tr(
113 "%1 attempt allowed.",
114 "%1 attempts allowed.",
115 curSim.pinRetries[OfonoSimManager.SimPin] === 1
116 ).arg(curSim.pinRetries[OfonoSimManager.SimPin])
117 else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0)
118 return i18n.tr("No more attempts allowed")
119 else
120 return ""
121 }
98 visible: !incorrect.visible122 visible: !incorrect.visible
99 }123 }
100124
@@ -130,7 +154,10 @@
130 onTextChanged: confirmButton.enabled =154 onTextChanged: confirmButton.enabled =
131 (acceptableInput &&155 (acceptableInput &&
132 text.length >= simMin &&156 text.length >= simMin &&
133 (text === newInput.text))157 (text === newInput.text) &&
158 (!curSim.pinRetries[OfonoSimManager.SimPin] ||
159 (curSim.pinRetries[OfonoSimManager.SimPin] > 0)))
160
134 }161 }
135162
136 Label {163 Label {
@@ -185,9 +212,18 @@
185 i18n.tr("Enter SIM PIN") :212 i18n.tr("Enter SIM PIN") :
186 i18n.tr("Enter Previous SIM PIN")213 i18n.tr("Enter Previous SIM PIN")
187214
188 property string errorText: i18n.tr(215 property string errorText: {
189 "Incorrect PIN. %1 attempts remaining."216 if (curSim.pinRetries[OfonoSimManager.SimPin] > 0)
190 ).arg(curSim.pinRetries[OfonoSimManager.SimPin] || 3)217 return i18n.tr(
218 "Incorrect PIN. %1 attempt remaining.",
219 "Incorrect PIN. %1 attempts remaining.",
220 curSim.pinRetries[OfonoSimManager.SimPin] === 1
221 ).arg(curSim.pinRetries[OfonoSimManager.SimPin])
222 else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0)
223 return i18n.tr("No more attempts allowed")
224 else
225 return ""
226 }
191227
192 property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin)228 property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin)
193 property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin)229 property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin)
@@ -208,6 +244,7 @@
208 console.warn("Lock PIN failed with: " + error);244 console.warn("Lock PIN failed with: " + error);
209 incorrect.visible = true;245 incorrect.visible = true;
210 lockPinDialog.enabled = true;246 lockPinDialog.enabled = true;
247 lockButton.enabled = false;
211 prevInput.forceActiveFocus();248 prevInput.forceActiveFocus();
212 prevInput.selectAll();249 prevInput.selectAll();
213 return;250 return;
@@ -221,6 +258,7 @@
221 console.warn("Unlock PIN failed with: " + error);258 console.warn("Unlock PIN failed with: " + error);
222 incorrect.visible = true;259 incorrect.visible = true;
223 lockPinDialog.enabled = true;260 lockPinDialog.enabled = true;
261 lockButton.enabled = false;
224 prevInput.forceActiveFocus();262 prevInput.forceActiveFocus();
225 prevInput.selectAll();263 prevInput.selectAll();
226 return;264 return;
@@ -240,13 +278,25 @@
240278
241 // Doesn't get updated if you set this in enabled of confirmButton279 // Doesn't get updated if you set this in enabled of confirmButton
242 onTextChanged: lockButton.enabled =280 onTextChanged: lockButton.enabled =
243 (acceptableInput && text.length >= simMin)281 (acceptableInput && (text.length >= simMin) &&
282 (!curSim.pinRetries[OfonoSimManager.SimPin] ||
283 (curSim.pinRetries[OfonoSimManager.SimPin] > 0)))
244 }284 }
245285
246 Label {286 Label {
247 horizontalAlignment: Text.AlignHCenter287 horizontalAlignment: Text.AlignHCenter
248 text: i18n.tr("%1 attempts allowed.").arg(288 text: {
249 curSim.pinRetries[OfonoSimManager.SimPin] || 3)289 if (curSim.pinRetries[OfonoSimManager.SimPin] > 0)
290 return i18n.tr(
291 "%1 attempt allowed.",
292 "%1 attempts allowed.",
293 curSim.pinRetries[OfonoSimManager.SimPin] === 1
294 ).arg(curSim.pinRetries[OfonoSimManager.SimPin])
295 else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0)
296 return i18n.tr("No more attempts allowed")
297 else
298 return ""
299 }
250 visible: !incorrect.visible300 visible: !incorrect.visible
251 width: parent.width301 width: parent.width
252 }302 }
253303
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/ofono.py'
--- tests/autopilot/ubuntu_system_settings/tests/ofono.py 2014-08-27 16:13:12 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/ofono.py 2015-04-01 18:25:56 +0000
@@ -81,6 +81,7 @@
81 ])81 ])
82 obj = dbusmock.mockobject.objects[path]82 obj = dbusmock.mockobject.objects[path]
83 obj.name = name83 obj.name = name
84 obj.sim_pin = "2468"
84 add_simmanager_api(obj)85 add_simmanager_api(obj)
85 add_voice_call_api(obj)86 add_voice_call_api(obj)
86 add_netreg_api(obj)87 add_netreg_api(obj)
@@ -110,19 +111,103 @@
110 ('SetProperty', 'sv', '', 'self.Set("%(i)s", args[0], args[1]); '111 ('SetProperty', 'sv', '', 'self.Set("%(i)s", args[0], args[1]); '
111 'self.EmitSignal("%(i)s", "PropertyChanged", "sv", [args[0], '112 'self.EmitSignal("%(i)s", "PropertyChanged", "sv", [args[0], '
112 'args[1]])' % {'i': iface}),113 'args[1]])' % {'i': iface}),
113 ('ChangePin', 'sss', '', ''),114 ('ResetPin', 'sss', '', '')
114 ('EnterPin', 'ss', '', ''),
115 ('ResetPin', 'sss', '', ''),
116 ('LockPin', 'ss', '', 'if args[1] == "2468": self.Set("%(i)s",'
117 '"LockedPins", dbus.Array(["pin"])); self.EmitSignal("%(i)s",'
118 '"PropertyChanged", "sv", ["LockedPins", self.Get("%(i)s", '
119 '"LockedPins")])' % {'i': iface}),
120 ('UnlockPin', 'ss', '', 'if args[1] == "2468": self.Set("%(i)s",'
121 '"LockedPins", ""); self.EmitSignal("%(i)s", "PropertyChanged", "sv",'
122 ' ["LockedPins", self.Get("%(i)s", "LockedPins")])' % {'i': iface})
123 ])115 ])
124116
125117
118@dbus.service.method('org.ofono.SimManager',
119 in_signature='ss', out_signature='')
120def LockPin(self, pin_type, pin):
121 iface = 'org.ofono.SimManager'
122 print('XXX LockPin', pin_type, pin)
123
124 if (pin == self.sim_pin):
125 print('XXX LockPin pin matches')
126 self.Set(iface, "LockedPins", dbus.Array(["pin"]))
127 self.EmitSignal(iface, "PropertyChanged", "sv",
128 ["LockedPins", self.Get(iface, "LockedPins")])
129 self.Set(iface, "Retries", {'pin': dbus.Byte(3)})
130 self.EmitSignal(iface, "PropertyChanged", "sv",
131 ["Retries", self.Get(iface, "Retries")])
132 else:
133 retries = self.Get(iface, "Retries")['pin']
134 if (retries > 0):
135 self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)})
136 self.EmitSignal(iface, "PropertyChanged", "sv",
137 ["Retries", self.Get(iface, "Retries")])
138 raise dbus.exceptions.DBusException("", "Failed",
139 name="org.ofono.Error.Failed")
140 print('XXX LockPin', self.Get(iface, "Retries")['pin'])
141
142
143@dbus.service.method('org.ofono.SimManager',
144 in_signature='ss', out_signature='')
145def UnlockPin(self, pin_type, pin):
146 iface = 'org.ofono.SimManager'
147 print('XXX UnlockPin', pin_type, pin)
148
149 if (pin == self.sim_pin):
150 print('XXX UnlockPin pin matches')
151 self.Set(iface, "LockedPins", "")
152 self.EmitSignal(iface, "PropertyChanged", "sv",
153 ["LockedPins", self.Get(iface, "LockedPins")])
154 self.Set(iface, "Retries", {'pin': dbus.Byte(3)})
155 self.EmitSignal(iface, "PropertyChanged", "sv",
156 ["Retries", self.Get(iface, "Retries")])
157 else:
158 retries = self.Get(iface, "Retries")['pin']
159 if (retries > 0):
160 self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)})
161 self.EmitSignal(iface, "PropertyChanged", "sv",
162 ["Retries", self.Get(iface, "Retries")])
163 raise dbus.exceptions.DBusException("", "Failed",
164 name="org.ofono.Error.Failed")
165 print('XXX UnlockPin', self.Get(iface, "Retries")['pin'])
166
167
168@dbus.service.method('org.ofono.SimManager',
169 in_signature='sss', out_signature='')
170def ChangePin(self, pin_type, pin, pin2):
171 iface = 'org.ofono.SimManager'
172 print('XXX ChangePin', pin_type, pin, pin2)
173
174 if (pin == self.sim_pin):
175 print('XXX ChangePin pin matches')
176 self.sim_pin = pin2
177 self.Set(iface, "Retries", {'pin': dbus.Byte(3)})
178 self.EmitSignal(iface, "PropertyChanged", "sv",
179 ["Retries", self.Get(iface, "Retries")])
180 else:
181 retries = self.Get(iface, "Retries")['pin']
182 if (retries > 0):
183 self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)})
184 self.EmitSignal(iface, "PropertyChanged", "sv",
185 ["Retries", self.Get(iface, "Retries")])
186 raise dbus.exceptions.DBusException("", "Failed",
187 name="org.ofono.Error.Failed")
188
189
190@dbus.service.method('org.ofono.SimManager',
191 in_signature='ss', out_signature='')
192def EnterPin(self, pin_type, pin):
193 iface = 'org.ofono.SimManager'
194 print('XXX EnterPin', pin)
195
196 if (pin == self.sim_pin):
197 print('XXX EnterPin pin matches')
198 self.Set(iface, "Retries", {'pin': dbus.Byte(3)})
199 self.EmitSignal(iface, "PropertyChanged", "sv",
200 ["Retries", self.Get(iface, "Retries")])
201 else:
202 retries = self.Get(iface, "Retries")['pin']
203 if (retries > 0):
204 self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)})
205 self.EmitSignal(iface, "PropertyChanged", "sv",
206 ["Retries", self.Get(iface, "Retries")])
207 raise dbus.exceptions.DBusException("", "Failed",
208 name="org.ofono.Error.Failed")
209
210
126def add_voice_call_api(mock):211def add_voice_call_api(mock):
127 '''Add org.ofono.VoiceCallManager API to a mock'''212 '''Add org.ofono.VoiceCallManager API to a mock'''
128213

Subscribers

People subscribed via source and target branches