File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
core/java/com/android/internal/app
packages/DefaultContainerService/src/com/android/defcontainer Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -32,4 +32,6 @@ interface IMediaContainerService {
3232 boolean checkExternalFreeStorage (in Uri fileUri );
3333 ObbInfo getObbInfo (in String filename );
3434 long calculateDirectorySize (in String directory );
35+ /** Return file system stats: [0] is total bytes, [1] is available bytes */
36+ long [] getFileSystemStats (in String path );
3537}
Original file line number Diff line number Diff line change 5050import java .io .InputStream ;
5151import java .io .OutputStream ;
5252
53+ import libcore .io .ErrnoException ;
54+ import libcore .io .Libcore ;
55+ import libcore .io .StructStatFs ;
56+
5357/*
5458 * This service copies a downloaded apk to a file passed in as
5559 * a ParcelFileDescriptor or to a newly created container specified
@@ -203,6 +207,18 @@ public long calculateDirectorySize(String path) throws RemoteException {
203207 return 0L ;
204208 }
205209 }
210+
211+ @ Override
212+ public long [] getFileSystemStats (String path ) {
213+ try {
214+ final StructStatFs stat = Libcore .os .statfs (path );
215+ final long totalSize = stat .f_blocks * stat .f_bsize ;
216+ final long availSize = stat .f_bavail * stat .f_bsize ;
217+ return new long [] { totalSize , availSize };
218+ } catch (ErrnoException e ) {
219+ throw new IllegalStateException (e );
220+ }
221+ }
206222 };
207223
208224 public DefaultContainerService () {
You can’t perform that action at this time.
0 commit comments