From 46bb7dd18c9b092d352d76ab44a4e52951941b2c Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Thu, 27 Sep 2012 11:12:30 -0700 Subject: Send uid of the application that initiated the download Bug: 6923241 Change-Id: Idf4037b4e360cb6453b315d1cc95608762c9e0c8 --- src/com/android/providers/downloads/OpenHelper.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/com/android') diff --git a/src/com/android/providers/downloads/OpenHelper.java b/src/com/android/providers/downloads/OpenHelper.java index 0151c8de..c7d90edd 100644 --- a/src/com/android/providers/downloads/OpenHelper.java +++ b/src/com/android/providers/downloads/OpenHelper.java @@ -59,6 +59,7 @@ public class OpenHelper { final Uri remoteUri = getCursorUri(cursor, COLUMN_URI); intent.putExtra(Intent.EXTRA_ORIGINATING_URI, remoteUri); intent.putExtra(Intent.EXTRA_REFERRER, getRefererUri(context, id)); + intent.putExtra(Intent.EXTRA_ORIGINATING_UID, getOriginatingUid(context, id)); } else if ("file".equals(localUri.getScheme())) { intent.setDataAndType( ContentUris.withAppendedId(ALL_DOWNLOADS_CONTENT_URI, id), mimeType); @@ -91,6 +92,22 @@ public class OpenHelper { return null; } + private static int getOriginatingUid(Context context, long id) { + final Uri uri = ContentUris.withAppendedId(ALL_DOWNLOADS_CONTENT_URI, id); + final Cursor cursor = context.getContentResolver().query(uri, new String[]{Constants.UID}, + null, null, null); + if (cursor != null) { + try { + if (cursor.moveToFirst()) { + return cursor.getInt(cursor.getColumnIndexOrThrow(Constants.UID)); + } + } finally { + cursor.close(); + } + } + return -1; + } + private static String getCursorString(Cursor cursor, String column) { return cursor.getString(cursor.getColumnIndexOrThrow(column)); } -- cgit v1.2.3