remove issue with service launching via explicit intent

This commit is contained in:
Nathan Freitas 2014-02-22 19:16:55 -05:00
parent 87411bea85
commit c1cb30d1bb
3 changed files with 11 additions and 5 deletions

View File

@ -298,7 +298,7 @@ public class Orbot extends SherlockActivity implements TorConstants, OnLongClick
stopTor(); stopTor();
//perhaps this should be referenced as INTENT_TOR_SERVICE as in startService //perhaps this should be referenced as INTENT_TOR_SERVICE as in startService
stopService(new Intent(ITorService.class.getName())); stopService(new Intent(this,TorService.class));
//clears all notifications from the status bar //clears all notifications from the status bar
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
@ -1053,7 +1053,7 @@ public class Orbot extends SherlockActivity implements TorConstants, OnLongClick
private void bindService () private void bindService ()
{ {
Intent iTorService = new Intent(ITorService.class.getName()); Intent iTorService = new Intent(this, TorService.class);
getApplication().getApplicationContext().startService(iTorService); getApplication().getApplicationContext().startService(iTorService);

View File

@ -25,7 +25,7 @@ public interface TorConstants {
+ "ControlPort 9051\nCookieAuthentication 1\nRelayBandwidthRate 20 KBytes\nRelayBandwidthBurst 20 KBytes\nAutomapHostsOnResolve 1\nTransPort 9040\n"; + "ControlPort 9051\nCookieAuthentication 1\nRelayBandwidthRate 20 KBytes\nRelayBandwidthBurst 20 KBytes\nAutomapHostsOnResolve 1\nTransPort 9040\n";
*/ */
public final static String INTENT_TOR_SERVICE = "org.torproject.android.service.TOR_SERVICE"; // public final static String INTENT_TOR_SERVICE = "org.torproject.android.service.TOR_SERVICE";
public final static String HANDLER_TOR_MSG = "torServiceMsg"; public final static String HANDLER_TOR_MSG = "torServiceMsg";

View File

@ -132,6 +132,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
private boolean findExistingProc () private boolean findExistingProc ()
{ {
// android.os.Debug.waitForDebugger();
if (fileTorLink != null) if (fileTorLink != null)
{ {
try try
@ -1190,8 +1192,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
sendCallbackStatusMessage(written, read, mTotalTrafficWritten, mTotalTrafficRead); sendCallbackStatusMessage(written, read, mTotalTrafficWritten, mTotalTrafficRead);
if(++notificationCounter%10==0) // if(++notificationCounter%10==0)
startService(new Intent(INTENT_TOR_SERVICE)); // startService(new Intent(ITorService.class.getName()));
} }
@ -1288,6 +1290,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
else else
return node; return node;
} }
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
@ -1311,11 +1314,14 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}; };
thread.start(); thread.start();
return mBinder;
/**
if (ITorService.class.getName().equals(intent.getAction())) { if (ITorService.class.getName().equals(intent.getAction())) {
return mBinder; return mBinder;
} }
else else
return null; return null;
*/
} }
/** /**