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

Proposed by Jonas G. Drange
Status: Merged
Approved by: Jonas G. Drange
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 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
=== modified file 'client/service/postal.go'
--- client/service/postal.go 2015-07-14 19:00:39 +0000
+++ client/service/postal.go 2015-11-02 13:11:11 +0000
@@ -428,27 +428,30 @@
428 return false428 return false
429 }429 }
430430
431 locked := svc.unityGreeter.IsActive()
432 focused := svc.windowStack.IsAppFocused(app)
433
431 if output.Notification.Card != nil && output.Notification.Card.Popup {434 if output.Notification.Card != nil && output.Notification.Card.Popup {
432 if svc.unityGreeter.IsActive() {435 if locked {
433 // Screen is locked, ensure popup is false436 // Screen is locked, ensure popup is false
434 output.Notification.Card.Popup = false437 output.Notification.Card.Popup = false
435 }438 }
436 }439 }
437440
438 if !svc.windowStack.IsAppFocused(app) {441 if !locked && focused {
439 if isBlacklisted(app) {
440 svc.Log.Debugf("notification skipped (except emblem counter) because app is blacklisted")
441 return svc.emblemCounter.Present(app, nid, output.Notification)
442 }
443
444 b := false
445 for _, p := range svc.Presenters {
446 // we don't want this to shortcut :)
447 b = p.Present(app, nid, output.Notification) || b
448 }
449 return b
450 } else {
451 svc.Log.Debugf("notification skipped because app is focused.")442 svc.Log.Debugf("notification skipped because app is focused.")
452 return false443 return false
453 }444 }
445
446 if isBlacklisted(app) {
447 svc.Log.Debugf("notification skipped (except emblem counter) because app is blacklisted")
448 return svc.emblemCounter.Present(app, nid, output.Notification)
449 }
450
451 b := false
452 for _, p := range svc.Presenters {
453 // we don't want this to shortcut :)
454 b = p.Present(app, nid, output.Notification) || b
455 }
456 return b
454}457}
455458
=== modified file 'client/service/postal_test.go'
--- client/service/postal_test.go 2015-04-16 15:46:46 +0000
+++ client/service/postal_test.go 2015-11-02 13:11:11 +0000
@@ -857,6 +857,7 @@
857 []windowstack.WindowsInfo{},857 []windowstack.WindowsInfo{},
858 []windowstack.WindowsInfo{},858 []windowstack.WindowsInfo{},
859 []windowstack.WindowsInfo{})859 []windowstack.WindowsInfo{})
860 ps.unityGreeterBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), false, false, false, false)
860 svc := ps.replaceBuses(NewPostalService(ps.cfg, ps.log))861 svc := ps.replaceBuses(NewPostalService(ps.cfg, ps.log))
861 svc.Start()862 svc.Start()
862 ps.blacklisted = false863 ps.blacklisted = false
@@ -871,7 +872,22 @@
871 c.Check(svc.messageHandler(app, "0", output), Equals, true)872 c.Check(svc.messageHandler(app, "0", output), Equals, true)
872 c.Check(svc.messageHandler(app, "1", embOut), Equals, true)873 c.Check(svc.messageHandler(app, "1", embOut), Equals, true)
873 ps.blacklisted = true874 ps.blacklisted = true
874 // and regular notifications (but not emblem counters) are supprsessed if blacklisted.875 // and regular notifications (but not emblem counters) are suppressed if blacklisted.
875 c.Check(svc.messageHandler(app, "2", output), Equals, false)876 c.Check(svc.messageHandler(app, "2", output), Equals, false)
876 c.Check(svc.messageHandler(app, "3", embOut), Equals, true)877 c.Check(svc.messageHandler(app, "3", embOut), Equals, true)
877}878}
879
880func (ps *postalSuite) TestFocusedAppButLockedScreenNotification(c *C) {
881 appId := "com.example.test_test-app"
882 ps.winStackBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), []windowstack.WindowsInfo{{0, appId, true, 0}})
883 ps.unityGreeterBus = testibus.NewTestingEndpoint(condition.Work(true), condition.Work(true), true)
884 svc := ps.replaceBuses(NewPostalService(ps.cfg, ps.log))
885 // svc.WindowStackEndp = ps.winStackBus
886 svc.Start()
887
888 card := &launch_helper.Card{Icon: "icon-value", Summary: "summary-value", Persist: true}
889 output := &launch_helper.HelperOutput{Notification: &launch_helper.Notification{Card: card}}
890 app := clickhelp.MustParseAppId(fmt.Sprintf("%v_0", appId))
891
892 c.Check(svc.messageHandler(app, "0", output), Equals, true)
893}

Subscribers

People subscribed via source and target branches

to all changes: