diff options
author | Leon Scroggins <scroggo@google.com> | 2010-01-28 17:53:26 -0500 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2010-02-05 11:16:49 -0500 |
commit | a2028ed4141075da8199ba04a499be77734a85ae (patch) | |
tree | 24f1c71c6e1ee200f6decd0c161069368e92ddc4 /src/com/android/providers/downloads/DownloadProvider.java | |
parent | 91e4522fa90d969a596058756c24e173df1a6196 (diff) | |
download | android_packages_providers_DownloadProvider-a2028ed4141075da8199ba04a499be77734a85ae.tar.gz android_packages_providers_DownloadProvider-a2028ed4141075da8199ba04a499be77734a85ae.tar.bz2 android_packages_providers_DownloadProvider-a2028ed4141075da8199ba04a499be77734a85ae.zip |
Create a new permission that allows apps to see downloads from other
applications to the SD card.
Necessary for http://b/issue?id=2384554
Also create names for files by default, so they do not display as
<Untitled>. Remove calls to createTitleFromFilename, which are
no longer necessary.
Requires a change to frameworks/base.
Diffstat (limited to 'src/com/android/providers/downloads/DownloadProvider.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadProvider.java | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java index db005542..d7c24f9a 100644 --- a/src/com/android/providers/downloads/DownloadProvider.java +++ b/src/com/android/providers/downloads/DownloadProvider.java @@ -413,23 +413,40 @@ public final class DownloadProvider extends ContentProvider { callingUid != mSystemUid && callingUid != mDefContainerUid && Process.supportsProcesses()) { - if (!emptyWhere) { - qb.appendWhere(" AND "); - } - qb.appendWhere("( " + Constants.UID + "=" + Binder.getCallingUid() + " OR " - + Downloads.Impl.COLUMN_OTHER_UID + "=" + Binder.getCallingUid() + " )"); - emptyWhere = false; - + boolean canSeeAllExternal; if (projection == null) { projection = sAppReadableColumnsArray; + // sAppReadableColumnsArray includes _DATA, which is not allowed + // to be seen except by the initiating application + canSeeAllExternal = false; } else { + canSeeAllExternal = getContext().checkCallingPermission( + Downloads.Impl.PERMISSION_SEE_ALL_EXTERNAL) + == PackageManager.PERMISSION_GRANTED; for (int i = 0; i < projection.length; ++i) { if (!sAppReadableColumnsSet.contains(projection[i])) { throw new IllegalArgumentException( "column " + projection[i] + " is not allowed in queries"); } + canSeeAllExternal = canSeeAllExternal + && !projection[i].equals(Downloads.Impl._DATA); } } + if (!emptyWhere) { + qb.appendWhere(" AND "); + emptyWhere = false; + } + String validUid = "( " + Constants.UID + "=" + + Binder.getCallingUid() + " OR " + + Downloads.Impl.COLUMN_OTHER_UID + "=" + + Binder.getCallingUid() + " )"; + if (canSeeAllExternal) { + qb.appendWhere("( " + validUid + " OR " + + Downloads.Impl.DESTINATION_EXTERNAL + " = " + + Downloads.Impl.COLUMN_DESTINATION + " )"); + } else { + qb.appendWhere(validUid); + } } if (Constants.LOGVV) { @@ -526,6 +543,16 @@ public final class DownloadProvider extends ContentProvider { copyString(Downloads.Impl.COLUMN_DESCRIPTION, values, filteredValues); } else { filteredValues = values; + String filename = values.getAsString(Downloads.Impl._DATA); + if (filename != null) { + Cursor c = query(uri, new String[] + { Downloads.Impl.COLUMN_TITLE }, null, null, null); + if (!c.moveToFirst() || c.getString(0) == null) { + values.put(Downloads.Impl.COLUMN_TITLE, + new File(filename).getName()); + } + c.close(); + } } int match = sURIMatcher.match(uri); switch (match) { |