From 4e93720b8495d8bf2f0240c1e224610c976ef9d8 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Sun, 29 Dec 2013 19:09:39 +0100 Subject: [PATCH] service: implement SEND_PACKET API --- AndroidManifest.xml | 1 + src/AprsService.scala | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 14272af..48ad91c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -83,6 +83,7 @@ + diff --git a/src/AprsService.scala b/src/AprsService.scala index 8e77dc6..05d7c01 100644 --- a/src/AprsService.scala +++ b/src/AprsService.scala @@ -15,6 +15,7 @@ object AprsService { // intent actions val SERVICE = PACKAGE + ".SERVICE" val SERVICE_ONCE = PACKAGE + ".ONCE" + val SERVICE_SEND_PACKET = PACKAGE + ".SEND_PACKET" // broadcast actions val UPDATE = PACKAGE + ".UPDATE" // something added to the log val MESSAGE = PACKAGE + ".MESSAGE" // we received a message/ack @@ -73,6 +74,22 @@ class AprsService extends Service { } def handleStart(i : Intent) { + if (i.getAction() == SERVICE_SEND_PACKET) { + if (!running) { + Log.d(TAG, "SEND_PACKET ignored, service not running.") + return + } + val data_field = i.getStringExtra("data") + if (data_field == null) { + Log.d(TAG, "SEND_PACKET ignored, data extra is empty.") + return + } + val p = Parser.parseBody(prefs.getCallSsid(), APP_VERSION, null, + data_field) + sendPacket(p) + return + } + // display notification (even though we are not actually started yet, // but we need this to prevent error message reordering) val toastString = if (i.getAction() == SERVICE_ONCE) {