commit 6e8ef24c7949120cd5c89d6959f281446749839a Author: Dan Ballard Date: Wed Aug 16 07:36:11 2017 -0700 Initial connect page that pulls in goRicochetMobile and attempts to connect to tor control diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1a486f --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild +/.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..a67baea --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Android OD + +A simple proof of concept usage of Ricochet + Tor on mobile +Uses: +- Orbot +- gomobile: to leverage the go ricochet protocol library diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..87a593f --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.0" + defaultConfig { + applicationId "im.ricochet.androidod" + minSdkVersion 16 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:25.3.1' + compile 'com.android.support.constraint:constraint-layout:1.0.2' + compile project(':goRicochetMobile') + + testCompile 'junit:junit:4.12' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..5799d2b --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/user/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/im/ricochet/androidod/ExampleInstrumentedTest.java b/app/src/androidTest/java/im/ricochet/androidod/ExampleInstrumentedTest.java new file mode 100644 index 0000000..5fefcec --- /dev/null +++ b/app/src/androidTest/java/im/ricochet/androidod/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package im.ricochet.androidod; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("im.ricochet.androidod", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..dd292ed --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/im/ricochet/androidod/ConnectActivity.java b/app/src/main/java/im/ricochet/androidod/ConnectActivity.java new file mode 100644 index 0000000..6078d54 --- /dev/null +++ b/app/src/main/java/im/ricochet/androidod/ConnectActivity.java @@ -0,0 +1,68 @@ +package im.ricochet.androidod; + +import android.content.SharedPreferences; +import android.os.StrictMode; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.ProgressBar; +import android.widget.TextView; + +import java.net.Socket; + +import goRicochetMobile.GoRicochetMobile; + +public class ConnectActivity extends AppCompatActivity { + + public static final String PREFERNCE_FILE = "im.ricochet.PREFERENCE_FILE"; + private static final String TAG = "InitActivity"; + private static final String PRIVATE_KEY_KEY = "privateKey"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(im.ricochet.androidod.R.layout.activity_connect); + + TextView progressText = (TextView)findViewById(im.ricochet.androidod.R.id.progressTextView); + progressText.setText("Loading private key..."); + + Log.i(TAG, "Loading private key..."); + SharedPreferences prefs = getSharedPreferences(PREFERNCE_FILE, MODE_PRIVATE); + String privateKey = prefs.getString(PRIVATE_KEY_KEY, ""); + Log.i(TAG, "Loaded! '" + privateKey + "'"); + if (privateKey.equals("")) { + Log.i(TAG, "Failed to load private key from preferences, generating new"); + progressText.setText("Generating private key..."); + try { + privateKey = GoRicochetMobile.generatePrivateKey(); + } catch (Exception e) { + Log.e(TAG, e.toString()); + } + Log.i(TAG, "Generated!: '" + privateKey + "'"); + SharedPreferences.Editor prefsEditor = prefs.edit(); + prefsEditor.putString(PRIVATE_KEY_KEY, privateKey); + prefsEditor.commit(); + } + Log.i(TAG, "Ready!"); + progressText.setText("Ready!"); + ProgressBar progressBar = (ProgressBar)findViewById(im.ricochet.androidod.R.id.progressBar); + progressBar.setVisibility(View.GONE); + + Log.i(TAG, "Setting thread policy perms"); + StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); + StrictMode.setThreadPolicy(policy); + + Log.i(TAG, "Attempting manual java connection to tor control"); + try { + Socket socket = new Socket("127.0.0.1", 5051); + } catch (Exception e) { + Log.e(TAG, e.toString()); + Log.e(TAG, Log.getStackTraceString(e)); + } + + + Log.i(TAG, "Starting Echo Bot"); + GoRicochetMobile.echoBot(privateKey); + } +} diff --git a/app/src/main/res/layout/activity_connect.xml b/app/src/main/res/layout/activity_connect.xml new file mode 100644 index 0000000..54a51d0 --- /dev/null +++ b/app/src/main/res/layout/activity_connect.xml @@ -0,0 +1,102 @@ + + + + + + + + + +