Merge "Expose statfs() through IMediaContainerService."
diff --git a/core/java/com/android/internal/app/IMediaContainerService.aidl b/core/java/com/android/internal/app/IMediaContainerService.aidl
index d407080..4322a20 100755
--- a/core/java/com/android/internal/app/IMediaContainerService.aidl
+++ b/core/java/com/android/internal/app/IMediaContainerService.aidl
@@ -32,4 +32,6 @@
boolean checkExternalFreeStorage(in Uri fileUri);
ObbInfo getObbInfo(in String filename);
long calculateDirectorySize(in String directory);
+ /** Return file system stats: [0] is total bytes, [1] is available bytes */
+ long[] getFileSystemStats(in String path);
}
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index 113f0f7..8e3a3c5 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -50,6 +50,10 @@
import java.io.InputStream;
import java.io.OutputStream;
+import libcore.io.ErrnoException;
+import libcore.io.Libcore;
+import libcore.io.StructStatFs;
+
/*
* This service copies a downloaded apk to a file passed in as
* a ParcelFileDescriptor or to a newly created container specified
@@ -203,6 +207,18 @@
return 0L;
}
}
+
+ @Override
+ public long[] getFileSystemStats(String path) {
+ try {
+ final StructStatFs stat = Libcore.os.statfs(path);
+ final long totalSize = stat.f_blocks * stat.f_bsize;
+ final long availSize = stat.f_bavail * stat.f_bsize;
+ return new long[] { totalSize, availSize };
+ } catch (ErrnoException e) {
+ throw new IllegalStateException(e);
+ }
+ }
};
public DefaultContainerService() {