attempted to address leaking bound service
This commit is contained in:
parent
eb2b7531c9
commit
3de5d66440
|
@ -82,9 +82,6 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
|||
|
||||
setLocale();
|
||||
|
||||
bindService();
|
||||
startService(new Intent(INTENT_TOR_SERVICE));
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
setContentView(R.layout.layout_main);
|
||||
|
@ -94,8 +91,6 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
|||
|
||||
imgStatus = (ImageView)findViewById(R.id.imgStatus);
|
||||
imgStatus.setOnLongClickListener(this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -244,26 +239,13 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
|||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
unbindService();
|
||||
|
||||
hideProgressDialog();
|
||||
|
||||
if (aDialog != null)
|
||||
aDialog.dismiss();
|
||||
}
|
||||
|
||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||
// Save UI state changes to the savedInstanceState.
|
||||
// This bundle will be passed to onCreate if the process is
|
||||
// killed and restarted.
|
||||
// etc.
|
||||
super.onSaveInstanceState(savedInstanceState);
|
||||
}
|
||||
|
||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
// Restore UI state from the savedInstanceState.
|
||||
// This bundle has also been passed to onCreate.
|
||||
|
||||
}
|
||||
|
||||
private void doTorCheck ()
|
||||
{
|
||||
|
@ -327,6 +309,11 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
|||
|
||||
setLocale();
|
||||
|
||||
bindService();
|
||||
// startService(new Intent(INTENT_TOR_SERVICE));
|
||||
|
||||
|
||||
|
||||
if (getIntent() == null)
|
||||
return;
|
||||
|
||||
|
@ -425,7 +412,7 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
|||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
||||
//unbindService();
|
||||
unbindService();
|
||||
}
|
||||
|
||||
|
||||
|
@ -607,9 +594,6 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
|||
// to start Tor
|
||||
private void startTor () throws RemoteException
|
||||
{
|
||||
// here we bind AGAIN - at some point i think we had to bind multiple times just in case
|
||||
// but i would love to clarify, clean this up
|
||||
bindService();
|
||||
|
||||
// this is a bit of a strange/old/borrowed code/design i used to change the service state
|
||||
// not sure it really makes sense when what we want to say is just "startTor"
|
||||
|
@ -877,12 +861,11 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
|||
private void hideProgressDialog ()
|
||||
{
|
||||
|
||||
if (progressDialog != null && progressDialog.isShowing())
|
||||
{
|
||||
progressDialog.dismiss();
|
||||
progressDialog = null;
|
||||
}
|
||||
|
||||
if (progressDialog != null && progressDialog.isShowing())
|
||||
{
|
||||
progressDialog.dismiss();
|
||||
progressDialog = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -77,11 +77,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
private File filePrivoxy;
|
||||
private File fileObfsProxy;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
}
|
||||
|
||||
public static void logMessage(String msg)
|
||||
{
|
||||
|
@ -168,6 +163,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
{
|
||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.cancelAll();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void showToolbarNotification (String notifyMsg, int notifyId, int icon, int flags)
|
||||
|
@ -322,7 +319,10 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
try
|
||||
{
|
||||
killTorProcess ();
|
||||
|
||||
|
||||
//stop the foreground priority and make sure to remove the persistant notification
|
||||
stopForeground(true);
|
||||
|
||||
currentStatus = STATUS_OFF;
|
||||
|
||||
clearNotifications();
|
||||
|
@ -793,7 +793,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
initControlConnection ();
|
||||
|
||||
applyPreferences();
|
||||
updateTorConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1033,6 +1033,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
startForeground(NOTIFY_ID,notice);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1156,6 +1157,15 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
_torInstance = this;
|
||||
initTorPaths();
|
||||
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
|
||||
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
|
||||
|
||||
prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true);
|
||||
|
||||
|
||||
new Thread ()
|
||||
{
|
||||
|
||||
|
@ -1208,8 +1218,14 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
|
||||
try {
|
||||
applyPreferences();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(TorService.this);
|
||||
|
||||
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
|
||||
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
|
||||
|
||||
prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true);
|
||||
|
||||
updateTorConfiguration();
|
||||
|
||||
if (currentStatus == STATUS_ON)
|
||||
{
|
||||
|
@ -1411,15 +1427,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
}
|
||||
|
||||
private boolean applyPreferences () throws RemoteException
|
||||
private boolean updateTorConfiguration () throws RemoteException
|
||||
{
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
|
||||
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
|
||||
|
||||
prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true);
|
||||
|
||||
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
||||
|
||||
//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
|
||||
|
|
Loading…
Reference in New Issue