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
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 id: changePinDialog
6 title: i18n.tr("Change SIM PIN")
7
8- property string errorText: i18n.tr(
9- "Incorrect PIN. %1 attempt remaining.",
10- "Incorrect PIN. %1 attempts remaining.",
11- curSim.pinRetries[OfonoSimManager.SimPin] || 3
12- ).arg(curSim.pinRetries[OfonoSimManager.SimPin] || 3)
13+ property string errorText: {
14+ if (curSim.pinRetries[OfonoSimManager.SimPin] > 0)
15+ return i18n.tr(
16+ "Incorrect PIN. %1 attempt remaining.",
17+ "Incorrect PIN. %1 attempts remaining.",
18+ curSim.pinRetries[OfonoSimManager.SimPin] === 1
19+ ).arg(curSim.pinRetries[OfonoSimManager.SimPin])
20+ else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0)
21+ return i18n.tr("No more attempts allowed")
22+ else
23+ return ""
24+ }
25 property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin)
26 property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin)
27
28@@ -69,6 +76,7 @@
29 console.warn("Change PIN failed with: " + error);
30 incorrect.visible = true;
31 changePinDialog.enabled = true;
32+ confirmButton.enabled = false;
33 currentInput.forceActiveFocus();
34 currentInput.selectAll();
35 return;
36@@ -88,13 +96,29 @@
37 echoMode: TextInput.Password
38 inputMethodHints: Qt.ImhDialableCharactersOnly
39 maximumLength: simMax
40+ onTextChanged: confirmButton.enabled =
41+ (acceptableInput &&
42+ confirmInput.acceptableInput &&
43+ confirmInput.text.length >= simMin &&
44+ (confirmInput.text === newInput.text) &&
45+ (!curSim.pinRetries[OfonoSimManager.SimPin] ||
46+ (curSim.pinRetries[OfonoSimManager.SimPin] > 0)))
47 }
48
49 Label {
50 id: retries
51- text: i18n.tr("%1 attempt allowed.", "%1 attempts allowed.",
52- curSim.pinRetries[OfonoSimManager.SimPin] || 3).arg(
53- curSim.pinRetries[OfonoSimManager.SimPin] || 3)
54+ text: {
55+ if (curSim.pinRetries[OfonoSimManager.SimPin] > 0)
56+ return i18n.tr(
57+ "%1 attempt allowed.",
58+ "%1 attempts allowed.",
59+ curSim.pinRetries[OfonoSimManager.SimPin] === 1
60+ ).arg(curSim.pinRetries[OfonoSimManager.SimPin])
61+ else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0)
62+ return i18n.tr("No more attempts allowed")
63+ else
64+ return ""
65+ }
66 visible: !incorrect.visible
67 }
68
69@@ -130,7 +154,10 @@
70 onTextChanged: confirmButton.enabled =
71 (acceptableInput &&
72 text.length >= simMin &&
73- (text === newInput.text))
74+ (text === newInput.text) &&
75+ (!curSim.pinRetries[OfonoSimManager.SimPin] ||
76+ (curSim.pinRetries[OfonoSimManager.SimPin] > 0)))
77+
78 }
79
80 Label {
81@@ -185,9 +212,18 @@
82 i18n.tr("Enter SIM PIN") :
83 i18n.tr("Enter Previous SIM PIN")
84
85- property string errorText: i18n.tr(
86- "Incorrect PIN. %1 attempts remaining."
87- ).arg(curSim.pinRetries[OfonoSimManager.SimPin] || 3)
88+ property string errorText: {
89+ if (curSim.pinRetries[OfonoSimManager.SimPin] > 0)
90+ return i18n.tr(
91+ "Incorrect PIN. %1 attempt remaining.",
92+ "Incorrect PIN. %1 attempts remaining.",
93+ curSim.pinRetries[OfonoSimManager.SimPin] === 1
94+ ).arg(curSim.pinRetries[OfonoSimManager.SimPin])
95+ else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0)
96+ return i18n.tr("No more attempts allowed")
97+ else
98+ return ""
99+ }
100
101 property int simMin: curSim.minimumPinLength(OfonoSimManager.SimPin)
102 property int simMax: curSim.maximumPinLength(OfonoSimManager.SimPin)
103@@ -208,6 +244,7 @@
104 console.warn("Lock PIN failed with: " + error);
105 incorrect.visible = true;
106 lockPinDialog.enabled = true;
107+ lockButton.enabled = false;
108 prevInput.forceActiveFocus();
109 prevInput.selectAll();
110 return;
111@@ -221,6 +258,7 @@
112 console.warn("Unlock PIN failed with: " + error);
113 incorrect.visible = true;
114 lockPinDialog.enabled = true;
115+ lockButton.enabled = false;
116 prevInput.forceActiveFocus();
117 prevInput.selectAll();
118 return;
119@@ -240,13 +278,25 @@
120
121 // Doesn't get updated if you set this in enabled of confirmButton
122 onTextChanged: lockButton.enabled =
123- (acceptableInput && text.length >= simMin)
124+ (acceptableInput && (text.length >= simMin) &&
125+ (!curSim.pinRetries[OfonoSimManager.SimPin] ||
126+ (curSim.pinRetries[OfonoSimManager.SimPin] > 0)))
127 }
128
129 Label {
130 horizontalAlignment: Text.AlignHCenter
131- text: i18n.tr("%1 attempts allowed.").arg(
132- curSim.pinRetries[OfonoSimManager.SimPin] || 3)
133+ text: {
134+ if (curSim.pinRetries[OfonoSimManager.SimPin] > 0)
135+ return i18n.tr(
136+ "%1 attempt allowed.",
137+ "%1 attempts allowed.",
138+ curSim.pinRetries[OfonoSimManager.SimPin] === 1
139+ ).arg(curSim.pinRetries[OfonoSimManager.SimPin])
140+ else if (curSim.pinRetries[OfonoSimManager.SimPin] === 0)
141+ return i18n.tr("No more attempts allowed")
142+ else
143+ return ""
144+ }
145 visible: !incorrect.visible
146 width: parent.width
147 }
148
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 ])
154 obj = dbusmock.mockobject.objects[path]
155 obj.name = name
156+ obj.sim_pin = "2468"
157 add_simmanager_api(obj)
158 add_voice_call_api(obj)
159 add_netreg_api(obj)
160@@ -110,19 +111,103 @@
161 ('SetProperty', 'sv', '', 'self.Set("%(i)s", args[0], args[1]); '
162 'self.EmitSignal("%(i)s", "PropertyChanged", "sv", [args[0], '
163 'args[1]])' % {'i': iface}),
164- ('ChangePin', 'sss', '', ''),
165- ('EnterPin', 'ss', '', ''),
166- ('ResetPin', 'sss', '', ''),
167- ('LockPin', 'ss', '', 'if args[1] == "2468": self.Set("%(i)s",'
168- '"LockedPins", dbus.Array(["pin"])); self.EmitSignal("%(i)s",'
169- '"PropertyChanged", "sv", ["LockedPins", self.Get("%(i)s", '
170- '"LockedPins")])' % {'i': iface}),
171- ('UnlockPin', 'ss', '', 'if args[1] == "2468": self.Set("%(i)s",'
172- '"LockedPins", ""); self.EmitSignal("%(i)s", "PropertyChanged", "sv",'
173- ' ["LockedPins", self.Get("%(i)s", "LockedPins")])' % {'i': iface})
174+ ('ResetPin', 'sss', '', '')
175 ])
176
177
178+@dbus.service.method('org.ofono.SimManager',
179+ in_signature='ss', out_signature='')
180+def LockPin(self, pin_type, pin):
181+ iface = 'org.ofono.SimManager'
182+ print('XXX LockPin', pin_type, pin)
183+
184+ if (pin == self.sim_pin):
185+ print('XXX LockPin pin matches')
186+ self.Set(iface, "LockedPins", dbus.Array(["pin"]))
187+ self.EmitSignal(iface, "PropertyChanged", "sv",
188+ ["LockedPins", self.Get(iface, "LockedPins")])
189+ self.Set(iface, "Retries", {'pin': dbus.Byte(3)})
190+ self.EmitSignal(iface, "PropertyChanged", "sv",
191+ ["Retries", self.Get(iface, "Retries")])
192+ else:
193+ retries = self.Get(iface, "Retries")['pin']
194+ if (retries > 0):
195+ self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)})
196+ self.EmitSignal(iface, "PropertyChanged", "sv",
197+ ["Retries", self.Get(iface, "Retries")])
198+ raise dbus.exceptions.DBusException("", "Failed",
199+ name="org.ofono.Error.Failed")
200+ print('XXX LockPin', self.Get(iface, "Retries")['pin'])
201+
202+
203+@dbus.service.method('org.ofono.SimManager',
204+ in_signature='ss', out_signature='')
205+def UnlockPin(self, pin_type, pin):
206+ iface = 'org.ofono.SimManager'
207+ print('XXX UnlockPin', pin_type, pin)
208+
209+ if (pin == self.sim_pin):
210+ print('XXX UnlockPin pin matches')
211+ self.Set(iface, "LockedPins", "")
212+ self.EmitSignal(iface, "PropertyChanged", "sv",
213+ ["LockedPins", self.Get(iface, "LockedPins")])
214+ self.Set(iface, "Retries", {'pin': dbus.Byte(3)})
215+ self.EmitSignal(iface, "PropertyChanged", "sv",
216+ ["Retries", self.Get(iface, "Retries")])
217+ else:
218+ retries = self.Get(iface, "Retries")['pin']
219+ if (retries > 0):
220+ self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)})
221+ self.EmitSignal(iface, "PropertyChanged", "sv",
222+ ["Retries", self.Get(iface, "Retries")])
223+ raise dbus.exceptions.DBusException("", "Failed",
224+ name="org.ofono.Error.Failed")
225+ print('XXX UnlockPin', self.Get(iface, "Retries")['pin'])
226+
227+
228+@dbus.service.method('org.ofono.SimManager',
229+ in_signature='sss', out_signature='')
230+def ChangePin(self, pin_type, pin, pin2):
231+ iface = 'org.ofono.SimManager'
232+ print('XXX ChangePin', pin_type, pin, pin2)
233+
234+ if (pin == self.sim_pin):
235+ print('XXX ChangePin pin matches')
236+ self.sim_pin = pin2
237+ self.Set(iface, "Retries", {'pin': dbus.Byte(3)})
238+ self.EmitSignal(iface, "PropertyChanged", "sv",
239+ ["Retries", self.Get(iface, "Retries")])
240+ else:
241+ retries = self.Get(iface, "Retries")['pin']
242+ if (retries > 0):
243+ self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)})
244+ self.EmitSignal(iface, "PropertyChanged", "sv",
245+ ["Retries", self.Get(iface, "Retries")])
246+ raise dbus.exceptions.DBusException("", "Failed",
247+ name="org.ofono.Error.Failed")
248+
249+
250+@dbus.service.method('org.ofono.SimManager',
251+ in_signature='ss', out_signature='')
252+def EnterPin(self, pin_type, pin):
253+ iface = 'org.ofono.SimManager'
254+ print('XXX EnterPin', pin)
255+
256+ if (pin == self.sim_pin):
257+ print('XXX EnterPin pin matches')
258+ self.Set(iface, "Retries", {'pin': dbus.Byte(3)})
259+ self.EmitSignal(iface, "PropertyChanged", "sv",
260+ ["Retries", self.Get(iface, "Retries")])
261+ else:
262+ retries = self.Get(iface, "Retries")['pin']
263+ if (retries > 0):
264+ self.Set(iface, "Retries", {'pin': dbus.Byte(retries - 1)})
265+ self.EmitSignal(iface, "PropertyChanged", "sv",
266+ ["Retries", self.Get(iface, "Retries")])
267+ raise dbus.exceptions.DBusException("", "Failed",
268+ name="org.ofono.Error.Failed")
269+
270+
271 def add_voice_call_api(mock):
272 '''Add org.ofono.VoiceCallManager API to a mock'''
273

Subscribers

People subscribed via source and target branches