handle NPE in case service disconnects

This commit is contained in:
Nathan Freitas 2014-07-14 13:16:19 -04:00
parent 1e6ff3579b
commit c4cf845650
1 changed files with 17 additions and 41 deletions

View File

@ -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);
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){}
try { Thread.sleep(1000); }
catch (Exception e){}
}
torStatus = mService.getStatus();
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 ()
{