diff options
Diffstat (limited to 'src/com/android/providers/downloads/DownloadProvider.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadProvider.java | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java index ad3cf7ac..48350f6a 100644 --- a/src/com/android/providers/downloads/DownloadProvider.java +++ b/src/com/android/providers/downloads/DownloadProvider.java @@ -39,7 +39,6 @@ import android.os.Handler; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor.OnCloseListener; import android.os.Process; -import android.os.SELinux; import android.provider.BaseColumns; import android.provider.Downloads; import android.provider.OpenableColumns; @@ -465,11 +464,6 @@ public final class DownloadProvider extends ContentProvider { Context context = getContext(); context.startService(new Intent(context, DownloadService.class)); mDownloadsDataDir = StorageManager.getDownloadDataDirectory(getContext()); - try { - SELinux.restorecon(mDownloadsDataDir.getCanonicalPath()); - } catch (IOException e) { - Log.wtf(Constants.TAG, "Could not get canonical path for download directory", e); - } return true; } @@ -1051,12 +1045,16 @@ public final class DownloadProvider extends ContentProvider { 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).isEmpty()) { - values.put(Downloads.Impl.COLUMN_TITLE, new File(filename).getName()); + Cursor c = null; + try { + c = query(uri, new String[] + { Downloads.Impl.COLUMN_TITLE }, null, null, null); + if (!c.moveToFirst() || c.getString(0).isEmpty()) { + values.put(Downloads.Impl.COLUMN_TITLE, new File(filename).getName()); + } + } finally { + IoUtils.closeQuietly(c); } - c.close(); } Integer status = values.getAsInteger(Downloads.Impl.COLUMN_STATUS); @@ -1275,29 +1273,35 @@ public final class DownloadProvider extends ContentProvider { if (cursor == null) { Log.v(Constants.TAG, "null cursor in openFile"); } else { - if (!cursor.moveToFirst()) { - Log.v(Constants.TAG, "empty cursor in openFile"); - } else { - do { - Log.v(Constants.TAG, "row " + cursor.getInt(0) + " available"); - } while(cursor.moveToNext()); + try { + if (!cursor.moveToFirst()) { + Log.v(Constants.TAG, "empty cursor in openFile"); + } else { + do { + Log.v(Constants.TAG, "row " + cursor.getInt(0) + " available"); + } while(cursor.moveToNext()); + } + } finally { + cursor.close(); } - cursor.close(); } cursor = query(uri, new String[] { "_data" }, null, null, null); if (cursor == null) { Log.v(Constants.TAG, "null cursor in openFile"); } else { - if (!cursor.moveToFirst()) { - Log.v(Constants.TAG, "empty cursor in openFile"); - } else { - String filename = cursor.getString(0); - Log.v(Constants.TAG, "filename in openFile: " + filename); - if (new java.io.File(filename).isFile()) { - Log.v(Constants.TAG, "file exists in openFile"); + try { + if (!cursor.moveToFirst()) { + Log.v(Constants.TAG, "empty cursor in openFile"); + } else { + String filename = cursor.getString(0); + Log.v(Constants.TAG, "filename in openFile: " + filename); + if (new java.io.File(filename).isFile()) { + Log.v(Constants.TAG, "file exists in openFile"); + } } + } finally { + cursor.close(); } - cursor.close(); } } |