kopia lustrzana https://github.com/ge0rg/aprsdroid
service: implement SEND_PACKET API
rodzic
fe0986009c
commit
4e93720b84
|
@ -83,6 +83,7 @@
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="org.aprsdroid.app.SERVICE" />
|
<action android:name="org.aprsdroid.app.SERVICE" />
|
||||||
<action android:name="org.aprsdroid.app.ONCE" />
|
<action android:name="org.aprsdroid.app.ONCE" />
|
||||||
|
<action android:name="org.aprsdroid.app.SEND_PACKET" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
</application>
|
</application>
|
||||||
|
|
|
@ -15,6 +15,7 @@ object AprsService {
|
||||||
// intent actions
|
// intent actions
|
||||||
val SERVICE = PACKAGE + ".SERVICE"
|
val SERVICE = PACKAGE + ".SERVICE"
|
||||||
val SERVICE_ONCE = PACKAGE + ".ONCE"
|
val SERVICE_ONCE = PACKAGE + ".ONCE"
|
||||||
|
val SERVICE_SEND_PACKET = PACKAGE + ".SEND_PACKET"
|
||||||
// broadcast actions
|
// broadcast actions
|
||||||
val UPDATE = PACKAGE + ".UPDATE" // something added to the log
|
val UPDATE = PACKAGE + ".UPDATE" // something added to the log
|
||||||
val MESSAGE = PACKAGE + ".MESSAGE" // we received a message/ack
|
val MESSAGE = PACKAGE + ".MESSAGE" // we received a message/ack
|
||||||
|
@ -73,6 +74,22 @@ class AprsService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
def handleStart(i : Intent) {
|
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,
|
// display notification (even though we are not actually started yet,
|
||||||
// but we need this to prevent error message reordering)
|
// but we need this to prevent error message reordering)
|
||||||
val toastString = if (i.getAction() == SERVICE_ONCE) {
|
val toastString = if (i.getAction() == SERVICE_ONCE) {
|
||||||
|
|
Ładowanie…
Reference in New Issue