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
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 Architecture: any
6 Multi-Arch: same
7 Pre-Depends: ${misc:Pre-Depends},
8-Depends: accountsservice-ubuntu-schemas (>= 0.0.3),
9+Depends: accountsservice-ubuntu-schemas (>= 0.0.5),
10 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
11 libhardware2,
12 pay-service,
13
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 m_enableLauncherWhileLocked(false),
19 m_enableIndicatorsWhileLocked(false),
20 m_statsWelcomeScreen(false),
21+ m_lockscreenPassword(""),
22 m_passwordDisplayHint(Keyboard),
23+ m_synthesizedDisplayHint(Keyboard),
24 m_failedLogins(0),
25 m_hereEnabled(false),
26 m_hereLicensePath() // null means not set yet
27@@ -59,6 +61,7 @@
28 updateEnableIndicatorsWhileLocked(false);
29 updateBackgroundFile(false);
30 updateStatsWelcomeScreen(false);
31+ updateLockscreenPassword(false);
32 updatePasswordDisplayHint(false);
33 updateFailedLogins(false);
34 updateHereEnabled(false);
35@@ -102,7 +105,7 @@
36
37 AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() const
38 {
39- return m_passwordDisplayHint;
40+ return m_synthesizedDisplayHint;
41 }
42
43 bool AccountsService::hereEnabled() const
44@@ -275,6 +278,56 @@
45 }
46 }
47
48+void AccountsService::synthesizeDisplayHint()
49+{
50+ // There are actually two properties that control whether the password
51+ // prompt should be shown as a pin entry or passphrase entry and here we
52+ // do the math so that the upper layers don't have to.
53+
54+ PasswordDisplayHint hint;
55+ if (m_lockscreenPassword.startsWith(QStringLiteral("pin:"))) {
56+ hint = PasswordDisplayHint::Numeric;
57+ } else if (m_lockscreenPassword.isEmpty()) {
58+ hint = m_passwordDisplayHint;
59+ } else {
60+ hint = PasswordDisplayHint::Keyboard;
61+ }
62+
63+ if (m_synthesizedDisplayHint != hint) {
64+ m_synthesizedDisplayHint = hint;
65+ Q_EMIT passwordDisplayHintChanged();
66+ }
67+}
68+
69+void AccountsService::updateLockscreenPassword(bool async)
70+{
71+ QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
72+ QStringLiteral("com.ubuntu.AccountsService.SecurityPrivacy"),
73+ QStringLiteral("LockscreenPassword"));
74+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply, this);
75+
76+ connect(watcher, &QDBusPendingCallWatcher::finished,
77+ this, [this](QDBusPendingCallWatcher* watcher) {
78+
79+ QDBusPendingReply<QVariant> reply = *watcher;
80+ watcher->deleteLater();
81+ if (reply.isError()) {
82+ qWarning() << "Failed to get 'LockscreenPassword' property - " << reply.error().message();
83+ return;
84+ }
85+
86+ const QString lockscreenPassword = reply.value().toString();
87+ if (m_lockscreenPassword != lockscreenPassword) {
88+ m_lockscreenPassword = lockscreenPassword;
89+ synthesizeDisplayHint();
90+ }
91+ });
92+ if (!async) {
93+ watcher->waitForFinished();
94+ delete watcher;
95+ }
96+}
97+
98 void AccountsService::updatePasswordDisplayHint(bool async)
99 {
100 QDBusPendingCall pendingReply = m_service->getUserPropertyAsync(m_user,
101@@ -295,7 +348,7 @@
102 const PasswordDisplayHint passwordDisplayHint = (PasswordDisplayHint)reply.value().toInt();
103 if (m_passwordDisplayHint != passwordDisplayHint) {
104 m_passwordDisplayHint = passwordDisplayHint;
105- Q_EMIT passwordDisplayHintChanged();
106+ synthesizeDisplayHint();
107 }
108 });
109 if (!async) {
110@@ -428,6 +481,9 @@
111 updateStatsWelcomeScreen();
112 }
113 } else if (interface == QLatin1String("com.ubuntu.AccountsService.SecurityPrivacy")) {
114+ if (changed.contains(QStringLiteral("LockscreenPassword"))) {
115+ updateLockscreenPassword();
116+ }
117 if (changed.contains(QStringLiteral("PasswordDisplayHint"))) {
118 updatePasswordDisplayHint();
119 }
120
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 void updateEnableIndicatorsWhileLocked(bool async = true);
126 void updateBackgroundFile(bool async = true);
127 void updateStatsWelcomeScreen(bool async = true);
128+ void updateLockscreenPassword(bool async = true);
129 void updatePasswordDisplayHint(bool async = true);
130 void updateFailedLogins(bool async = true);
131 void updateHereEnabled(bool async = true);
132 void updateHereLicensePath(bool async = true);
133
134+ void synthesizeDisplayHint();
135+
136 AccountsServiceDBusAdaptor *m_service;
137 QString m_user;
138 bool m_demoEdges;
139@@ -125,7 +128,9 @@
140 bool m_enableIndicatorsWhileLocked;
141 QString m_backgroundFile;
142 bool m_statsWelcomeScreen;
143+ QString m_lockscreenPassword;
144 PasswordDisplayHint m_passwordDisplayHint;
145+ PasswordDisplayHint m_synthesizedDisplayHint;
146 uint m_failedLogins;
147 bool m_hereEnabled;
148 QString m_hereLicensePath;
149
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 m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true;
155 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true;
156 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true;
157+ m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["LockscreenPassword"] = QStringLiteral("");
158 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard;
159 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseAccepted"] = false;
160 m_properties["com.ubuntu.location.providers.here.AccountsService"]["LicenseBasePath"] = "";
161
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 QCOMPARE(session.hereEnabled(), true);
167 }
168
169- void testAsynchornousChangeForDemoEdges()
170+ void testAsynchronousChangeForDemoEdges()
171 {
172 AccountsService session(this, QTest::currentTestFunction());
173
174@@ -119,7 +119,7 @@
175 QTRY_COMPARE(session.demoEdges(), true);
176 }
177
178- void testAsynchornousChangeForFailedLogins()
179+ void testAsynchronousChangeForFailedLogins()
180 {
181 AccountsService session(this, QTest::currentTestFunction());
182
183@@ -131,7 +131,7 @@
184 QTRY_COMPARE(session.failedLogins(), (uint)5);
185 }
186
187- void testAsynchornousChangeForStatsWelcomeScreen()
188+ void testAsynchronousChangeForStatsWelcomeScreen()
189 {
190 AccountsService session(this, QTest::currentTestFunction());
191
192@@ -143,7 +143,7 @@
193 QTRY_COMPARE(session.statsWelcomeScreen(), false);
194 }
195
196- void testAsynchornousChangeForStatsEnableLauncherWhileLocked()
197+ void testAsynchronousChangeForEnableLauncherWhileLocked()
198 {
199 AccountsService session(this, QTest::currentTestFunction());
200
201@@ -155,7 +155,7 @@
202 QTRY_COMPARE(session.enableLauncherWhileLocked(), false);
203 }
204
205- void testAsynchornousChangeForStatsEnableIndicatorsWhileLocked()
206+ void testAsynchronousChangeForEnableIndicatorsWhileLocked()
207 {
208 AccountsService session(this, QTest::currentTestFunction());
209
210@@ -167,19 +167,50 @@
211 QTRY_COMPARE(session.enableIndicatorsWhileLocked(), false);
212 }
213
214- void testAsynchornousChangeForStatsPasswordDisplayHint()
215- {
216- AccountsService session(this, QTest::currentTestFunction());
217-
218- QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
219- ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
220- "com.ubuntu.AccountsService.SecurityPrivacy",
221- "PasswordDisplayHint",
222- dbusVariant(AccountsService::Numeric)));
223- QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric);
224- }
225-
226- void testAsynchornousChangeForStatsLicenseAccepted()
227+ void testAsynchronousChangeForPasswordDisplayHint()
228+ {
229+ AccountsService session(this, QTest::currentTestFunction());
230+
231+ QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
232+ ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
233+ "com.ubuntu.AccountsService.SecurityPrivacy",
234+ "PasswordDisplayHint",
235+ dbusVariant(AccountsService::Numeric)));
236+ QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric);
237+ }
238+
239+ void testAsynchronousChangeForLockscreenPassword()
240+ {
241+ AccountsService session(this, QTest::currentTestFunction());
242+
243+ QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
244+ ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
245+ "com.ubuntu.AccountsService.SecurityPrivacy",
246+ "LockscreenPassword",
247+ dbusVariant("pin:cryptedpassword")));
248+ QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric);
249+ }
250+
251+ void testLockscreenPasswordOverridesDisplayHint()
252+ {
253+ AccountsService session(this, QTest::currentTestFunction());
254+
255+ QCOMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
256+
257+ ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
258+ "com.ubuntu.AccountsService.SecurityPrivacy",
259+ "PasswordDisplayHint",
260+ dbusVariant(AccountsService::Numeric)));
261+ QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Numeric);
262+
263+ ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
264+ "com.ubuntu.AccountsService.SecurityPrivacy",
265+ "LockscreenPassword",
266+ dbusVariant("system")));
267+ QTRY_COMPARE(session.passwordDisplayHint(), AccountsService::Keyboard);
268+ }
269+
270+ void testAsynchronousChangeForLicenseAccepted()
271 {
272 AccountsService session(this, QTest::currentTestFunction());
273
274@@ -191,7 +222,7 @@
275 QTRY_COMPARE(session.hereEnabled(), true);
276 }
277
278- void testAsynchornousChangeForLicenseBasePath()
279+ void testAsynchronousChangeForLicenseBasePath()
280 {
281 AccountsService session(this, QTest::currentTestFunction());
282
283@@ -203,7 +234,7 @@
284 QTRY_COMPARE(session.hereLicensePath(), QString("/"));
285 }
286
287- void testAsynchornousChangeForStatsBackgroundFile()
288+ void testAsynchronousChangeForBackgroundFile()
289 {
290 AccountsService session(this, QTest::currentTestFunction());
291

Subscribers

People subscribed via source and target branches