Phone actions, groundwork: the executor and its settings, before the server's phone_action
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
- actions/PhoneActions: standard intents for alarm, timer, calendar insert, SMS and email drafts, dial (the dialler, never a call), open URL (http/https only), open app (package or launcher label), settings panels, automation broadcasts (never android.* / com.android.*); torch via CameraManager; media keys via AudioManager. - actions/Navigation: Google Maps (google.navigation:, the dir URL with waypoints, geo:0,0?q=; no adding to a running route, no stop) and OsmAnd through its intent API only (osmand.api:// navigate, navigate_gpx with route points as GPX data, navigate_search, stop_navigation; no OsmAnd code, which is GPLv3). add_stop re-plans here -> stop -> destination. - Optional OsmAnd get_info (Settings switch, after allowing LLeMbas inside OsmAnd): position and the running route's destination, through a see-through ResultActivity. - Settings › Navigation app: whichever is installed (both: ask), Google Maps, OsmAnd, ask. - Not wired yet: the confirm card and the capability wait for the server's spec 3.6.0 fixtures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
19 files changed
+900
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package eu.llembas.android
|
||||
|
||||
import eu.llembas.android.actions.Args
|
||||
import eu.llembas.android.actions.NavApp
|
||||
import eu.llembas.android.actions.NavIntents
|
||||
import eu.llembas.android.actions.PhoneActions
|
||||
import eu.llembas.android.actions.Place
|
||||
import eu.llembas.android.api.LembasJson
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class PhoneActionsTest {
|
||||
private fun args(json: String) = Args(LembasJson.parseToJsonElement(json).jsonObject)
|
||||
|
||||
@Test
|
||||
fun placesAreReadLeniently() {
|
||||
val a = args("""{"destination": {"name": "Rivendell", "lat": "47.1", "lon": 8.5}, "stops": ["Bree", {"query": "inn"}], "hour": "7"}""")
|
||||
assertEquals(Place("Rivendell", 47.1, 8.5), a.place("destination"))
|
||||
assertEquals(listOf(Place(query = "Bree"), Place(query = "inn")), a.places("stops"))
|
||||
assertEquals(7, a.int("hour"))
|
||||
assertNull(a.place("missing"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theNavigationAppIsTheOneInstalledOrAsked() {
|
||||
val both = listOf(NavApp.GoogleMaps, NavApp.OsmAnd)
|
||||
assertEquals(NavApp.OsmAnd, NavApp.chosen("", listOf(NavApp.OsmAnd)))
|
||||
// Both installed and nothing chosen: the card asks.
|
||||
assertNull(NavApp.chosen("", both))
|
||||
assertEquals(NavApp.GoogleMaps, NavApp.chosen("google", both))
|
||||
assertNull(NavApp.chosen(NavApp.PREF_ASK, both))
|
||||
// Chosen but since uninstalled: the one there is.
|
||||
assertEquals(NavApp.GoogleMaps, NavApp.chosen("osmand", listOf(NavApp.GoogleMaps)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aRouteForOsmAndIsGpxWithItsPointsInOrder() {
|
||||
val gpx = NavIntents.gpx(listOf(Place("Bree & Co", 1.0, 2.0), Place("Rivendell", 3.0, 4.0)))
|
||||
assertTrue(gpx.contains("<rtept lat=\"1.0\" lon=\"2.0\"><name>Bree & Co</name></rtept><rtept lat=\"3.0\" lon=\"4.0\">"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aBroadcastNeverNamesASystemAction() {
|
||||
assertTrue(PhoneActions.broadcastAllowed("net.dinglisch.android.tasker.ACTION_TASK"))
|
||||
assertTrue(PhoneActions.broadcastAllowed("lembas.lights_off"))
|
||||
assertFalse(PhoneActions.broadcastAllowed("android.intent.action.BOOT_COMPLETED"))
|
||||
assertFalse(PhoneActions.broadcastAllowed("com.android.something"))
|
||||
assertFalse(PhoneActions.broadcastAllowed("has spaces"))
|
||||
}
|
||||
}
|
||||
@@ -363,6 +363,7 @@ object Fakes {
|
||||
selfUpdate = true,
|
||||
phoneRecognizer = true,
|
||||
wakeAvailable = true,
|
||||
navApps = listOf("google", "osmand"),
|
||||
)
|
||||
|
||||
// The assistant's sheet, as it opens and as it answers.
|
||||
|
||||
Reference in new issue
Block a user