more fixes for UI disconnect issue

ensure service and status updates occur on new layout updates
This commit is contained in:
Nathan Freitas 2014-06-11 07:07:48 -04:00
parent 7e76162b88
commit d7f3f1989d
1 changed files with 23 additions and 20 deletions

View File

@ -110,6 +110,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
{ {
Intent torService = new Intent(this, TorService.class); Intent torService = new Intent(this, TorService.class);
/*
if (Build.VERSION.SDK_INT > 14) if (Build.VERSION.SDK_INT > 14)
{ {
@ -118,10 +119,10 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
} }
else else
{ {
*/
bindService(torService, bindService(torService,
mConnection, Context.BIND_AUTO_CREATE); mConnection, Context.BIND_AUTO_CREATE);
} //}
startService(torService); startService(torService);
@ -183,6 +184,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
// Gesture detection // Gesture detection
mGestureDetector = new GestureDetector(this, new MyGestureDetector()); mGestureDetector = new GestureDetector(this, new MyGestureDetector());
} }
@ -534,13 +536,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
setResult(RESULT_OK, nResult); setResult(RESULT_OK, nResult);
} }
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleIntents();
}
private void handleIntents () private void handleIntents ()
{ {
@ -674,6 +669,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
doLayout(); doLayout();
updateStatus("");
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -799,19 +795,23 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (mService != null && torStatus != TorServiceConstants.STATUS_ON) if (mService != null)
{ {
try { try {
mService.processSettings();
if (torStatus != TorServiceConstants.STATUS_ON)
mService.processSettings();
setLocale(); setLocale();
} catch (RemoteException e) { } catch (RemoteException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
updateStatus("");
} }
AlertDialog aDialog = null; AlertDialog aDialog = null;
@ -901,8 +901,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
if (newTorStatus == TorServiceConstants.STATUS_ON) if (newTorStatus == TorServiceConstants.STATUS_ON)
{ {
if (torStatus != newTorStatus) //if (torStatus != newTorStatus)
{ //{
imgStatus.setImageResource(R.drawable.toron); imgStatus.setImageResource(R.drawable.toron);
// mViewMain.setBackgroundResource(R.drawable.onionrootonly); // mViewMain.setBackgroundResource(R.drawable.onionrootonly);
@ -912,7 +912,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
if (mItemOnOff != null) if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_stop); mItemOnOff.setTitle(R.string.menu_stop);
} //}
if (mTorServiceMsg != null && mTorServiceMsg.length() > 0) if (mTorServiceMsg != null && mTorServiceMsg.length() > 0)
{ {
@ -1193,6 +1193,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
// representation of that from the raw service object. // representation of that from the raw service object.
mService = ITorService.Stub.asInterface(service); mService = ITorService.Stub.asInterface(service);
torStatus = -1;
// We want to monitor the service for as long as we are // We want to monitor the service for as long as we are
// connected to it. // connected to it.
try { try {
@ -1206,9 +1208,9 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
} }
updateStatus("");
handleIntents(); handleIntents();
updateStatus("");
} catch (RemoteException e) { } catch (RemoteException e) {
// In this case the service has crashed before we could even // In this case the service has crashed before we could even
@ -1229,7 +1231,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
// This is called when the connection with the service has been // This is called when the connection with the service has been
// unexpectedly disconnected -- that is, its process crashed. // unexpectedly disconnected -- that is, its process crashed.
mService = null; mService = null;
Log.d(TAG,"service was disconnected");
} }
}; };
@ -1254,6 +1256,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
unbindService(mConnection); unbindService(mConnection);
mIsBound = false; mIsBound = false;
Log.d(TAG,"service was ubnound");
//maybe needs this? //maybe needs this?
mService = null; mService = null;
@ -1310,7 +1313,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
unbindService(); //unbindService();
} }
public class DataCount { public class DataCount {