mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user