diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e12ae49..6264bf8 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ - + android:versionCode="10" + android:versionName="0.9.9" > @@ -22,7 +22,13 @@ - + + + + + + + diff --git a/src/org/poirsouille/tinc_gui/BootReceiver.java b/src/org/poirsouille/tinc_gui/BootReceiver.java index db4d459..a11adaa 100644 --- a/src/org/poirsouille/tinc_gui/BootReceiver.java +++ b/src/org/poirsouille/tinc_gui/BootReceiver.java @@ -23,7 +23,7 @@ public void onReceive(Context iContext, Intent iIntent) { Log.i(Tools.TAG, "Autostarting Tinc GUI service"); // Start tincd service - Intent intent = new Intent(iContext, TincdService.class); + Intent intent = new Intent(iContext, TincdService.class).setAction("org.poirsouille.tinc_gui.TincdService.START"); iContext.startService(intent); } } diff --git a/src/org/poirsouille/tinc_gui/TincActivity.java b/src/org/poirsouille/tinc_gui/TincActivity.java index 6fd09b6..7465818 100644 --- a/src/org/poirsouille/tinc_gui/TincActivity.java +++ b/src/org/poirsouille/tinc_gui/TincActivity.java @@ -222,7 +222,7 @@ public void onClick(DialogInterface dialog, int id) else { // Start tincd service - Intent intent = new Intent(this,TincdService.class); + Intent intent = new Intent(this,TincdService.class).setAction("org.poirsouille.tinc_gui.TincdService.START"); startService(intent); } } diff --git a/src/org/poirsouille/tinc_gui/TincdService.java b/src/org/poirsouille/tinc_gui/TincdService.java index ebf0628..58a8eca 100644 --- a/src/org/poirsouille/tinc_gui/TincdService.java +++ b/src/org/poirsouille/tinc_gui/TincdService.java @@ -48,6 +48,7 @@ import android.os.Binder; import android.os.IBinder; import android.preference.PreferenceManager; +import android.sax.StartElementListener; import android.util.Log; public class TincdService extends Service implements ICallback @@ -357,16 +358,34 @@ public void toggleDebug() _debug = !_debug; } + /** + * Handle intent on startService call. Defines START & STOP actions to allow external applications to drive service. + */ @Override - public int onStartCommand(Intent intent, int flags, int startId) + public int onStartCommand(Intent iIntent, int flags, int startId) { // Because of the START_STICKY, the service might get restarted by the system after a kill, but with a null intent - if (intent != null) + if (iIntent != null) { - startTinc(); - Log.d(Tools.TAG, "Service started"); - showNotification(); + if (iIntent.getAction() == "org.poirsouille.tinc_gui.TincdService.START") + { + Log.i(Tools.TAG, "Received START intent for tincd service"); + startTinc(); + Log.d(Tools.TAG, "Service started"); + showNotification(); + } + else if (iIntent.getAction() == "org.poirsouille.tinc_gui.TincdService.STOP") + { + Log.i(Tools.TAG, "Received STOP intent for tincd service"); + stopTincd(); + } + else + { + Log.e(Tools.TAG, "Unkown intent action: " + iIntent.getAction()); + return START_NOT_STICKY; + } } + // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY;