diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/providers/downloads/DownloadProvider.java | 56 | ||||
-rw-r--r-- | src/com/android/providers/downloads/StorageManager.java | 8 |
2 files changed, 34 insertions, 30 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(); } } diff --git a/src/com/android/providers/downloads/StorageManager.java b/src/com/android/providers/downloads/StorageManager.java index deb412e7..b8cd6c79 100644 --- a/src/com/android/providers/downloads/StorageManager.java +++ b/src/com/android/providers/downloads/StorageManager.java @@ -38,9 +38,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import libcore.io.ErrnoException; -import libcore.io.Libcore; -import libcore.io.StructStat; +import android.system.ErrnoException; +import android.system.Os; +import android.system.StructStat; /** * Manages the storage space consumed by Downloads Data dir. When space falls below @@ -401,7 +401,7 @@ class StorageManager { for (File file : files) { final String path = file.getAbsolutePath(); try { - final StructStat stat = Libcore.os.stat(path); + final StructStat stat = Os.stat(path); if (stat.st_uid == myUid) { if (Constants.LOGVV) { Log.d(TAG, "deleting spurious file " + path); |