Merge lp:~unity-team/unity8/lockscreen-password into lp:unity8

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
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
=== modified file 'debian/control'
--- debian/control 2016-01-05 09:57:15 +0000
+++ debian/control 2016-01-13 14:35:29 +0000
@@ -184,7 +184,7 @@
184Architecture: any184Architecture: any
185Multi-Arch: same185Multi-Arch: same
186Pre-Depends: ${misc:Pre-Depends},186Pre-Depends: ${misc:Pre-Depends},
187Depends: accountsservice-ubuntu-schemas (>= 0.0.3),187Depends: accountsservice-ubuntu-schemas (>= 0.0.5),
188 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),188 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
189 libhardware2,189 libhardware2,
190 pay-service,190 pay-service,
191191
=== modified file 'plugins/AccountsService/AccountsService.cpp'
--- plugins/AccountsService/AccountsService.cpp 2015-10-26 14:05:14 +0000
+++ plugins/AccountsService/AccountsService.cpp 2016-01-13 14:35:29 +0000
@@ -30,7 +30,9 @@
30 m_enableLauncherWhileLocked(false),30 m_enableLauncherWhileLocked(false),
31 m_enableIndicatorsWhileLocked(false),31 m_enableIndicatorsWhileLocked(false),
32 m_statsWelcomeScreen(false),32 m_statsWelcomeScreen(false),
33 m_lockscreenPassword(""),
33 m_passwordDisplayHint(Keyboard),34 m_passwordDisplayHint(Keyboard),
35 m_synthesizedDisplayHint(Keyboard),
34 m_failedLogins(0),36 m_failedLogins(0),
35 m_hereEnabled(false),37 m_hereEnabled(false),
36 m_hereLicensePath() // null means not set yet38 m_hereLicensePath() // null means not set yet
@@ -59,6 +61,7 @@
59 updateEnableIndicatorsWhileLocked(false);61 updateEnableIndicatorsWhileLocked(false);
60 updateBackgroundFile(false);62 updateBackgroundFile(false);
61 updateStatsWelcomeScreen(false);63 updateStatsWelcomeScreen(false);
64 updateLockscreenPassword(false);
62 updatePasswordDisplayHint(false);65 updatePasswordDisplayHint(false);
63 updateFailedLogins(false);66 updateFailedLogins(false);
64 updateHereEnabled(false);67 updateHereEnabled(false);
@@ -102,7 +105,7 @@
102105
103AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const106AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const
104{107{
105 return m_passwordDisplayHint;108 return m_synthesizedDisplayHint;
106}109}
107110
108bool AccountsService::hereEnabled() const111bool AccountsService::hereEnabled() const
@@ -275,6 +278,56 @@
275 }278 }
276}279}
277280
281void AccountsService::synthesizeDisplayHint()
282{
283 // There are actually two properties that control whether the password
284 // prompt should be shown as a pin entry or passphrase entry and here we
285 // do the math so that the upper layers don't have to.
286
287 PasswordDisplayHint hint;
288 if (m_lockscreenPassword.startsWith(QStringLiteral("pin:"))) {
289 hint = PasswordDisplayHint::Numeric;
290 } else if (m_lockscreenPassword.isEmpty()) {
291 hint = m_passwordDisplayHint;
292 } else {
293 hint = PasswordDisplayHint::Keyboard;
294 }
295
296 if (m_synthesizedDisplayHint != hint) {
297 m_synthesizedDisplayHint = hint;
298 Q_EMIT passwordDisplayHintChanged();
299 }
300}
301
302void AccountsService::updateLockscreenPassword(bool async)
303{
304 QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
305 QStringLiteral("com.ubuntu.AccountsService.SecurityPrivacy"),
306 QStringLiteral("LockscreenPassword"));
307 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
308
309 connect(watcher, &QDBusPendingCallWatcher::finished,
310 this, [this](QDBusPendingCallWatcher* watcher) {
311
312 QDBusPendingReply<QVariant> reply = *watcher;
313 watcher->deleteLater();
314 if (reply.isError()) {
315 qWarning() << "Failed to get 'LockscreenPassword' property - " << reply.error().message();
316 return;
317 }
318
319 const QString lockscreenPassword = reply.value().toString();
320 if (m_lockscreenPassword != lockscreenPassword) {
321 m_lockscreenPassword = lockscreenPassword;
322 synthesizeDisplayHint();
323 }
324 });
325 if (!async) {
326 watcher->waitForFinished();
327 delete watcher;
328 }
329}
330
278void AccountsService::updatePasswordDisplayHint(bool async)331void AccountsService::updatePasswordDisplayHint(bool async)
279{332{
280 QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,333 QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
@@ -295,7 +348,7 @@
295 const PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().toInt();348 const PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().toInt();
296 if (m_passwordDisplayHint != passwordDisplayHint) {349 if (m_passwordDisplayHint != passwordDisplayHint) {
297 m_passwordDisplayHint = passwordDisplayHint;350 m_passwordDisplayHint = passwordDisplayHint;
298 Q_EMIT passwordDisplayHintChanged();351 synthesizeDisplayHint();
299 }352 }
300 });353 });
301 if (!async) {354 if (!async) {
@@ -428,6 +481,9 @@
428 updateStatsWelcomeScreen();481 updateStatsWelcomeScreen();
429 }482 }
430 } else if (interface == QLatin1String("com.ubuntu.AccountsService.SecurityPrivacy")) {483 } else if (interface == QLatin1String("com.ubuntu.AccountsService.SecurityPrivacy")) {
484 if (changed.contains(QStringLiteral("LockscreenPassword"))) {
485 updateLockscreenPassword();
486 }
431 if (changed.contains(QStringLiteral("PasswordDisplayHint"))) {487 if (changed.contains(QStringLiteral("PasswordDisplayHint"))) {
432 updatePasswordDisplayHint();488 updatePasswordDisplayHint();
433 }489 }
434490
=== modified file 'plugins/AccountsService/AccountsService.h'
--- plugins/AccountsService/AccountsService.h 2015-06-11 23:45:12 +0000
+++ plugins/AccountsService/AccountsService.h 2016-01-13 14:35:29 +0000
@@ -113,11 +113,14 @@
113 void updateEnableIndicatorsWhileLocked(bool async = true);113 void updateEnableIndicatorsWhileLocked(bool async = true);
114 void updateBackgroundFile(bool async = true);114 void updateBackgroundFile(bool async = true);
115 void updateStatsWelcomeScreen(bool async = true);115 void updateStatsWelcomeScreen(bool async = true);
116 void updateLockscreenPassword(bool async = true);
116 void updatePasswordDisplayHint(bool async = true);117 void updatePasswordDisplayHint(bool async = true);
117 void updateFailedLogins(bool async = true);118 void updateFailedLogins(bool async = true);
118 void updateHereEnabled(bool async = true);119 void updateHereEnabled(bool async = true);
119 void updateHereLicensePath(bool async = true);120 void updateHereLicensePath(bool async = true);
120121
122 void synthesizeDisplayHint();
123
121 AccountsServiceDBusAdaptor *m_service;124 AccountsServiceDBusAdaptor *m_service;
122 QString m_user;125 QString m_user;
123 bool m_demoEdges;126 bool m_demoEdges;
@@ -125,7 +128,9 @@
125 bool m_enableIndicatorsWhileLocked;128 bool m_enableIndicatorsWhileLocked;
126 QString m_backgroundFile;129 QString m_backgroundFile;
127 bool m_statsWelcomeScreen;130 bool m_statsWelcomeScreen;
131 QString m_lockscreenPassword;
128 PasswordDisplayHint m_passwordDisplayHint;132 PasswordDisplayHint m_passwordDisplayHint;
133 PasswordDisplayHint m_synthesizedDisplayHint;
129 uint m_failedLogins;134 uint m_failedLogins;
130 bool m_hereEnabled;135 bool m_hereEnabled;
131 QString m_hereLicensePath;136 QString m_hereLicensePath;
132137
=== modified file 'tests/plugins/AccountsService/PropertiesServer.cpp'
--- tests/plugins/AccountsService/PropertiesServer.cpp 2015-10-26 14:05:14 +0000
+++ tests/plugins/AccountsService/PropertiesServer.cpp 2016-01-13 14:35:29 +0000
@@ -84,6 +84,7 @@
84 m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true;84 m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true;
85 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true;85 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true;
86 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true;86 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true;
87 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["LockscreenPassword"] = QStringLiteral("");
87 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard;88 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard;
88 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseAccepted"] = false;89 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseAccepted"] = false;
89 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseBasePath"] = "";90 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseBasePath"] = "";
9091
=== modified file 'tests/plugins/AccountsService/client.cpp'
--- tests/plugins/AccountsService/client.cpp 2015-10-26 14:05:14 +0000
+++ tests/plugins/AccountsService/client.cpp 2016-01-13 14:35:29 +0000
@@ -107,7 +107,7 @@
107 QCOMPARE(session.hereEnabled(), true);107 QCOMPARE(session.hereEnabled(), true);
108 }108 }
109109
110 void testAsynchornousChangeForDemoEdges()110 void testAsynchronousChangeForDemoEdges()
111 {111 {
112 AccountsService session(this, QTest::currentTestFunction());112 AccountsService session(this, QTest::currentTestFunction());
113113
@@ -119,7 +119,7 @@
119 QTRY_COMPARE(session.demoEdges(), true);119 QTRY_COMPARE(session.demoEdges(), true);
120 }120 }
121121
122 void testAsynchornousChangeForFailedLogins()122 void testAsynchronousChangeForFailedLogins()
123 {123 {
124 AccountsService session(this, QTest::currentTestFunction());124 AccountsService session(this, QTest::currentTestFunction());
125125
@@ -131,7 +131,7 @@
131 QTRY_COMPARE(session.failedLogins(), (uint)5);131 QTRY_COMPARE(session.failedLogins(), (uint)5);
132 }132 }
133133
134 void testAsynchornousChangeForStatsWelcomeScreen()134 void testAsynchronousChangeForStatsWelcomeScreen()
135 {135 {
136 AccountsService session(this, QTest::currentTestFunction());136 AccountsService session(this, QTest::currentTestFunction());
137137
@@ -143,7 +143,7 @@
143 QTRY_COMPARE(session.statsWelcomeScreen(), false);143 QTRY_COMPARE(session.statsWelcomeScreen(), false);
144 }144 }
145145
146 void testAsynchornousChangeForStatsEnableLauncherWhileLocked()146 void testAsynchronousChangeForEnableLauncherWhileLocked()
147 {147 {
148 AccountsService session(this, QTest::currentTestFunction());148 AccountsService session(this, QTest::currentTestFunction());
149149
@@ -155,7 +155,7 @@
155 QTRY_COMPARE(session.enableLauncherWhileLocked(), false);155 QTRY_COMPARE(session.enableLauncherWhileLocked(), false);
156 }156 }
157157
158 void testAsynchornousChangeForStatsEnableIndicatorsWhileLocked()158 void testAsynchronousChangeForEnableIndicatorsWhileLocked()
159 {159 {
160 AccountsService session(this, QTest::currentTestFunction());160 AccountsService session(this, QTest::currentTestFunction());
161161
@@ -167,19 +167,50 @@
167 QTRY_COMPARE(session.enableIndicatorsWhileLocked(), false);167 QTRY_COMPARE(session.enableIndicatorsWhileLocked(), false);
168 }168 }
169169
170 void testAsynchornousChangeForStatsPasswordDisplayHint()170 void testAsynchronousChangeForPasswordDisplayHint()
171 {171 {
172 AccountsService session(this, QTest::currentTestFunction());172 AccountsService session(this, QTest::currentTestFunction());
173173
174 QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);174 QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
175 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",175 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
176 "com.ubuntu.AccountsService.SecurityPrivacy",176 "com.ubuntu.AccountsService.SecurityPrivacy",
177 "PasswordDisplayHint",177 "PasswordDisplayHint",
178 dbusVariant(AccountsService::Numeric)));178 dbusVariant(AccountsService::Numeric)));
179 QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric);179 QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric);
180 }180 }
181181
182 void testAsynchornousChangeForStatsLicenseAccepted()182 void testAsynchronousChangeForLockscreenPassword()
183 {
184 AccountsService session(this, QTest::currentTestFunction());
185
186 QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
187 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
188 "com.ubuntu.AccountsService.SecurityPrivacy",
189 "LockscreenPassword",
190 dbusVariant("pin:cryptedpassword")));
191 QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric);
192 }
193
194 void testLockscreenPasswordOverridesDisplayHint()
195 {
196 AccountsService session(this, QTest::currentTestFunction());
197
198 QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
199
200 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
201 "com.ubuntu.AccountsService.SecurityPrivacy",
202 "PasswordDisplayHint",
203 dbusVariant(AccountsService::Numeric)));
204 QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric);
205
206 ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
207 "com.ubuntu.AccountsService.SecurityPrivacy",
208 "LockscreenPassword",
209 dbusVariant("system")));
210 QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
211 }
212
213 void testAsynchronousChangeForLicenseAccepted()
183 {214 {
184 AccountsService session(this, QTest::currentTestFunction());215 AccountsService session(this, QTest::currentTestFunction());
185216
@@ -191,7 +222,7 @@
191 QTRY_COMPARE(session.hereEnabled(), true);222 QTRY_COMPARE(session.hereEnabled(), true);
192 }223 }
193224
194 void testAsynchornousChangeForLicenseBasePath()225 void testAsynchronousChangeForLicenseBasePath()
195 {226 {
196 AccountsService session(this, QTest::currentTestFunction());227 AccountsService session(this, QTest::currentTestFunction());
197228
@@ -203,7 +234,7 @@
203 QTRY_COMPARE(session.hereLicensePath(), QString("/"));234 QTRY_COMPARE(session.hereLicensePath(), QString("/"));
204 }235 }
205236
206 void testAsynchornousChangeForStatsBackgroundFile()237 void testAsynchronousChangeForBackgroundFile()
207 {238 {
208 AccountsService session(this, QTest::currentTestFunction());239 AccountsService session(this, QTest::currentTestFunction());
209240

Subscribers

People subscribed via source and target branches