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
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index bab4f7a..848edf8 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -890,6 +890,7 @@
 
         userId = ActivityManager.handleIncomingUser(callingPid,
                 callingUid, userId, true, true, "enqueueNotification", pkg);
+        final UserHandle user = new UserHandle(userId);
 
         // Limit the number of notifications that any given package except the android
         // package can enqueue.  Prevents DOS attacks and deals with leaks.
@@ -991,7 +992,6 @@
             }
 
             if (notification.icon != 0) {
-                final UserHandle user = new UserHandle(userId);
                 final StatusBarNotification n = new StatusBarNotification(
                         pkg, id, tag, r.uid, r.initialPid, score, notification, user);
                 if (old != null && old.statusBarKey != null) {
@@ -1063,7 +1063,7 @@
                         try {
                             final IRingtonePlayer player = mAudioService.getRingtonePlayer();
                             if (player != null) {
-                                player.playAsync(uri, looping, audioStreamType);
+                                player.playAsync(uri, user, looping, audioStreamType);
                             }
                         } catch (RemoteException e) {
                         } finally {