156 Commits

Author SHA1 Message Date
John Spurlock
3ec4e7050a Rebind notification listeners for current user.
Use ForUser overload when reading setting inside system server.

Bug: 9000206
Change-Id: Ie87aed578d29425d8f32b23aeb8aa7118922c889
2013-05-16 13:42:38 -04:00
Chris Wren
3da7302dd2 restart notification listener on package add
Bug: 8813471
Change-Id: Icf6c69811392c4567a5c842740e463fb957e7563
2013-05-10 14:49:53 -04:00
Daniel Sandler
c1b49bd26b Defend against a system server crash.
Bug: 8575629
Change-Id: Iafc8ab2f7460c8eacc37fc077cf5a3df16cf2911
2013-05-07 13:55:07 -04:00
Daniel Sandler
4f91efdf42 API: getPkg() -> getPackageName()
Bug: 8656860
Change-Id: If3062b9fc00270e5f0ecfe67e593b9a28c6bccdd
2013-04-25 16:39:02 -04:00
Daniel Sandler
e6f7f2e3a0 API cleanup: NotificationListener
- Wrap all public member variables in getters and make
    slots private
  - Rename clear* methods to cancel* to be more consistent
    with existing public Notification API

Bug: 8656860
Change-Id: I84f7e71fbb627f859352a93089c6a531b44dac95
2013-04-25 15:51:08 -04:00
Daniel Sandler
25cf8cee6f New NotificationListener API: getActiveNotifications()
This allows a listener service to catch up on the current
state of the notification panel at any time, including at
startup.

Bug: 8656860
Change-Id: I1a3d665d84576e17870929a63dda334afc696010
2013-04-24 23:19:08 -04:00
Daniel Sandler
f78ff07f6e Merge "Fix concurrency issues when parceling StatusBarNotifications." into jb-mr2-dev 2013-04-23 00:53:31 +00:00
Daniel Sandler
1a497d3a2b Fix concurrency issues when parceling StatusBarNotifications.
Protip: Don't mess with Bundles after you've sent them off
for parceling in an RPC.

Note that this change reduces the payload size of
StatusBarNotification objects received in
onNotificationRemoved() callbacks; it scrubs out the
RemoteViews and Bitmaps just as the NoMan's internal archive
does. [You don't really need that information anyway when
hearing about a removed notification; most likely all you
need are the other slots on StatusBarNotification, but
nulling the whole Notification object breaks a lot of
clients.]

Bug: 8616295
Change-Id: Ic899045f2352b96dcf064d3e9e51dad52629aea3
2013-04-22 15:14:55 -04:00
Daniel Sandler
32e698b12f Once again, cancel all when notifications canceled for pkg.
Right now this only works if you go through the front door
(using setNotificationsEnabledForPackage()); if you set the
AppOps for a package otherwise the existing notifications
will not be cleared (but new ones will be blocked). Since
there's no UI for modifying AppOps today this shouldn't be a
problem.

Bug: 8489214
Change-Id: I84f8c76a0d03959127e9076ab2b7d37dbdaebb17
2013-04-18 11:31:52 -04:00
Daniel Sandler
3147523c10 Treat the default sound Uri the same as DEFAULT_SOUND.
For the purposes of deciding whether or not to invoke the
"fallback vibrate", that is. (RingtonePicker will return
content://settings/system/notification_sound when "Default"
is chosen, so if the app pops this Uri directly into
Notification.sound, we should treat it like DEFAULT_SOUND
and look to see whether the system notification sound is
not None before running the fallback vibration.)

Bug: 8627641
Change-Id: Ia469b8e4d5d7647ce1a8a179f591ed7a3443b5c5
2013-04-17 10:59:50 -04:00
Daniel Sandler
5e62e3aa7d Further reduce memory usage of notification archive.
- Max 250 notifications preserved (was 1000)
- Known heavyweight extras are removed
- print some of 'em out in dumpstate, while we're at it

Bug: 8280039
Bug: 8537938
Change-Id: I9239128c32a1d9f5ef4e0dc62dc2d23e190871e9
2013-04-16 01:43:49 +00:00
Daniel Sandler
f45564ee72 Finish annotating Notification.extras.
This covers all useful data from the basic Builder as well
as each of the Styles that is not otherwise captured on the
Notification object itself.

Extras are now prettyprinted in dump() output.

Bug: 8270485
Change-Id: I47fc50860dab6409793f57e904cc60296310d5cf
2013-04-15 15:05:08 -04:00
Daniel Sandler
5feceebb89 New NotificationListenerService.
This is the best and only way for apps to listen for
notifications: create a NotificationListenerService, wait
for the NoMan to bind to you (as a result of the user
checking a box somewhere in Settings and agreeing to a
scary dialog box), and you'll start receiving notification
posted and dismissed callbacks. Your service, while enabled,
will also be able to clear one or all notifications.

Use this power wisely.

This change moves StatusBarNotification out of
com.android.internal into android.service.notification.
[Internal customers, including System UI and early users of
the system-only listener binder API, will need to be
updated.]

Bug: 8199624
Change-Id: I1be46f823d4b3ddc901109ec1e085cd6deb740c2
2013-04-05 19:54:44 +00:00
Jeff Sharkey
0c1baf9dd6 Nuke heavy parts of notification before archiving.
Bug: 8537938
Change-Id: I2e4eccc3bd6d57fe5cef340d9e67986d78d3be95
2013-04-03 13:08:52 -07:00
Daniel Sandler
4b749ef5f2 Allow whitelisted non-system packages to listen for notifications.
The allowed packages are listed in
Settings.Secure.ENABLED_NOTIFICATION_LISTENERS. (Don't let
the plural fool you: only one listener will be supported in
the UI.)

Change-Id: Ia69f2ba05d8e555fd4d40b0cc89c62ed14af3cac
2013-03-21 01:41:20 -07:00
Daniel Sandler
23d7c70032 Accumulate updates to notifications before archiving.
By only adding notifications to the archive when they are
removed we batch up multiple updates and only store the
final version. Some data is lost in this process, but we
save tons of memory storing otherwise redundant /
uninteresting data (e.g. each step of a download).

Change-Id: I008afefc1242bb7c433d45da2c36fcc626dd3706
2013-03-07 16:32:06 -05:00
Daniel Sandler
21ca44d67b Properly support USER_ALL in notification listener API.
Listeners should be notified for any notification if they
register for USER_ALL, or for any notification posted to
USER_ALL.

Bug: 8328357
Change-Id: Ib5024d41287090d1a390539a015d8cb4dfa854a7
2013-03-07 14:01:22 -05:00
Daniel Sandler
09a247e9a8 New INotificationListener interface.
Use with INotificationManager.registerListener(). Limited to
system only right now.

Change-Id: I65b6a8778267022cdc5e58eb75ae607a54b1cc52
2013-02-19 15:26:37 -05:00
Daniel Sandler
78d0d25dca Historical notification access API.
Similar to getActiveNotifications(),
getHistoricalNotifications() returns a list of all
notifications that have been posted, in
reverse-chronological order. It currently includes duplicate
entries for notifications that have been updated (so it
really is tracking every notification that has been posted
to the system).

Change-Id: Icce8d6f96bbe76710c989fd0068ff971c6498605
2013-02-12 14:33:24 -05:00
Daniel Sandler
fde19b106b New API to request a list of current notifications.
The ACCESS_NOTIFICATIONS permission is signature|system only.

Change-Id: I41338230aee9611117cbdac251c1b6b6c3cebf00
2013-02-07 15:43:02 -05:00
Dianne Hackborn
f265ea9d83 App ops: vibration, neighboring cells, dialing, etc.
Improve handling of vibration op, so that apps are
better blamed (there is now a hidden vibrator API that
supplies the app to blame, and the system now uses this
when vibrating on behalf of an app).

Add operation for retrieving neighboring cell information.

Add a new op for calling a phone number.  This required
plumbing information about the launching package name through
the activity manager, which required changing the internal
startActivity class, which required hitting a ton of code that
uses those internal APIs.

Change-Id: I3f8015634fdb296558f07fe654fb8d53e5c94d07
2013-02-01 15:14:29 -08:00
Daniel Sandler
4a900acdef Migrate package notification restrictions to AppOps.
Change-Id: I23064ce3014d2446d009bbdff92b301280e8b989
2013-02-01 13:26:17 -05:00
Sascha Prueter
98c958097b am 8f7eddbe: am 652d8fc9: Merge "PRIORITY_MIN notifications should be truly ambient." into jb-mr1.1-dev
* commit '8f7eddbef33f97e7d4439707ac0039be4c81ef0e':
  PRIORITY_MIN notifications should be truly ambient.
2012-12-04 16:35:12 -08:00
Daniel Sandler
526fa0e6d5 PRIORITY_MIN notifications should be truly ambient.
If your notification is set to MIN priority, it will never
attempt to interrupt the user, either by an icon (already
implemented), or (new in this patch) by LED, vibration, or
sound.

Bug: 7648785
Change-Id: Ia0f8e010e62029d8d8ef1955dd20b7c79fb68398
2012-12-04 17:01:12 -05:00
Daniel Sandler
69d13491ea am 8fef4a82: am 15db00eb: Merge "DEFAULT_VIBRATE must always use the default vibe pattern" into jb-mr1.1-dev
* commit '8fef4a820ee217f25fbf29234e90d68dff448222':
  DEFAULT_VIBRATE must always use the default vibe pattern
2012-11-20 15:53:09 -08:00
Daniel Sandler
4a7a9b963b DEFAULT_VIBRATE must always use the default vibe pattern
The logic here was backwards, causing the (softer) fallback vibe
pattern to be applied if the notification specified a sound
(or DEFAULT_SOUND) and also DEFAULT_VIBRATE. The fallback
vibe should only play if you have *no* vibration set.

Bug: 7588655
Change-Id: Iecdd362729bccedf779b51cc9b90a12014328aff
2012-11-20 12:59:41 -05:00
Daniel Sandler
8ff32d8113 am 00679b5b: am 020d6529: Merge "Do not vibe when the default notification sound is Silent." into jb-mr1.1-dev
* commit '00679b5b467dbc19ce2223b5501976c5c3f66fa9':
  Do not vibe when the default notification sound is Silent.
2012-11-15 06:17:35 -08:00
Daniel Sandler
1812b34503 am 2bb5dc6a: am 83b25961: Merge "Notification vibration improvements:" into jb-mr1.1-dev
* commit '2bb5dc6a367ce869939728b2978be7ca61a4b8b8':
  Notification vibration improvements:
2012-11-15 06:17:31 -08:00
Daniel Sandler
d4d2de2a77 Do not vibe when the default notification sound is Silent.
(This relates to the new vibration fallback behavior, where
notifications that expect to make a sound should always
vibrate in vibrate mode. We should not vibrate if the
notification's sound is silent, but we should also not
vibrate if the notification uses the default sound and the
default is silent.)

Bug: 7537077
Change-Id: I08e149c8c00ef2d2f61e418d88a086cb5e9cf241
2012-11-14 16:42:04 -05:00
Daniel Sandler
edbb380950 Notification vibration improvements:
- When notifications vibrate as a fallback (that is,
   because they want to play a sound but the device is in
   vibrate mode), this no longer requires the VIBRATE
   permission.
 - As a bonus, if your notifications use DEFAULT_VIBRATE,
   you don't need the VIBRATE permission either.
 - If you specify a custom vibration pattern, you'll still
   need the VIBRATE permission for that.
 - Notifications vibrating in fallback mode use a different
   vibration pattern.
 - The DEFAULT_VIBRATE and fallback vibrate patterns are now
   specified in config.xml.

Bug: 7531442
Change-Id: I7a2d8413d1becc53b9d31f0d1abbc2acc3f650c6
2012-11-14 11:50:11 -08:00
Ed Heyl
ffea917025 am 5ec97f4e: am 4f017e75: Merge "When in vibrate mode, all notifications will vibrate." into jb-mr1.1-dev
* commit '5ec97f4e82e1adc3bffb9c998b302464517e1f04':
  When in vibrate mode, all notifications will vibrate.
2012-11-09 23:54:08 -08:00
David Agnew
71789e11cc When in vibrate mode, all notifications will vibrate.
(Unless the notification specifies no ringtone AND no
vibration, in which case it will remain silent.)

Change-Id: I926d0fe0165b9622cd117e6c3ef6e3637772b444
2012-11-10 00:01:04 -05:00
Amith Yamasani
807dc6f038 am 081c36de: am bfb8a7b1: am 3fe2cb4d: Merge "Don\'t cancel any notifications that are meant for all users, if no package is specified." into jb-mr1-dev
* commit '081c36ded6a562ae2bde4238592a1e7bc13ba151':
  Don't cancel any notifications that are meant for all users, if no package is specified.
2012-11-08 15:44:40 -08:00
Amith Yamasani
5ec00e930f Don't cancel any notifications that are meant for all users, if no package is specified.
Bug: 7490028

Otherwise notifications such as the USB debugging and OTA notifications will be
dismissed when any user is stopped.

Change-Id: I0ae0c1136a999dd3aade99ca9e71c714b359eab4
2012-11-07 16:58:30 -08:00
Kenny Root
58ed5d748c am 768d9e1a: Merge "Correct executable bit for source files"
* commit '768d9e1a72ceee7d4a5f608776b87b62d6ce4a04':
  Correct executable bit for source files
2012-11-07 11:52:12 -08:00
Kenny Root
3a084af2e9 Correct executable bit for source files
Many media files and source code files were marked as executable in Git.
Remove those.

Also a shell script and python script were not marked as executable.

Change-Id: Ieb51bafb46c895a21d2e83696f5a901ba752b2c5
2012-11-07 10:27:31 -08:00
Amith Yamasani
2c7ebeae9f Relax permission requirements for posting notifications across users
Bug: 7430689
Change-Id: I2430b20137705ed2d6dc0f870690acda0662392b
2012-10-30 16:12:54 -07:00
Daniel Sandler
321e9c562b Allow any user to clear a notification targeted at USER_ALL.
This also adds the userid to notification_* eventlogs.

Bug: 7325802
Change-Id: I48055caf1344acd58b61607bf0be38cc299fc7be
2012-10-15 14:38:39 -04:00
Jean-Michel Trivi
bcfc1ca8ab Merge "Don't play notifications during speech recognition" into jb-mr1-dev 2012-10-10 16:30:56 -07:00
Svetoslav Ganov
c31ed39e7a Send accessibility notification events only for the current user.
1. The notification manager service is firing accessibility events
   for notification for a background user. Events for the current
   user's notifications should be sent.

bug:7326302

Change-Id: I00665385ba2106f161928dad1b76536c93c17f27
2012-10-10 14:58:33 -07:00
Jean-Michel Trivi
d677054ca6 Don't play notifications during speech recognition
Add support for querying AudioManager to know whether speech
 recognition is currently underway.

Don't play a notification if speech recognition is underway.

Bug 7314859

Change-Id: I1bd013a3168cfe1a6b6dcfd28565e1c3c512eb6a
2012-10-10 12:03:41 -07:00
Jeff Sharkey
b78738fa06 Clear identity when requesting current user.
Bug: 7298189
Change-Id: Ie9c160f12067f1b9426acbfee67ef81e8f5f7992
2012-10-05 16:03:01 -07:00
Jeff Sharkey
8637bd9766 Only play notification sounds for active user.
Bug: 7298302
Change-Id: I1e176f7b17bb51b878f2e8b345804780df92d487
2012-10-05 15:29:01 -07:00
John Spurlock
078a490c22 Clear notifications properly on ACTION_USER_STOPPED.
Which also takes care of the ACTION_USER_REMOVED case.

Bug:7277853
Change-Id: I0a6bade11bd0d420df03e16e69a386cfccfa07cc
2012-10-04 12:00:53 -04:00
Jeff Sharkey
1951db86f5 Merge "Multi-user ringtone playback." into jb-mr1-dev 2012-09-26 13:38:22 -07:00
Jeff Sharkey
65c4a2b26c Multi-user ringtone playback.
Change RingtonePlayer to open content:// Uris based on requesting
UserHandle.  Grant SystemUI visibility to all emulated storage so
it can play ringtones for apps without READ_EXTERNAL_STORAGE.

Resolve canonical file:// Uris before passing out of source app,
replacing any /emulated_legacy/-style paths with user-specific
variant so they can be opened by SystemUI.  Calling for RemoteViews,
Ringtones, and Notifications.

Bug: 7202982
Change-Id: Ibf0eca8df80c1486711144a7b648f464aadfe099
2012-09-26 10:49:35 -07:00
Jeff Brown
bf6f6f9de7 Update references to migrated global settings.
Fixed one setting that was migrated but not marked deprecated.

Removed a hidden setting that is no longer used by the new
power manager service.

Bug: 7231172
Change-Id: I332f020f876a18d519a1a20598a172f1c98036f7
2012-09-25 15:27:51 -07:00
Dianne Hackborn
50cdf7c306 Fix issue #7214090: Need to be able to post notifications to all users
Also fix a bunch of system services that should be doing this.  And
while doing that, found I needed to fix PendingIntent to evaluate
USER_CURRENT at the point of sending, not creation.

Note that this may end up with us having some notification shown to
non-primary users that lead to settings UI that should only be for
the primary user (such as the vpn notification).  I'm not sure what
to do about this, maybe we need a different UI to come up there or
something, but showing the actual notification for those users at
least seems less broken than not telling them at all.

Change-Id: Iffc51e2d7c847e3d05064d292ab93937646a1ab7
2012-09-24 10:55:46 -07:00
Jeff Sharkey
6d51571835 Allow acquiring ContentProviders across users.
Otherwise services like SystemUI will always open content://-style
Uris as USER_OWNER.  Surfaces through createPackageContextAsUser()
which points all ContentResolver operations towards a given user.

Start using in RemoteViews, so that Notifications correctly resolve
image Uris to the sending user.  Also add user support for "content"
shell tool.

Bug: 7202982
Change-Id: I8cb7fb8a812e825bb0b5833799dba87055ff8699
2012-09-21 19:49:43 -07:00
Daniel Sandler
c9ce0abe29 Make the SystemUI stop the screen saver when a full-screen notification is posted.
This keeps all the fullScreenIntent logic (including
multiuser implications) in one place.

Change-Id: I4ef284daf90464f105780ade1d971e9e081fbbb5
2012-09-05 08:41:07 -04:00