Merge "Track libcore API change."
This commit is contained in:
@@ -18,14 +18,14 @@ package android.os;
|
|||||||
|
|
||||||
import libcore.io.ErrnoException;
|
import libcore.io.ErrnoException;
|
||||||
import libcore.io.Libcore;
|
import libcore.io.Libcore;
|
||||||
import libcore.io.StructStatFs;
|
import libcore.io.StructStatVfs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve overall information about the space on a filesystem. This is a
|
* Retrieve overall information about the space on a filesystem. This is a
|
||||||
* wrapper for Unix statfs().
|
* wrapper for Unix statvfs().
|
||||||
*/
|
*/
|
||||||
public class StatFs {
|
public class StatFs {
|
||||||
private StructStatFs mStat;
|
private StructStatVfs mStat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new StatFs for looking at the stats of the filesystem at
|
* Construct a new StatFs for looking at the stats of the filesystem at
|
||||||
@@ -39,9 +39,9 @@ public class StatFs {
|
|||||||
mStat = doStat(path);
|
mStat = doStat(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StructStatFs doStat(String path) {
|
private static StructStatVfs doStat(String path) {
|
||||||
try {
|
try {
|
||||||
return Libcore.os.statfs(path);
|
return Libcore.os.statvfs(path);
|
||||||
} catch (ErrnoException e) {
|
} catch (ErrnoException e) {
|
||||||
throw new IllegalArgumentException("Invalid path: " + path, e);
|
throw new IllegalArgumentException("Invalid path: " + path, e);
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public class StatFs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The size, in bytes, of a block on the file system. This corresponds to
|
* The size, in bytes, of a block on the file system. This corresponds to
|
||||||
* the Unix {@code statfs.f_bsize} field.
|
* the Unix {@code statvfs.f_bsize} field.
|
||||||
*/
|
*/
|
||||||
public int getBlockSize() {
|
public int getBlockSize() {
|
||||||
return (int) mStat.f_bsize;
|
return (int) mStat.f_bsize;
|
||||||
@@ -66,7 +66,7 @@ public class StatFs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The total number of blocks on the file system. This corresponds to the
|
* The total number of blocks on the file system. This corresponds to the
|
||||||
* Unix {@code statfs.f_blocks} field.
|
* Unix {@code statvfs.f_blocks} field.
|
||||||
*/
|
*/
|
||||||
public int getBlockCount() {
|
public int getBlockCount() {
|
||||||
return (int) mStat.f_blocks;
|
return (int) mStat.f_blocks;
|
||||||
@@ -75,7 +75,7 @@ public class StatFs {
|
|||||||
/**
|
/**
|
||||||
* The total number of blocks that are free on the file system, including
|
* The total number of blocks that are free on the file system, including
|
||||||
* reserved blocks (that are not available to normal applications). This
|
* reserved blocks (that are not available to normal applications). This
|
||||||
* corresponds to the Unix {@code statfs.f_bfree} field. Most applications
|
* corresponds to the Unix {@code statvfs.f_bfree} field. Most applications
|
||||||
* will want to use {@link #getAvailableBlocks()} instead.
|
* will want to use {@link #getAvailableBlocks()} instead.
|
||||||
*/
|
*/
|
||||||
public int getFreeBlocks() {
|
public int getFreeBlocks() {
|
||||||
@@ -84,7 +84,7 @@ public class StatFs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of blocks that are free on the file system and available to
|
* The number of blocks that are free on the file system and available to
|
||||||
* applications. This corresponds to the Unix {@code statfs.f_bavail} field.
|
* applications. This corresponds to the Unix {@code statvfs.f_bavail} field.
|
||||||
*/
|
*/
|
||||||
public int getAvailableBlocks() {
|
public int getAvailableBlocks() {
|
||||||
return (int) mStat.f_bavail;
|
return (int) mStat.f_bavail;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ import libcore.io.ErrnoException;
|
|||||||
import libcore.io.IoUtils;
|
import libcore.io.IoUtils;
|
||||||
import libcore.io.Libcore;
|
import libcore.io.Libcore;
|
||||||
import libcore.io.Streams;
|
import libcore.io.Streams;
|
||||||
import libcore.io.StructStatFs;
|
import libcore.io.StructStatVfs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This service copies a downloaded apk to a file passed in as
|
* This service copies a downloaded apk to a file passed in as
|
||||||
@@ -241,7 +241,7 @@ public class DefaultContainerService extends IntentService {
|
|||||||
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final StructStatFs stat = Libcore.os.statfs(path);
|
final StructStatVfs stat = Libcore.os.statvfs(path);
|
||||||
final long totalSize = stat.f_blocks * stat.f_bsize;
|
final long totalSize = stat.f_blocks * stat.f_bsize;
|
||||||
final long availSize = stat.f_bavail * stat.f_bsize;
|
final long availSize = stat.f_bavail * stat.f_bsize;
|
||||||
return new long[] { totalSize, availSize };
|
return new long[] { totalSize, availSize };
|
||||||
|
|||||||
Reference in New Issue
Block a user