summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-04-28 16:49:06 -0700
committerElliott Hughes <enh@google.com>2014-04-28 16:50:00 -0700
commit5dcbf701c9077e62ca8c1ee0079b4cbffaf57d14 (patch)
treeeda9df38ef0d49939587b02236b35b9650ac5acc /src/com/android/providers
parent3a203e4a58bf5ee03c3303df6a04e43a4eefb1eb (diff)
downloadandroid_packages_providers_DownloadProvider-5dcbf701c9077e62ca8c1ee0079b4cbffaf57d14.tar.gz
android_packages_providers_DownloadProvider-5dcbf701c9077e62ca8c1ee0079b4cbffaf57d14.tar.bz2
android_packages_providers_DownloadProvider-5dcbf701c9077e62ca8c1ee0079b4cbffaf57d14.zip
Move internal DownloadProvider code off libcore.os.
(As much as possible. There are no plans to make the mocking API public.) Change-Id: I348877b850d6d34572d5a19e67952254bc4f12ef
Diffstat (limited to 'src/com/android/providers')
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java20
-rw-r--r--src/com/android/providers/downloads/StorageUtils.java16
2 files changed, 18 insertions, 18 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index 6c7cdc6e..aeb28c67 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -54,15 +54,15 @@ import android.os.Process;
import android.os.SystemClock;
import android.os.WorkSource;
import android.provider.Downloads;
+import android.system.ErrnoException;
+import android.system.Os;
+import android.system.OsConstants;
import android.util.Log;
import android.util.Pair;
import com.android.providers.downloads.DownloadInfo.NetworkState;
-import libcore.io.ErrnoException;
import libcore.io.IoUtils;
-import libcore.io.Libcore;
-import libcore.io.OsConstants;
import java.io.File;
import java.io.FileDescriptor;
@@ -459,18 +459,18 @@ public class DownloadThread implements Runnable {
// Pre-flight disk space requirements, when known
if (mInfoDelta.mTotalBytes > 0) {
- final long curSize = Libcore.os.fstat(outFd).st_size;
+ final long curSize = Os.fstat(outFd).st_size;
final long newBytes = mInfoDelta.mTotalBytes - curSize;
StorageUtils.ensureAvailableSpace(mContext, outFd, newBytes);
try {
// We found enough space, so claim it for ourselves
- Libcore.os.posix_fallocate(outFd, 0, mInfoDelta.mTotalBytes);
+ Os.posix_fallocate(outFd, 0, mInfoDelta.mTotalBytes);
} catch (ErrnoException e) {
if (e.errno == OsConstants.ENOTSUP) {
Log.w(TAG, "fallocate() said ENOTSUP; falling back to ftruncate()");
- Libcore.os.ftruncate(outFd, mInfoDelta.mTotalBytes);
+ Os.ftruncate(outFd, mInfoDelta.mTotalBytes);
} else {
throw e;
}
@@ -478,7 +478,7 @@ public class DownloadThread implements Runnable {
}
// Move into place to begin writing
- Libcore.os.lseek(outFd, mInfoDelta.mCurrentBytes, SEEK_SET);
+ Os.lseek(outFd, mInfoDelta.mCurrentBytes, SEEK_SET);
} catch (ErrnoException e) {
throw new StopRequestException(STATUS_FILE_ERROR, e);
@@ -540,7 +540,7 @@ public class DownloadThread implements Runnable {
try {
// When streaming, ensure space before each write
if (mInfoDelta.mTotalBytes == -1) {
- final long curSize = Libcore.os.fstat(outFd).st_size;
+ final long curSize = Os.fstat(outFd).st_size;
final long newBytes = (mInfoDelta.mCurrentBytes + len) - curSize;
StorageUtils.ensureAvailableSpace(mContext, outFd, newBytes);
@@ -577,7 +577,7 @@ public class DownloadThread implements Runnable {
final ParcelFileDescriptor target = mContext.getContentResolver()
.openFileDescriptor(mInfo.getAllDownloadsUri(), "rw");
try {
- Libcore.os.ftruncate(target.getFileDescriptor(), 0);
+ Os.ftruncate(target.getFileDescriptor(), 0);
} catch (ErrnoException ignored) {
} finally {
IoUtils.closeQuietly(target);
@@ -596,7 +596,7 @@ public class DownloadThread implements Runnable {
if (mInfoDelta.mFileName != null) {
try {
// TODO: remove this once PackageInstaller works with content://
- Libcore.os.chmod(mInfoDelta.mFileName, 0644);
+ Os.chmod(mInfoDelta.mFileName, 0644);
} catch (ErrnoException ignored) {
}
diff --git a/src/com/android/providers/downloads/StorageUtils.java b/src/com/android/providers/downloads/StorageUtils.java
index ad08c5d8..1817c758 100644
--- a/src/com/android/providers/downloads/StorageUtils.java
+++ b/src/com/android/providers/downloads/StorageUtils.java
@@ -30,6 +30,10 @@ import android.content.pm.PackageManager;
import android.database.Cursor;
import android.os.Environment;
import android.provider.Downloads;
+import android.system.ErrnoException;
+import android.system.Os;
+import android.system.StructStat;
+import android.system.StructStatVfs;
import android.text.TextUtils;
import android.util.Slog;
@@ -37,11 +41,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.google.android.collect.Lists;
import com.google.android.collect.Sets;
-import libcore.io.ErrnoException;
import libcore.io.IoUtils;
-import libcore.io.Libcore;
-import libcore.io.StructStat;
-import libcore.io.StructStatVfs;
import java.io.File;
import java.io.FileDescriptor;
@@ -100,7 +100,7 @@ public class StorageUtils {
// the backing partition.
final long dev;
try {
- dev = Libcore.os.fstat(fd).st_dev;
+ dev = Os.fstat(fd).st_dev;
} catch (ErrnoException e) {
throw e.rethrowAsIOException();
}
@@ -178,7 +178,7 @@ public class StorageUtils {
*/
private static long getAvailableBytes(FileDescriptor fd) throws IOException {
try {
- final StructStatVfs stat = Libcore.os.fstatvfs(fd);
+ final StructStatVfs stat = Os.fstatvfs(fd);
return (stat.f_bavail * stat.f_bsize) - RESERVED_BYTES;
} catch (ErrnoException e) {
throw e.rethrowAsIOException();
@@ -187,7 +187,7 @@ public class StorageUtils {
private static long getDeviceId(File file) {
try {
- return Libcore.os.stat(file.getAbsolutePath()).st_dev;
+ return Os.stat(file.getAbsolutePath()).st_dev;
} catch (ErrnoException e) {
// Safe since dev_t is uint
return -1;
@@ -239,7 +239,7 @@ public class StorageUtils {
public ConcreteFile(File file) throws ErrnoException {
this.file = file;
- this.stat = Libcore.os.lstat(file.getAbsolutePath());
+ this.stat = Os.lstat(file.getAbsolutePath());
}
@Override