[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] handle NPE in case service disconnects
commit c4cf845650aee14ef2bca637937f253fc13701b5
Author: Nathan Freitas <nathan@xxxxxxxxxxx>
Date: Mon Jul 14 13:16:19 2014 -0400
handle NPE in case service disconnects
---
src/org/torproject/android/Orbot.java | 60 ++++++++++-----------------------
1 file changed, 18 insertions(+), 42 deletions(-)
diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index 06ffe57..2c63711 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -1082,22 +1082,25 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
mHandler.sendMessage(msg);
}
- long[] bws = mService.getBandwidth();
- Message msg = mHandler.obtainMessage(TorServiceConstants.MESSAGE_TRAFFIC_COUNT);
- msg.getData().putLong("download", bws[0]);
- msg.getData().putLong("upload", bws[1]);
- msg.getData().putLong("readTotal", bws[2]);
- msg.getData().putLong("writeTotal", bws[3]);
- mHandler.sendMessage(msg);
-
- try { Thread.sleep(1000); }
- catch (Exception e){}
-
-
- torStatus = mService.getStatus();
+ if (mService != null)
+ {
+ long[] bws = mService.getBandwidth();
+ Message msg = mHandler.obtainMessage(TorServiceConstants.MESSAGE_TRAFFIC_COUNT);
+ msg.getData().putLong("download", bws[0]);
+ msg.getData().putLong("upload", bws[1]);
+ msg.getData().putLong("readTotal", bws[2]);
+ msg.getData().putLong("writeTotal", bws[3]);
+ mHandler.sendMessage(msg);
+
+ try { Thread.sleep(1000); }
+ catch (Exception e){}
+ }
+
+ if (mService != null)
+ torStatus = mService.getStatus();
}
}
- catch (RemoteException re)
+ catch (Exception re)
{
Log.e(TAG, "error getting service updates",re);
}
@@ -1230,37 +1233,10 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
mKeepUpdating = false;
mService = null;
Log.d(TAG,"service was disconnected");
+
}
};
-
- /*
- private void createProgressDialog (String msg)
- {
- if (progressDialog != null && progressDialog.isShowing())
- {
- progressDialog.setMessage(msg);
- }
- else
- {
- progressDialog = ProgressDialog.show(Orbot.this, "", msg);
- progressDialog.setCancelable(true);
- }
- }
-
- private void hideProgressDialog ()
- {
-
- if (progressDialog != null && progressDialog.isShowing())
- {
- progressDialog.dismiss();
- progressDialog = null;
- }
-
- }
- */
-
-
private void setLocale ()
{
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits