Skip to content
Snippets Groups Projects
Commit 79d9b4b6 authored by akwizgran's avatar akwizgran
Browse files

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

parent 7841ae52
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
android:versionName="0.11" >
<uses-sdk
android:minSdkVersion="7"
android:minSdkVersion="9"
android:targetSdkVersion="22"
/>
......
package org.briarproject.android;
import static android.view.Gravity.CENTER;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static java.util.logging.Level.INFO;
import static org.briarproject.android.TestingConstants.DEFAULT_LOG_LEVEL;
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
import static org.briarproject.android.TestingConstants.TESTING;
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
import java.io.File;
import java.util.logging.Logger;
import org.briarproject.R;
import org.briarproject.android.util.LayoutUtils;
import org.briarproject.api.db.DatabaseConfig;
import roboguice.RoboGuice;
import roboguice.activity.RoboSplashActivity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.os.StrictMode.ThreadPolicy;
......@@ -31,6 +12,24 @@ import android.widget.LinearLayout;
import com.google.inject.Injector;
import org.briarproject.R;
import org.briarproject.android.util.LayoutUtils;
import org.briarproject.api.db.DatabaseConfig;
import java.io.File;
import java.util.logging.Logger;
import roboguice.RoboGuice;
import roboguice.activity.RoboSplashActivity;
import static android.view.Gravity.CENTER;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static java.util.logging.Level.INFO;
import static org.briarproject.android.TestingConstants.DEFAULT_LOG_LEVEL;
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
import static org.briarproject.android.TestingConstants.TESTING;
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
public class SplashScreenActivity extends RoboSplashActivity {
private static final Logger LOG =
......@@ -91,9 +90,8 @@ public class SplashScreenActivity extends RoboSplashActivity {
}
}
@SuppressLint("NewApi")
private void enableStrictMode() {
if (TESTING && Build.VERSION.SDK_INT >= 9) {
if (TESTING) {
ThreadPolicy.Builder threadPolicy = new ThreadPolicy.Builder();
threadPolicy.detectAll();
threadPolicy.penaltyLog();
......
package org.briarproject.android.util;
import android.annotation.SuppressLint;
import android.os.Build;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import android.annotation.SuppressLint;
import android.os.Build;
public class AndroidUtils {
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public static Collection<String> getSupportedArchitectures() {
List<String> abis = new ArrayList<String>();
List<String> abis = new ArrayList<>();
if (Build.VERSION.SDK_INT >= 21) {
for (String abi : Build.SUPPORTED_ABIS) abis.add(abi);
} else if (Build.VERSION.SDK_INT >= 8) {
abis.add(Build.CPU_ABI);
if (Build.CPU_ABI2 != null) abis.add(Build.CPU_ABI2);
abis.addAll(Arrays.asList(Build.SUPPORTED_ABIS));
} else {
abis.add(Build.CPU_ABI);
if (Build.CPU_ABI2 != null) abis.add(Build.CPU_ABI2);
}
return Collections.unmodifiableList(abis);
}
......
package org.briarproject.plugins.tor;
import static android.content.Context.CONNECTIVITY_SERVICE;
import static android.content.Context.MODE_PRIVATE;
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
import static android.net.ConnectivityManager.EXTRA_NO_CONNECTIVITY;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.FileObserver;
import net.freehaven.tor.control.EventHandler;
import net.freehaven.tor.control.TorControlConnection;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties;
import org.briarproject.api.crypto.PseudoRandom;
import org.briarproject.api.plugins.duplex.DuplexPlugin;
import org.briarproject.api.plugins.duplex.DuplexPluginCallback;
import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
import org.briarproject.api.system.LocationUtils;
import org.briarproject.util.StringUtils;
import java.io.EOFException;
import java.io.File;
......@@ -29,31 +43,16 @@ import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.zip.ZipInputStream;
import net.freehaven.tor.control.EventHandler;
import net.freehaven.tor.control.TorControlConnection;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties;
import org.briarproject.api.crypto.PseudoRandom;
import org.briarproject.api.plugins.duplex.DuplexPlugin;
import org.briarproject.api.plugins.duplex.DuplexPluginCallback;
import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
import org.briarproject.api.system.LocationUtils;
import org.briarproject.util.StringUtils;
import socks.Socks5Proxy;
import socks.SocksSocket;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.FileObserver;
import static android.content.Context.CONNECTIVITY_SERVICE;
import static android.content.Context.MODE_PRIVATE;
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
import static android.net.ConnectivityManager.EXTRA_NO_CONNECTIVITY;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
class TorPlugin implements DuplexPlugin, EventHandler {
......@@ -228,7 +227,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
out = new FileOutputStream(torFile);
copy(in, out);
// Make the Tor binary executable
if (!setExecutable(torFile)) {
if (!torFile.setExecutable(true, true)) {
LOG.warning("Could not make Tor binary executable");
return false;
}
......@@ -301,26 +300,6 @@ class TorPlugin implements DuplexPlugin, EventHandler {
out.close();
}
@SuppressLint("NewApi")
private boolean setExecutable(File f) {
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) {
LOG.warning("Interrupted while executing chmod");
Thread.currentThread().interrupt();
} catch (SecurityException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
return false;
}
}
private void tryToClose(InputStream in) {
try {
if (in != null) in.close();
......
package org.briarproject.system;
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;
import java.io.File;
import java.io.IOException;
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();
}
}
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);
}
}
......@@ -28,5 +28,6 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="guice-3.0-no_aop" level="project" />
<orderEntry type="library" exported="" name="javax.inject" level="project" />
<orderEntry type="library" exported="" name="briar-api.briar-api" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -32,5 +32,6 @@
<orderEntry type="library" exported="" name="h2small-1.3.170" level="project" />
<orderEntry type="library" exported="" name="lcrypto-jdk15on-152" level="project" />
<orderEntry type="library" exported="" name="weupnp-0.1.3-SNAPSHOT-briar" level="project" />
<orderEntry type="library" exported="" name="briar-core.briar-core" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -39,5 +39,6 @@
<orderEntry type="library" exported="" name="jnotify-0.94" level="project" />
<orderEntry type="library" exported="" name="bluecove-gpl-2.1.1-SNAPSHOT" level="project" />
<orderEntry type="library" exported="" name="jssc-0.9-briar" level="project" />
<orderEntry type="library" exported="" name="briar-desktop.briar-desktop" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -43,5 +43,6 @@
<orderEntry type="library" exported="" name="jmock-2.5.1" level="project" />
<orderEntry type="library" exported="" name="hamcrest-core-1.1" level="project" />
<orderEntry type="library" exported="" name="hamcrest-library-1.1" level="project" />
<orderEntry type="library" exported="" name="briar-tests.briar-tests" level="project" />
</component>
</module>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment