Merge lp:ubuntu-push/automatic into lp:ubuntu-push/vivid-overlay

Proposed by Jonas G. Drange on 2015-11-02
Status: Merged
Approved by: Jonas G. Drange on 2015-11-02
Approved revision: 413
Merged at revision: 154
Proposed branch: lp:ubuntu-push/automatic
Merge into: lp:ubuntu-push/vivid-overlay
Diff against target: 84 lines (+34/-15)
2 files modified
client/service/postal.go (+17/-14)
client/service/postal_test.go (+17/-1)
To merge this branch: bzr merge lp:ubuntu-push/automatic
Reviewer Review Type Date Requested Status
Ubuntu Push Hackers 2015-11-02 Pending
Review via email: mp+276387@code.launchpad.net

Commit message

[postal] make sure we don't gobble notifications when screen is locked, even if the app getting notified is focused.

Description of the change

[postal] make sure we don't gobble notifications when screen is locked, even if the app getting notified is focused.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/service/postal.go'
2--- client/service/postal.go 2015-07-14 19:00:39 +0000
3+++ client/service/postal.go 2015-11-02 13:11:11 +0000
4@@ -428,27 +428,30 @@
5 return false
6 }
7
8+ locked := svc.unityGreeter.IsActive()
9+ focused := svc.windowStack.IsAppFocused(app)
10+
11 if output.Notification.Card != nil && output.Notification.Card.Popup {
12- if svc.unityGreeter.IsActive() {
13+ if locked {
14 // Screen is locked, ensure popup is false
15 output.Notification.Card.Popup = false
16 }
17 }
18
19- if !svc.windowStack.IsAppFocused(app) {
20- if isBlacklisted(app) {
21- svc.Log.Debugf("notification skipped (except emblem counter) because app is blacklisted")
22- return svc.emblemCounter.Present(app, nid, output.Notification)
23- }
24-
25- b := false
26- for _, p := range svc.Presenters {
27- // we don't want this to shortcut :)
28- b = p.Present(app, nid, output.Notification) || b
29- }
30- return b
31- } else {
32+ if !locked && focused {
33 svc.Log.Debugf("notification skipped because app is focused.")
34 return false
35 }
36+
37+ if isBlacklisted(app) {
38+ svc.Log.Debugf("notification skipped (except emblem counter) because app is blacklisted")
39+ return svc.emblemCounter.Present(app, nid, output.Notification)
40+ }
41+
42+ b := false
43+ for _, p := range svc.Presenters {
44+ // we don't want this to shortcut :)
45+ b = p.Present(app, nid, output.Notification) || b
46+ }
47+ return b
48 }
49
50=== modified file 'client/service/postal_test.go'
51--- client/service/postal_test.go 2015-04-16 15:46:46 +0000
52+++ client/service/postal_test.go 2015-11-02 13:11:11 +0000
53@@ -857,6 +857,7 @@
54 []windowstack.WindowsInfo{},
55 []windowstack.WindowsInfo{},
56 []windowstack.WindowsInfo{})
57+ ps.unityGreeterBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), false, false, false, false)
58 svc := ps.replaceBuses(NewPostalService(ps.cfg, ps.log))
59 svc.Start()
60 ps.blacklisted = false
61@@ -871,7 +872,22 @@
62 c.Check(svc.messageHandler(app, "0", output), Equals, true)
63 c.Check(svc.messageHandler(app, "1", embOut), Equals, true)
64 ps.blacklisted = true
65- // and regular notifications (but not emblem counters) are supprsessed if blacklisted.
66+ // and regular notifications (but not emblem counters) are suppressed if blacklisted.
67 c.Check(svc.messageHandler(app, "2", output), Equals, false)
68 c.Check(svc.messageHandler(app, "3", embOut), Equals, true)
69 }
70+
71+func (ps *postalSuite) TestFocusedAppButLockedScreenNotification(c *C) {
72+ appId := "com.example.test_test-app"
73+ ps.winStackBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), []windowstack.WindowsInfo{{0, appId, true, 0}})
74+ ps.unityGreeterBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), true)
75+ svc := ps.replaceBuses(NewPostalService(ps.cfg, ps.log))
76+ // svc.WindowStackEndp = ps.winStackBus
77+ svc.Start()
78+
79+ card := &launch_helper.Card{Icon: "icon-value", Summary: "summary-value", Persist: true}
80+ output := &launch_helper.HelperOutput{Notification: &launch_helper.Notification{Card: card}}
81+ app := clickhelp.MustParseAppId(fmt.Sprintf("%v_0", appId))
82+
83+ c.Check(svc.messageHandler(app, "0", output), Equals, true)
84+}

Subscribers

People subscribed via source and target branches

to all changes: