on xenial help sign in
Merge pull request #166 from ubports/xenial_-_edge_-_ensureLock
7e937b9Rodney
qml/Launcher/Launcher.qml+9
@@ -117,6 +117,15 @@ FocusScope {
117 hint();
117 hint();
118 }
118 }
119
119
120+ // Switches the Launcher to the visible state, but only if it's not already
121+ // opened.
122+ // Prevents closing the Drawer when trying to show the Launcher.
123+ function show() {
124+ if (state === "" || state === "visibleTemporary") {
125+ switchToNextState("visible");
126+ }
127+ }
128+
120 function hide(flags) {
129 function hide(flags) {
121 if ((flags & ignoreHideIfMouseOverLauncher) && Utils.Functions.itemUnderMouse(panel)) {
130 if ((flags & ignoreHideIfMouseOverLauncher) && Utils.Functions.itemUnderMouse(panel)) {
122 if (state == "drawer") {
131 if (state == "drawer") {
qml/Shell.qml+31−29
@@ -96,9 +96,7 @@ StyledItem {
96 readonly property var mainApp: stage.mainApp
96 readonly property var mainApp: stage.mainApp
97
97
98 onMainAppChanged: {
98 onMainAppChanged: {
99− if (mainApp) {
100− _onMainAppChanged(mainApp.appId);
99+ _onMainAppChanged((mainApp ? mainApp.appId : ""));
101− }
102 }
100 }
103 Connections {
101 Connections {
104 target: ApplicationManager
102 target: ApplicationManager
@@ -108,24 +106,40 @@ StyledItem {
108 }
106 }
109 }
107 }
110 }
108 }
109+
110+ // Calls attention back to the most important thing that's been focused
111+ // (ex: phone calls go over Wizard, app focuses go over indicators, greeter
112+ // goes over everything if it is locked)
113+ // Must be called whenever app focus changes occur, even if the focus change
114+ // is "nothing is focused". In that case, call with appId = ""
111 function _onMainAppChanged(appId) {
115 function _onMainAppChanged(appId) {
112− if (wizard.active && appId != "") {
113− // If this happens on first boot, we may be in the
114− // wizard while receiving a call. But a call is more
115− // important than the wizard so just bail out of it.
116− wizard.hide();
117− }
118
116
117+ if (appId !== "") {
118+ if (wizard.active) {
119+ // If this happens on first boot, we may be in the
120+ // wizard while receiving a call. A call is more
121+ // important than the wizard so just bail out of it.
122+ wizard.hide();
123+ }
124+
119− if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
125+ if (appId === "dialer-app" && callManager.hasCalls && greeter.locked) {
120− // If we are in the middle of a call, make dialer lockedApp and show it.
126+ // If we are in the middle of a call, make dialer lockedApp. The
127+ // Greeter will show it when it's notified of the focus.
121− // This can happen if user backs out of dialer back to greeter, then
128+ // This can happen if user backs out of dialer back to greeter, then
122− // launches dialer again.
129+ // launches dialer again.
123− greeter.lockedApp = appId;
130+ greeter.lockedApp = appId;
131+ }
132+
133+ panel.indicators.hide();
134+ launcher.hide(launcher.ignoreHideIfMouseOverLauncher);
135+ } else if (topLevelSurfaceList.count === 0 && !greeter.active && !wizard.active) {
136+ // Show the Launcher when there are no apps running
137+ stage.closeSpread();
138+ launcher.show();
124 }
139 }
125− greeter.notifyAppFocusRequested(appId);
126
140
127− panel.indicators.hide();
141+ // *Always* make sure the greeter knows that the focused app changed
128− launcher.hide(launcher.ignoreHideIfMouseOverLauncher);
142+ greeter.notifyAppFocusRequested(appId);
129 }
143 }
130
144
131 // For autopilot consumption
145 // For autopilot consumption
@@ -393,18 +407,6 @@ StyledItem {
393 }
407 }
394 }
408 }
395 }
409 }
396−
397− // Show the launcher in case there are no running apps
398− Connections {
399− target: topLevelSurfaceList
400− onCountChanged: {
401− if (topLevelSurfaceList.count > 0)
402− return
403−
404− stage.closeSpread()
405− launcher.switchToNextState("visible")
406− }
407− }
408 }
410 }
409
411
410 Component {
412 Component {
tests/qmltests/tst_ShellWithPin.qml+31−5
@@ -140,8 +140,6 @@ Item {
140 stage = findChild(shell, "stage");
140 stage = findChild(shell, "stage");
141 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
141 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
142 verify(topLevelSurfaceList);
142 verify(topLevelSurfaceList);
143−
144− startApplication("unity8-dash");
145 }
143 }
146
144
147 function cleanup() {
145 function cleanup() {
@@ -288,7 +286,7 @@ Item {
288 var greeter = findChild(shell, "greeter");
286 var greeter = findChild(shell, "greeter");
289 var emergencyButton = findChild(greeter, "emergencyCallLabel");
287 var emergencyButton = findChild(greeter, "emergencyCallLabel");
290 tap(emergencyButton)
288 tap(emergencyButton)
291− tryCompare(topLevelSurfaceList, "count", 2);
289+ tryCompare(topLevelSurfaceList, "count", 1);
292 waitUntilAppWindowIsFullyLoaded(dialerSurfaceId);
290 waitUntilAppWindowIsFullyLoaded(dialerSurfaceId);
293
291
294 tryCompare(greeter, "shown", false);
292 tryCompare(greeter, "shown", false);
@@ -416,6 +414,8 @@ Item {
416 // - Should be back in normal dialer
414 // - Should be back in normal dialer
417 // (we've had a bug where we locked screen in this case)
415 // (we've had a bug where we locked screen in this case)
418
416
417+ startApplication("gallery-app");
418+
419 var greeter = findChild(shell, "greeter");
419 var greeter = findChild(shell, "greeter");
420 var panel = findChild(shell, "panel");
420 var panel = findChild(shell, "panel");
421
421
@@ -427,8 +427,8 @@ Item {
427 tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
427 tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
428 callManager.foregroundCall = phoneCall;
428 callManager.foregroundCall = phoneCall;
429
429
430− ApplicationManager.requestFocusApplication("unity8-dash");
430+ ApplicationManager.requestFocusApplication("gallery-app");
431− tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
431+ tryCompare(ApplicationManager, "focusedApplicationId", "gallery-app");
432 var callHint = findChild(panel, "callHint");
432 var callHint = findChild(panel, "callHint");
433 tryCompare(callHint, "visible", true);
433 tryCompare(callHint, "visible", true);
434 wait(10000)
434 wait(10000)
@@ -528,5 +528,31 @@ Item {
528
528
529 tryCompare(launcher, "state", "drawer");
529 tryCompare(launcher, "state", "drawer");
530 }
530 }
531+
532+ /* Regression test, https://github.com/ubports/ubuntu-touch/issues/1178
533+ When all apps closed while the Greeter was shown, the Launcher would
534+ appear over the Greeter. This was caused by logic that would normally
535+ cause the Launcher to be shown over the empty Background. */
536+ function test_launcherShowCulledWhenLocked() {
537+ var launcher = findChild(shell, "launcher");
538+
539+ // Ensure the Launcher is sane
540+ touchFlick(shell, units.gu(.5), shell.height / 2, units.gu(10), shell.height / 2);
541+ tryCompare(launcher, "state", "visible");
542+ tap(shell);
543+ tryCompare(launcher, "state", "");
544+
545+ console.log("I AM LOGGING NOW");
546+ console.log(ApplicationManager.count);
547+
548+ // Start and kill an app to cause the Launcher to be triggered (in error state)
549+ startApplication("gallery-app");
550+ tryCompare(ApplicationManager, "count", 1);
551+ ApplicationManager.stopApplication("gallery-app");
552+ tryCompare(ApplicationManager, "count", 0);
553+
554+ // Make sure that the error state didn't happen
555+ tryCompare(launcher, "state", "");
556+ }
531 }
557 }
532}
558}