Raised minimum Android version to 2.3 (API 9). #23

This commit is contained in:
akwizgran
2015-12-02 13:20:55 +00:00
parent 7841ae52ca
commit 79d9b4b6af
10 changed files with 71 additions and 111 deletions

View File

@@ -1,31 +1,17 @@
package org.briarproject.system;
import org.briarproject.api.system.FileUtils;
import java.io.File;
import java.io.IOException;
import org.briarproject.api.system.FileUtils;
import android.annotation.SuppressLint;
import android.os.Build;
import android.os.StatFs;
public class AndroidFileUtils implements FileUtils {
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public long getTotalSpace(File f) throws IOException {
if (Build.VERSION.SDK_INT >= 9) return f.getTotalSpace();
StatFs s = new StatFs(f.getAbsolutePath());
// These deprecated methods are the best thing available for SDK < 9
return (long) s.getBlockCount() * s.getBlockSize();
return f.getTotalSpace();
}
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public long getFreeSpace(File f) throws IOException {
if (Build.VERSION.SDK_INT >= 9) return f.getUsableSpace();
StatFs s = new StatFs(f.getAbsolutePath());
// These deprecated methods are the best thing available for SDK < 9
return (long) s.getAvailableBlocks() * s.getBlockSize();
return f.getUsableSpace();
}
}

View File

@@ -1,25 +1,19 @@
package org.briarproject.system;
import android.os.Build;
import java.io.DataOutputStream;
import java.io.IOException;
import android.annotation.SuppressLint;
import android.os.Build;
class AndroidSeedProvider extends LinuxSeedProvider {
@Override
@SuppressLint("NewApi")
void writeToEntropyPool(DataOutputStream out) throws IOException {
out.writeInt(android.os.Process.myPid());
out.writeInt(android.os.Process.myTid());
out.writeInt(android.os.Process.myUid());
String fingerprint = Build.FINGERPRINT;
if (fingerprint != null) out.writeUTF(fingerprint);
if (Build.VERSION.SDK_INT >= 9) {
String serial = Build.SERIAL;
if (serial != null) out.writeUTF(serial);
}
if (Build.FINGERPRINT != null) out.writeUTF(Build.FINGERPRINT);
if (Build.SERIAL != null) out.writeUTF(Build.SERIAL);
super.writeToEntropyPool(out);
}
}