[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] small cleanup of asynctask and error handling
commit a6da4bf5306d794b50aeb2b043485d151537841e
Author: Nathan Freitas <nathan@xxxxxxxxxxx>
Date: Thu Jul 10 11:23:49 2014 -0400
small cleanup of asynctask and error handling
---
src/org/torproject/android/service/TorService.java | 22 ++++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 4d5bb6d..9ed28b9 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -231,7 +231,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
R.layout.layout_notification_expanded);
expandedView.setTextViewText(R.id.text, notifyMsg);
- expandedView.setTextViewText(R.id.title, "ORBOT "+exitIP);
+ expandedView.setTextViewText(R.id.title, getString(R.string.app_name)+ ' ' + exitIP);
//expandedView.setTextViewText(R.id.exitIP, exitIP);
//expandedView.setOnClickPendingIntent(R.id._tor_notificationBT, pendIntent);
expandedView.setImageViewResource(R.id.icon, icon);
@@ -1370,42 +1370,42 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}
- private class getExternalIP extends AsyncTask<String, Void, Void>{
+ private class getExternalIP extends AsyncTask<String, Void, String>{
private long time;
- private String nodeDetails;
@Override
- protected Void doInBackground(String... params) {
+ protected String doInBackground(String... params) {
time = System.nanoTime();
try {
- nodeDetails = conn.getInfo("ns/name/"+params[0]);
+ String nodeDetails = conn.getInfo("ns/name/"+params[0]);
if (ENABLE_DEBUG_LOG)
{
Log.d(TAG,"Node Details: "+nodeDetails);
sendCallbackLogMessage("Node Details: "+nodeDetails);
}
+ return nodeDetails;
+
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Log.e(TorService.TAG,"Error getting node details",e);
}
return null;
}
@Override
- protected void onPostExecute(Void result) {
+ protected void onPostExecute(String result) {
// check if we need to update the exit IP
if(time > exitIPTime) {
exitIPTime = time;
Pattern pattern = Pattern.compile(IPADDRESS_PATTERN);
Matcher matcher = null;
- if(nodeDetails!=null){
- matcher = pattern.matcher(nodeDetails);
+ if(result!=null){
+ matcher = pattern.matcher(result);
if (matcher.find()) {
- Log.d(TAG, "ip: "+matcher.group());
exitIP = matcher.group();
+ sendCallbackLogMessage("Exit IP: "+exitIP);
}
}
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits