Reverted some changes that were made for Java 1.5 compatibility.

Removed Commons IO, which we were only using as a replacement for
File.getFreeSpace() on desktop plaftorms.

Note: The Huawei U8210 (Android 2.1) doesn't have all the Java 1.6
standard library methods, and crashes if they're called. Specifically,
String.isEmpty() and NetworkInterface.supportsMulticast() are missing,
so the changes removing those methods were not reverted.
This commit is contained in:
akwizgran
2013-11-22 12:49:20 +00:00
parent 3b5769cf8a
commit 26eebee8d9
11 changed files with 30 additions and 35 deletions

View File

@@ -10,9 +10,9 @@ import android.os.StatFs;
class AndroidFileUtils implements FileUtils {
public long getFreeSpace(File f) throws IOException {
if(Build.VERSION.SDK_INT >= 9) return f.getUsableSpace();
StatFs s = new StatFs(f.getAbsolutePath());
if(Build.VERSION.SDK_INT >= 18)
return s.getAvailableBlocksLong() * s.getBlockSizeLong();
// These deprecated methods are the best thing available for SDK < 9
return (long) s.getAvailableBlocks() * s.getBlockSize();
}
}

View File

@@ -275,19 +275,23 @@ class TorPlugin implements DuplexPlugin, EventHandler {
}
private boolean setExecutable(File f) {
String[] command = { "chmod", "700", f.getAbsolutePath() };
try {
return Runtime.getRuntime().exec(command).waitFor() == 0;
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(InterruptedException e) {
if(LOG.isLoggable(WARNING))
LOG.warning("Interrupted while executing chmod");
Thread.currentThread().interrupt();
} catch(SecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
if(Build.VERSION.SDK_INT >= 9) {
return f.setExecutable(true, true);
} else {
String[] command = { "chmod", "700", f.getAbsolutePath() };
try {
return Runtime.getRuntime().exec(command).waitFor() == 0;
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(InterruptedException e) {
if(LOG.isLoggable(WARNING))
LOG.warning("Interrupted while executing chmod");
Thread.currentThread().interrupt();
} catch(SecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
return false;
}
return false;
}
private void tryToClose(InputStream in) {