API: expose setting for e.g. RepeaterBook

pull/227/head
Georg Lukas 2018-10-22 12:48:21 +02:00
rodzic b003112454
commit 1fb509a49b
4 zmienionych plików z 46 dodań i 0 usunięć

Wyświetl plik

@ -145,6 +145,7 @@
<action android:name="org.aprsdroid.app.ONCE" />
<action android:name="org.aprsdroid.app.SEND_PACKET" />
<action android:name="org.aprsdroid.app.SERVICE_STOP" />
<action android:name="org.aprsdroid.app.FREQUENCY" />
</intent-filter>
</service>
<!-- start the service if applicable on boot -->

Wyświetl plik

@ -22,6 +22,8 @@ Intents ("actions"):
* `ONCE` - send one position packet and stop
* `SERVICE_STOP` - stop APRSdroid's tracking service
* `SEND_PACKET` - send a (raw) APRS packet
* `FREQUENCY` - change the frequency announced in position packets (requires
APRSdroid 1.4.1)
All uppercase strings mentioned in this document are suffixes to
`"org.aprsdroid.app."` and need to be concatenated for the effective
@ -196,6 +198,29 @@ Example for sending a raw status packet:
i.putExtra("data", ">third-party APRS status app");
startService(i);
### FREQUENCY (APRSdroid 1.4.1)
Update the [frequency field](http://www.aprs.org/info/freqspec.txt) in the
position reports sent by APRSdroid. If the APRSdroid service is running, this
will immediately generate a position packet with the new frequency.
Intent extras:
* `frequency` (String): the new frequency value, e.g. "438.750MHz", "145.500"
or "" to disable, decimal separator must be a dot (".")
Example for updating the frequency:
// send raw status packet
Intent i = new Intent("org.aprsdroid.app.FREQUENCY").setPackage("org.aprsdroid.app");
i.putExtra("frequency", "438.750");
startService(i);
Invocation from the adb shell:
am startservice -a org.aprsdroid.app.FREQUENCY -e frequency "438.750"
## (In-)Security
Currently, APRSdroid exposes the following personal information via

Wyświetl plik

@ -16,6 +16,7 @@ object AprsService {
val SERVICE = PACKAGE + ".SERVICE"
val SERVICE_ONCE = PACKAGE + ".ONCE"
val SERVICE_SEND_PACKET = PACKAGE + ".SEND_PACKET"
val SERVICE_FREQUENCY = PACKAGE + ".FREQUENCY"
val SERVICE_STOP = PACKAGE + ".SERVICE_STOP"
// event intents
val SERVICE_STARTED = PACKAGE + ".SERVICE_STARTED"
@ -122,8 +123,23 @@ class AprsService extends Service {
data_field)
sendPacket(p)
return
} else
if (i.getAction() == SERVICE_FREQUENCY) {
val data_field = i.getStringExtra("frequency")
if (data_field == null) {
Log.d(TAG, "FREQUENCY ignored, 'frequency' extra is empty.")
return
}
val freq_cleaned = data_field.replace("MHz", "").trim
val freq = try { freq_cleaned.toFloat; freq_cleaned } catch { case _ : Throwable => "" }
if (prefs.getString("frequency", null) != freq) {
prefs.set("frequency", freq)
if (!running) return
// XXX: fall through into SERVICE_ONCE
} else 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) {

Wyświetl plik

@ -41,6 +41,10 @@ class PrefsWrapper(val context : Context) {
prefs.edit().putBoolean(name, new_val).commit()
new_val
}
def set(name : String, new_val : String) = {
prefs.edit().putString(name, new_val).commit()
new_val
}
def getShowObjects() = prefs.getBoolean("show_objects", true)
def getShowSatellite() = prefs.getBoolean("show_satellite", false)