start echobot as backgound activity

This commit is contained in:
Dan Ballard 2017-08-23 08:06:07 -07:00
parent db899ffcf6
commit 03e0ea6bb4
1 changed files with 17 additions and 28 deletions

View File

@ -1,6 +1,7 @@
package im.ricochet.androidod; package im.ricochet.androidod;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.StrictMode; import android.os.StrictMode;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
@ -56,36 +57,24 @@ public class ConnectActivity extends AppCompatActivity {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy); StrictMode.setThreadPolicy(policy);
Log.i(TAG, "Attempting manual java connection to tor control");
try {
Socket socket = new Socket("127.0.0.1", 9051);
PrintWriter out =
new PrintWriter(socket.getOutputStream(), true);
BufferedReader in =
new BufferedReader(
new InputStreamReader(socket.getInputStream()));
out.write("hello");
//String result = in.readLine();
Log.i(TAG, "wrote");
//in.close();
socket.close();
} catch (Exception e) {
Log.e(TAG, e.toString());
Log.e(TAG, Log.getStackTraceString(e));
}
Log.i(TAG, "Go Net Test...");
try {
boolean ok = GoRicochetMobile.testNet();
Log.i(TAG, "NetTest: " + ok);
} catch(Exception e) {
}
Log.i(TAG, "Starting Echo Bot"); Log.i(TAG, "Starting Echo Bot");
//GoRicochetMobile.echoBot(privateKey);
new EchoBot(privateKey).execute();
}
private class EchoBot extends AsyncTask<Void, Void, Void> {
String privateKey;
public EchoBot(String privateKey) {
this.privateKey = privateKey;
}
@Override
public Void doInBackground(Void... voids) {
GoRicochetMobile.echoBot(privateKey); GoRicochetMobile.echoBot(privateKey);
return null;
}
} }
} }