Loading core/java/android/app/NotificationManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,9 @@ public class NotificationManager int[] idOut = new int[1]; INotificationManager service = getService(); String pkg = mContext.getPackageName(); if (notification.sound != null) { notification.sound = notification.sound.getCanonicalUri(); } if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")"); try { service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut, Loading @@ -143,6 +146,9 @@ public class NotificationManager int[] idOut = new int[1]; INotificationManager service = getService(); String pkg = mContext.getPackageName(); if (notification.sound != null) { notification.sound = notification.sound.getCanonicalUri(); } if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")"); try { service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut, Loading core/java/android/net/Uri.java +38 −0 Original line number Diff line number Diff line Loading @@ -16,10 +16,13 @@ package android.net; import android.os.Environment; import android.os.Parcel; import android.os.Parcelable; import android.os.Environment.UserEnvironment; import android.util.Log; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.Charsets; Loading Loading @@ -2288,4 +2291,39 @@ public abstract class Uri implements Parcelable, Comparable<Uri> { builder = builder.appendEncodedPath(pathSegment); return builder.build(); } /** * If this {@link Uri} is {@code file://}, then resolve and return its * canonical path. Also fixes legacy emulated storage paths so they are * usable across user boundaries. Should always be called from the app * process before sending elsewhere. * * @hide */ public Uri getCanonicalUri() { if ("file".equals(getScheme())) { final String canonicalPath; try { canonicalPath = new File(getPath()).getCanonicalPath(); } catch (IOException e) { return this; } if (Environment.isExternalStorageEmulated()) { final String legacyPath = Environment.getLegacyExternalStorageDirectory() .toString(); // Splice in user-specific path when legacy path is found if (canonicalPath.startsWith(legacyPath)) { return Uri.fromFile(new File( Environment.getExternalStorageDirectory().toString(), canonicalPath.substring(legacyPath.length() + 1))); } } return Uri.fromFile(new File(canonicalPath)); } else { return this; } } } core/java/android/os/UserHandle.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /** * Copyright (c) 2012, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.os; parcelable UserHandle; core/java/android/widget/RemoteViews.java +2 −0 Original line number Diff line number Diff line Loading @@ -2166,6 +2166,8 @@ public class RemoteViews implements Parcelable, Filter { * @param value The value to pass to the method. */ public void setUri(int viewId, String methodName, Uri value) { // Resolve any filesystem path before sending remotely value = value.getCanonicalUri(); addAction(new ReflectionAction(viewId, methodName, ReflectionAction.URI, value)); } Loading media/java/android/media/IRingtonePlayer.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.media; import android.net.Uri; import android.os.UserHandle; /** * @hide Loading @@ -28,6 +29,6 @@ interface IRingtonePlayer { boolean isPlaying(IBinder token); /** Used for Notification sound playback. */ void playAsync(in Uri uri, boolean looping, int streamType); void playAsync(in Uri uri, in UserHandle user, boolean looping, int streamType); void stopAsync(); } Loading
core/java/android/app/NotificationManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,9 @@ public class NotificationManager int[] idOut = new int[1]; INotificationManager service = getService(); String pkg = mContext.getPackageName(); if (notification.sound != null) { notification.sound = notification.sound.getCanonicalUri(); } if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")"); try { service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut, Loading @@ -143,6 +146,9 @@ public class NotificationManager int[] idOut = new int[1]; INotificationManager service = getService(); String pkg = mContext.getPackageName(); if (notification.sound != null) { notification.sound = notification.sound.getCanonicalUri(); } if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")"); try { service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut, Loading
core/java/android/net/Uri.java +38 −0 Original line number Diff line number Diff line Loading @@ -16,10 +16,13 @@ package android.net; import android.os.Environment; import android.os.Parcel; import android.os.Parcelable; import android.os.Environment.UserEnvironment; import android.util.Log; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.Charsets; Loading Loading @@ -2288,4 +2291,39 @@ public abstract class Uri implements Parcelable, Comparable<Uri> { builder = builder.appendEncodedPath(pathSegment); return builder.build(); } /** * If this {@link Uri} is {@code file://}, then resolve and return its * canonical path. Also fixes legacy emulated storage paths so they are * usable across user boundaries. Should always be called from the app * process before sending elsewhere. * * @hide */ public Uri getCanonicalUri() { if ("file".equals(getScheme())) { final String canonicalPath; try { canonicalPath = new File(getPath()).getCanonicalPath(); } catch (IOException e) { return this; } if (Environment.isExternalStorageEmulated()) { final String legacyPath = Environment.getLegacyExternalStorageDirectory() .toString(); // Splice in user-specific path when legacy path is found if (canonicalPath.startsWith(legacyPath)) { return Uri.fromFile(new File( Environment.getExternalStorageDirectory().toString(), canonicalPath.substring(legacyPath.length() + 1))); } } return Uri.fromFile(new File(canonicalPath)); } else { return this; } } }
core/java/android/os/UserHandle.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /** * Copyright (c) 2012, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.os; parcelable UserHandle;
core/java/android/widget/RemoteViews.java +2 −0 Original line number Diff line number Diff line Loading @@ -2166,6 +2166,8 @@ public class RemoteViews implements Parcelable, Filter { * @param value The value to pass to the method. */ public void setUri(int viewId, String methodName, Uri value) { // Resolve any filesystem path before sending remotely value = value.getCanonicalUri(); addAction(new ReflectionAction(viewId, methodName, ReflectionAction.URI, value)); } Loading
media/java/android/media/IRingtonePlayer.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.media; import android.net.Uri; import android.os.UserHandle; /** * @hide Loading @@ -28,6 +29,6 @@ interface IRingtonePlayer { boolean isPlaying(IBinder token); /** Used for Notification sound playback. */ void playAsync(in Uri uri, boolean looping, int streamType); void playAsync(in Uri uri, in UserHandle user, boolean looping, int streamType); void stopAsync(); }