handle NPE in case service disconnects
This commit is contained in:
parent
1e6ff3579b
commit
c4cf845650
|
@ -1082,22 +1082,25 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
||||||
mHandler.sendMessage(msg);
|
mHandler.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
long[] bws = mService.getBandwidth();
|
if (mService != null)
|
||||||
Message msg = mHandler.obtainMessage(TorServiceConstants.MESSAGE_TRAFFIC_COUNT);
|
{
|
||||||
msg.getData().putLong("download", bws[0]);
|
long[] bws = mService.getBandwidth();
|
||||||
msg.getData().putLong("upload", bws[1]);
|
Message msg = mHandler.obtainMessage(TorServiceConstants.MESSAGE_TRAFFIC_COUNT);
|
||||||
msg.getData().putLong("readTotal", bws[2]);
|
msg.getData().putLong("download", bws[0]);
|
||||||
msg.getData().putLong("writeTotal", bws[3]);
|
msg.getData().putLong("upload", bws[1]);
|
||||||
mHandler.sendMessage(msg);
|
msg.getData().putLong("readTotal", bws[2]);
|
||||||
|
msg.getData().putLong("writeTotal", bws[3]);
|
||||||
try { Thread.sleep(1000); }
|
mHandler.sendMessage(msg);
|
||||||
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);
|
Log.e(TAG, "error getting service updates",re);
|
||||||
}
|
}
|
||||||
|
@ -1230,37 +1233,10 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
||||||
mKeepUpdating = false;
|
mKeepUpdating = false;
|
||||||
mService = null;
|
mService = null;
|
||||||
Log.d(TAG,"service was disconnected");
|
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 ()
|
private void setLocale ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue