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();
|
setLocale();
|
||||||
|
|
||||||
bindService();
|
|
||||||
startService(new Intent(INTENT_TOR_SERVICE));
|
|
||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
setContentView(R.layout.layout_main);
|
setContentView(R.layout.layout_main);
|
||||||
|
@ -95,8 +92,6 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
imgStatus = (ImageView)findViewById(R.id.imgStatus);
|
imgStatus = (ImageView)findViewById(R.id.imgStatus);
|
||||||
imgStatus.setOnLongClickListener(this);
|
imgStatus.setOnLongClickListener(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -244,27 +239,14 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
|
unbindService();
|
||||||
|
|
||||||
hideProgressDialog();
|
hideProgressDialog();
|
||||||
|
|
||||||
if (aDialog != null)
|
if (aDialog != null)
|
||||||
aDialog.dismiss();
|
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 ()
|
private void doTorCheck ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -327,6 +309,11 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
|
|
||||||
setLocale();
|
setLocale();
|
||||||
|
|
||||||
|
bindService();
|
||||||
|
// startService(new Intent(INTENT_TOR_SERVICE));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (getIntent() == null)
|
if (getIntent() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -425,7 +412,7 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
|
||||||
//unbindService();
|
unbindService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -607,9 +594,6 @@ public class Orbot extends Activity implements TorConstants, OnLongClickListener
|
||||||
// to start Tor
|
// to start Tor
|
||||||
private void startTor () throws RemoteException
|
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
|
// 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"
|
// 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 ()
|
private void hideProgressDialog ()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (progressDialog != null && progressDialog.isShowing())
|
if (progressDialog != null && progressDialog.isShowing())
|
||||||
{
|
{
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
progressDialog = null;
|
progressDialog = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,11 +77,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
private File filePrivoxy;
|
private File filePrivoxy;
|
||||||
private File fileObfsProxy;
|
private File fileObfsProxy;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void logMessage(String msg)
|
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);
|
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
mNotificationManager.cancelAll();
|
mNotificationManager.cancelAll();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showToolbarNotification (String notifyMsg, int notifyId, int icon, int flags)
|
private void showToolbarNotification (String notifyMsg, int notifyId, int icon, int flags)
|
||||||
|
@ -323,6 +320,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
{
|
{
|
||||||
killTorProcess ();
|
killTorProcess ();
|
||||||
|
|
||||||
|
//stop the foreground priority and make sure to remove the persistant notification
|
||||||
|
stopForeground(true);
|
||||||
|
|
||||||
currentStatus = STATUS_OFF;
|
currentStatus = STATUS_OFF;
|
||||||
|
|
||||||
clearNotifications();
|
clearNotifications();
|
||||||
|
@ -793,7 +793,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
initControlConnection ();
|
initControlConnection ();
|
||||||
|
|
||||||
applyPreferences();
|
updateTorConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,6 +1033,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
startForeground(NOTIFY_ID,notice);
|
startForeground(NOTIFY_ID,notice);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1156,6 +1157,15 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
_torInstance = this;
|
_torInstance = this;
|
||||||
initTorPaths();
|
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 ()
|
new Thread ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1208,8 +1218,14 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
|
|
||||||
try {
|
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)
|
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);
|
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 useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
||||||
|
|
||||||
//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
|
//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
|
||||||
|
|
Loading…
Reference in New Issue