Merge lp:~unity-team/unity8/lockscreen-password into lp:unity8
- lockscreen-password
- Merge into trunk
Proposed by
Michael Terry
Status: | Work in progress |
---|---|
Proposed branch: | lp:~unity-team/unity8/lockscreen-password |
Merge into: | lp:unity8 |
Diff against target: |
290 lines (+116/-23) 5 files modified
debian/control (+1/-1) plugins/AccountsService/AccountsService.cpp (+58/-2) plugins/AccountsService/AccountsService.h (+5/-0) tests/plugins/AccountsService/PropertiesServer.cpp (+1/-0) tests/plugins/AccountsService/client.cpp (+51/-20) |
To merge this branch: | bzr merge lp:~unity-team/unity8/lockscreen-password |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email: mp+282382@code.launchpad.net |
Commit message
WIP
Description of the change
WIP
To post a comment you must log in.
- 2115. By Michael Terry
-
Add a couple tets and fix build
Unmerged revisions
- 2115. By Michael Terry
-
Add a couple tets and fix build
- 2114. By Michael Terry
-
Initial support for a split lockscreen password
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2016-01-05 09:57:15 +0000 | |||
3 | +++ debian/control 2016-01-13 14:35:29 +0000 | |||
4 | @@ -184,7 +184,7 @@ | |||
5 | 184 | Architecture: any | 184 | Architecture: any |
6 | 185 | Multi-Arch: same | 185 | Multi-Arch: same |
7 | 186 | Pre-Depends: ${misc:Pre-Depends}, | 186 | Pre-Depends: ${misc:Pre-Depends}, |
9 | 187 | Depends: accountsservice-ubuntu-schemas (>= 0.0.3), | 187 | Depends: accountsservice-ubuntu-schemas (>= 0.0.5), |
10 | 188 | gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815), | 188 | gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815), |
11 | 189 | libhardware2, | 189 | libhardware2, |
12 | 190 | pay-service, | 190 | pay-service, |
13 | 191 | 191 | ||
14 | === modified file 'plugins/AccountsService/AccountsService.cpp' | |||
15 | --- plugins/AccountsService/AccountsService.cpp 2015-10-26 14:05:14 +0000 | |||
16 | +++ plugins/AccountsService/AccountsService.cpp 2016-01-13 14:35:29 +0000 | |||
17 | @@ -30,7 +30,9 @@ | |||
18 | 30 | m_enableLauncherWhileLocked(false), | 30 | m_enableLauncherWhileLocked(false), |
19 | 31 | m_enableIndicatorsWhileLocked(false), | 31 | m_enableIndicatorsWhileLocked(false), |
20 | 32 | m_statsWelcomeScreen(false), | 32 | m_statsWelcomeScreen(false), |
21 | 33 | m_lockscreenPassword(""), | ||
22 | 33 | m_passwordDisplayHint(Keyboard), | 34 | m_passwordDisplayHint(Keyboard), |
23 | 35 | m_synthesizedDisplayHint(Keyboard), | ||
24 | 34 | m_failedLogins(0), | 36 | m_failedLogins(0), |
25 | 35 | m_hereEnabled(false), | 37 | m_hereEnabled(false), |
26 | 36 | m_hereLicensePath() // null means not set yet | 38 | m_hereLicensePath() // null means not set yet |
27 | @@ -59,6 +61,7 @@ | |||
28 | 59 | updateEnableIndicatorsWhileLocked(false); | 61 | updateEnableIndicatorsWhileLocked(false); |
29 | 60 | updateBackgroundFile(false); | 62 | updateBackgroundFile(false); |
30 | 61 | updateStatsWelcomeScreen(false); | 63 | updateStatsWelcomeScreen(false); |
31 | 64 | updateLockscreenPassword(false); | ||
32 | 62 | updatePasswordDisplayHint(false); | 65 | updatePasswordDisplayHint(false); |
33 | 63 | updateFailedLogins(false); | 66 | updateFailedLogins(false); |
34 | 64 | updateHereEnabled(false); | 67 | updateHereEnabled(false); |
35 | @@ -102,7 +105,7 @@ | |||
36 | 102 | 105 | ||
37 | 103 | AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const | 106 | AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const |
38 | 104 | { | 107 | { |
40 | 105 | return m_passwordDisplayHint; | 108 | return m_synthesizedDisplayHint; |
41 | 106 | } | 109 | } |
42 | 107 | 110 | ||
43 | 108 | bool AccountsService::hereEnabled() const | 111 | bool AccountsService::hereEnabled() const |
44 | @@ -275,6 +278,56 @@ | |||
45 | 275 | } | 278 | } |
46 | 276 | } | 279 | } |
47 | 277 | 280 | ||
48 | 281 | void AccountsService::synthesizeDisplayHint() | ||
49 | 282 | { | ||
50 | 283 | // There are actually two properties that control whether the password | ||
51 | 284 | // prompt should be shown as a pin entry or passphrase entry and here we | ||
52 | 285 | // do the math so that the upper layers don't have to. | ||
53 | 286 | |||
54 | 287 | PasswordDisplayHint hint; | ||
55 | 288 | if (m_lockscreenPassword.startsWith(QStringLiteral("pin:"))) { | ||
56 | 289 | hint = PasswordDisplayHint::Numeric; | ||
57 | 290 | } else if (m_lockscreenPassword.isEmpty()) { | ||
58 | 291 | hint = m_passwordDisplayHint; | ||
59 | 292 | } else { | ||
60 | 293 | hint = PasswordDisplayHint::Keyboard; | ||
61 | 294 | } | ||
62 | 295 | |||
63 | 296 | if (m_synthesizedDisplayHint != hint) { | ||
64 | 297 | m_synthesizedDisplayHint = hint; | ||
65 | 298 | Q_EMIT passwordDisplayHintChanged(); | ||
66 | 299 | } | ||
67 | 300 | } | ||
68 | 301 | |||
69 | 302 | void AccountsService::updateLockscreenPassword(bool async) | ||
70 | 303 | { | ||
71 | 304 | QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user, | ||
72 | 305 | QStringLiteral("com.ubuntu.AccountsService.SecurityPrivacy"), | ||
73 | 306 | QStringLiteral("LockscreenPassword")); | ||
74 | 307 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this); | ||
75 | 308 | |||
76 | 309 | connect(watcher, &QDBusPendingCallWatcher::finished, | ||
77 | 310 | this, [this](QDBusPendingCallWatcher* watcher) { | ||
78 | 311 | |||
79 | 312 | QDBusPendingReply<QVariant> reply = *watcher; | ||
80 | 313 | watcher->deleteLater(); | ||
81 | 314 | if (reply.isError()) { | ||
82 | 315 | qWarning() << "Failed to get 'LockscreenPassword' property - " << reply.error().message(); | ||
83 | 316 | return; | ||
84 | 317 | } | ||
85 | 318 | |||
86 | 319 | const QString lockscreenPassword = reply.value().toString(); | ||
87 | 320 | if (m_lockscreenPassword != lockscreenPassword) { | ||
88 | 321 | m_lockscreenPassword = lockscreenPassword; | ||
89 | 322 | synthesizeDisplayHint(); | ||
90 | 323 | } | ||
91 | 324 | }); | ||
92 | 325 | if (!async) { | ||
93 | 326 | watcher->waitForFinished(); | ||
94 | 327 | delete watcher; | ||
95 | 328 | } | ||
96 | 329 | } | ||
97 | 330 | |||
98 | 278 | void AccountsService::updatePasswordDisplayHint(bool async) | 331 | void AccountsService::updatePasswordDisplayHint(bool async) |
99 | 279 | { | 332 | { |
100 | 280 | QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user, | 333 | QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user, |
101 | @@ -295,7 +348,7 @@ | |||
102 | 295 | const PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().toInt(); | 348 | const PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().toInt(); |
103 | 296 | if (m_passwordDisplayHint != passwordDisplayHint) { | 349 | if (m_passwordDisplayHint != passwordDisplayHint) { |
104 | 297 | m_passwordDisplayHint = passwordDisplayHint; | 350 | m_passwordDisplayHint = passwordDisplayHint; |
106 | 298 | Q_EMIT passwordDisplayHintChanged(); | 351 | synthesizeDisplayHint(); |
107 | 299 | } | 352 | } |
108 | 300 | }); | 353 | }); |
109 | 301 | if (!async) { | 354 | if (!async) { |
110 | @@ -428,6 +481,9 @@ | |||
111 | 428 | updateStatsWelcomeScreen(); | 481 | updateStatsWelcomeScreen(); |
112 | 429 | } | 482 | } |
113 | 430 | } else if (interface == QLatin1String("com.ubuntu.AccountsService.SecurityPrivacy")) { | 483 | } else if (interface == QLatin1String("com.ubuntu.AccountsService.SecurityPrivacy")) { |
114 | 484 | if (changed.contains(QStringLiteral("LockscreenPassword"))) { | ||
115 | 485 | updateLockscreenPassword(); | ||
116 | 486 | } | ||
117 | 431 | if (changed.contains(QStringLiteral("PasswordDisplayHint"))) { | 487 | if (changed.contains(QStringLiteral("PasswordDisplayHint"))) { |
118 | 432 | updatePasswordDisplayHint(); | 488 | updatePasswordDisplayHint(); |
119 | 433 | } | 489 | } |
120 | 434 | 490 | ||
121 | === modified file 'plugins/AccountsService/AccountsService.h' | |||
122 | --- plugins/AccountsService/AccountsService.h 2015-06-11 23:45:12 +0000 | |||
123 | +++ plugins/AccountsService/AccountsService.h 2016-01-13 14:35:29 +0000 | |||
124 | @@ -113,11 +113,14 @@ | |||
125 | 113 | void updateEnableIndicatorsWhileLocked(bool async = true); | 113 | void updateEnableIndicatorsWhileLocked(bool async = true); |
126 | 114 | void updateBackgroundFile(bool async = true); | 114 | void updateBackgroundFile(bool async = true); |
127 | 115 | void updateStatsWelcomeScreen(bool async = true); | 115 | void updateStatsWelcomeScreen(bool async = true); |
128 | 116 | void updateLockscreenPassword(bool async = true); | ||
129 | 116 | void updatePasswordDisplayHint(bool async = true); | 117 | void updatePasswordDisplayHint(bool async = true); |
130 | 117 | void updateFailedLogins(bool async = true); | 118 | void updateFailedLogins(bool async = true); |
131 | 118 | void updateHereEnabled(bool async = true); | 119 | void updateHereEnabled(bool async = true); |
132 | 119 | void updateHereLicensePath(bool async = true); | 120 | void updateHereLicensePath(bool async = true); |
133 | 120 | 121 | ||
134 | 122 | void synthesizeDisplayHint(); | ||
135 | 123 | |||
136 | 121 | AccountsServiceDBusAdaptor *m_service; | 124 | AccountsServiceDBusAdaptor *m_service; |
137 | 122 | QString m_user; | 125 | QString m_user; |
138 | 123 | bool m_demoEdges; | 126 | bool m_demoEdges; |
139 | @@ -125,7 +128,9 @@ | |||
140 | 125 | bool m_enableIndicatorsWhileLocked; | 128 | bool m_enableIndicatorsWhileLocked; |
141 | 126 | QString m_backgroundFile; | 129 | QString m_backgroundFile; |
142 | 127 | bool m_statsWelcomeScreen; | 130 | bool m_statsWelcomeScreen; |
143 | 131 | QString m_lockscreenPassword; | ||
144 | 128 | PasswordDisplayHint m_passwordDisplayHint; | 132 | PasswordDisplayHint m_passwordDisplayHint; |
145 | 133 | PasswordDisplayHint m_synthesizedDisplayHint; | ||
146 | 129 | uint m_failedLogins; | 134 | uint m_failedLogins; |
147 | 130 | bool m_hereEnabled; | 135 | bool m_hereEnabled; |
148 | 131 | QString m_hereLicensePath; | 136 | QString m_hereLicensePath; |
149 | 132 | 137 | ||
150 | === modified file 'tests/plugins/AccountsService/PropertiesServer.cpp' | |||
151 | --- tests/plugins/AccountsService/PropertiesServer.cpp 2015-10-26 14:05:14 +0000 | |||
152 | +++ tests/plugins/AccountsService/PropertiesServer.cpp 2016-01-13 14:35:29 +0000 | |||
153 | @@ -84,6 +84,7 @@ | |||
154 | 84 | m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true; | 84 | m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true; |
155 | 85 | m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true; | 85 | m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true; |
156 | 86 | m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true; | 86 | m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true; |
157 | 87 | m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["LockscreenPassword"] = QStringLiteral(""); | ||
158 | 87 | m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard; | 88 | m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard; |
159 | 88 | m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseAccepted"] = false; | 89 | m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseAccepted"] = false; |
160 | 89 | m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseBasePath"] = ""; | 90 | m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseBasePath"] = ""; |
161 | 90 | 91 | ||
162 | === modified file 'tests/plugins/AccountsService/client.cpp' | |||
163 | --- tests/plugins/AccountsService/client.cpp 2015-10-26 14:05:14 +0000 | |||
164 | +++ tests/plugins/AccountsService/client.cpp 2016-01-13 14:35:29 +0000 | |||
165 | @@ -107,7 +107,7 @@ | |||
166 | 107 | QCOMPARE(session.hereEnabled(), true); | 107 | QCOMPARE(session.hereEnabled(), true); |
167 | 108 | } | 108 | } |
168 | 109 | 109 | ||
170 | 110 | void testAsynchornousChangeForDemoEdges() | 110 | void testAsynchronousChangeForDemoEdges() |
171 | 111 | { | 111 | { |
172 | 112 | AccountsService session(this, QTest::currentTestFunction()); | 112 | AccountsService session(this, QTest::currentTestFunction()); |
173 | 113 | 113 | ||
174 | @@ -119,7 +119,7 @@ | |||
175 | 119 | QTRY_COMPARE(session.demoEdges(), true); | 119 | QTRY_COMPARE(session.demoEdges(), true); |
176 | 120 | } | 120 | } |
177 | 121 | 121 | ||
179 | 122 | void testAsynchornousChangeForFailedLogins() | 122 | void testAsynchronousChangeForFailedLogins() |
180 | 123 | { | 123 | { |
181 | 124 | AccountsService session(this, QTest::currentTestFunction()); | 124 | AccountsService session(this, QTest::currentTestFunction()); |
182 | 125 | 125 | ||
183 | @@ -131,7 +131,7 @@ | |||
184 | 131 | QTRY_COMPARE(session.failedLogins(), (uint)5); | 131 | QTRY_COMPARE(session.failedLogins(), (uint)5); |
185 | 132 | } | 132 | } |
186 | 133 | 133 | ||
188 | 134 | void testAsynchornousChangeForStatsWelcomeScreen() | 134 | void testAsynchronousChangeForStatsWelcomeScreen() |
189 | 135 | { | 135 | { |
190 | 136 | AccountsService session(this, QTest::currentTestFunction()); | 136 | AccountsService session(this, QTest::currentTestFunction()); |
191 | 137 | 137 | ||
192 | @@ -143,7 +143,7 @@ | |||
193 | 143 | QTRY_COMPARE(session.statsWelcomeScreen(), false); | 143 | QTRY_COMPARE(session.statsWelcomeScreen(), false); |
194 | 144 | } | 144 | } |
195 | 145 | 145 | ||
197 | 146 | void testAsynchornousChangeForStatsEnableLauncherWhileLocked() | 146 | void testAsynchronousChangeForEnableLauncherWhileLocked() |
198 | 147 | { | 147 | { |
199 | 148 | AccountsService session(this, QTest::currentTestFunction()); | 148 | AccountsService session(this, QTest::currentTestFunction()); |
200 | 149 | 149 | ||
201 | @@ -155,7 +155,7 @@ | |||
202 | 155 | QTRY_COMPARE(session.enableLauncherWhileLocked(), false); | 155 | QTRY_COMPARE(session.enableLauncherWhileLocked(), false); |
203 | 156 | } | 156 | } |
204 | 157 | 157 | ||
206 | 158 | void testAsynchornousChangeForStatsEnableIndicatorsWhileLocked() | 158 | void testAsynchronousChangeForEnableIndicatorsWhileLocked() |
207 | 159 | { | 159 | { |
208 | 160 | AccountsService session(this, QTest::currentTestFunction()); | 160 | AccountsService session(this, QTest::currentTestFunction()); |
209 | 161 | 161 | ||
210 | @@ -167,19 +167,50 @@ | |||
211 | 167 | QTRY_COMPARE(session.enableIndicatorsWhileLocked(), false); | 167 | QTRY_COMPARE(session.enableIndicatorsWhileLocked(), false); |
212 | 168 | } | 168 | } |
213 | 169 | 169 | ||
227 | 170 | void testAsynchornousChangeForStatsPasswordDisplayHint() | 170 | void testAsynchronousChangeForPasswordDisplayHint() |
228 | 171 | { | 171 | { |
229 | 172 | AccountsService session(this, QTest::currentTestFunction()); | 172 | AccountsService session(this, QTest::currentTestFunction()); |
230 | 173 | 173 | ||
231 | 174 | QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard); | 174 | QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard); |
232 | 175 | ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set", | 175 | ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set", |
233 | 176 | "com.ubuntu.AccountsService.SecurityPrivacy", | 176 | "com.ubuntu.AccountsService.SecurityPrivacy", |
234 | 177 | "PasswordDisplayHint", | 177 | "PasswordDisplayHint", |
235 | 178 | dbusVariant(AccountsService::Numeric))); | 178 | dbusVariant(AccountsService::Numeric))); |
236 | 179 | QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric); | 179 | QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric); |
237 | 180 | } | 180 | } |
238 | 181 | 181 | ||
239 | 182 | void testAsynchornousChangeForStatsLicenseAccepted() | 182 | void testAsynchronousChangeForLockscreenPassword() |
240 | 183 | { | ||
241 | 184 | AccountsService session(this, QTest::currentTestFunction()); | ||
242 | 185 | |||
243 | 186 | QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard); | ||
244 | 187 | ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set", | ||
245 | 188 | "com.ubuntu.AccountsService.SecurityPrivacy", | ||
246 | 189 | "LockscreenPassword", | ||
247 | 190 | dbusVariant("pin:cryptedpassword"))); | ||
248 | 191 | QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric); | ||
249 | 192 | } | ||
250 | 193 | |||
251 | 194 | void testLockscreenPasswordOverridesDisplayHint() | ||
252 | 195 | { | ||
253 | 196 | AccountsService session(this, QTest::currentTestFunction()); | ||
254 | 197 | |||
255 | 198 | QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard); | ||
256 | 199 | |||
257 | 200 | ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set", | ||
258 | 201 | "com.ubuntu.AccountsService.SecurityPrivacy", | ||
259 | 202 | "PasswordDisplayHint", | ||
260 | 203 | dbusVariant(AccountsService::Numeric))); | ||
261 | 204 | QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric); | ||
262 | 205 | |||
263 | 206 | ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set", | ||
264 | 207 | "com.ubuntu.AccountsService.SecurityPrivacy", | ||
265 | 208 | "LockscreenPassword", | ||
266 | 209 | dbusVariant("system"))); | ||
267 | 210 | QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Keyboard); | ||
268 | 211 | } | ||
269 | 212 | |||
270 | 213 | void testAsynchronousChangeForLicenseAccepted() | ||
271 | 183 | { | 214 | { |
272 | 184 | AccountsService session(this, QTest::currentTestFunction()); | 215 | AccountsService session(this, QTest::currentTestFunction()); |
273 | 185 | 216 | ||
274 | @@ -191,7 +222,7 @@ | |||
275 | 191 | QTRY_COMPARE(session.hereEnabled(), true); | 222 | QTRY_COMPARE(session.hereEnabled(), true); |
276 | 192 | } | 223 | } |
277 | 193 | 224 | ||
279 | 194 | void testAsynchornousChangeForLicenseBasePath() | 225 | void testAsynchronousChangeForLicenseBasePath() |
280 | 195 | { | 226 | { |
281 | 196 | AccountsService session(this, QTest::currentTestFunction()); | 227 | AccountsService session(this, QTest::currentTestFunction()); |
282 | 197 | 228 | ||
283 | @@ -203,7 +234,7 @@ | |||
284 | 203 | QTRY_COMPARE(session.hereLicensePath(), QString("/")); | 234 | QTRY_COMPARE(session.hereLicensePath(), QString("/")); |
285 | 204 | } | 235 | } |
286 | 205 | 236 | ||
288 | 206 | void testAsynchornousChangeForStatsBackgroundFile() | 237 | void testAsynchronousChangeForBackgroundFile() |
289 | 207 | { | 238 | { |
290 | 208 | AccountsService session(this, QTest::currentTestFunction()); | 239 | AccountsService session(this, QTest::currentTestFunction()); |
291 | 209 | 240 |