Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

fix(android): cover navigation boundaries and log failed home actions

aixialun0a9f9acfe317
diff --git a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
index ea6b309..36becbe 100644
--- a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
+++ b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt
@@ -368,10 +368,16 @@ class BodyCoreService : Service() {
// A user home gesture must also leave the app underneath the overlay.
override fun onHomeSwipe() {
dispatcher.compactForUser()
- val handled = ScreenBodyService.get()?.performGlobalAction(
+ val homeResult = ScreenBodyService.get()?.performGlobalAction(
AccessibilityService.GLOBAL_ACTION_HOME,
- ) == true
- if (!handled) {
+ )
+ if (homeResult != true) {
+ if (homeResult == false) {
+ android.util.Log.w(
+ "AndeeNavigation",
+ "GLOBAL_ACTION_HOME returned false; card folded, attempting launcher fallback",
+ )
+ }
runCatching {
startActivity(Intent(Intent.ACTION_MAIN).apply {
addCategory(Intent.CATEGORY_HOME)
diff --git a/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt b/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
index 9c82434..998fd6d 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/FloatingWindowUi.kt
@@ -207,10 +207,10 @@ class FloatingWindowUi(
* gesture, which a fullscreen touchable overlay would otherwise swallow
* before the launcher ever saw it (a touch that has entered this window
* cannot be forwarded by returning false from `onTouchEvent`). The
- * window detects it itself and reports it, because that is the one path
- * that does not need the accessibility service — which this ROM is free
- * to revoke. The host folds the card, exactly as [onMinimizeClick]
- * does: the two are the same intent reached by two gestures.
+ * window detects it itself so folding does not need accessibility.
+ * Returning the underlying app to the launcher is best-effort: the host
+ * uses accessibility HOME when available, then a launcher Intent, which
+ * a ROM may restrict from the background.
*/
fun onHomeSwipe()
diff --git a/app/src/test/java/net/kuafuai/andee/ui/HomeNavigationTrackerTest.kt b/app/src/test/java/net/kuafuai/andee/ui/HomeNavigationTrackerTest.kt
new file mode 100644
index 0000000..abef59e
--- /dev/null
+++ b/app/src/test/java/net/kuafuai/andee/ui/HomeNavigationTrackerTest.kt
@@ -0,0 +1,57 @@
+package net.kuafuai.andee.ui
+
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class HomeNavigationTrackerTest {
+ private val tracker = HomeNavigationTracker()
+ private fun note(pkg: String, transient: Boolean = false) =
+ tracker.note(pkg, "andee", "launcher", transient)
+
+ @Test fun `send closing input through keyboard and system UI keeps conversation open`() {
+ repeat(3) {
+ assertFalse(note("launcher"))
+ assertFalse(note("andee"))
+ assertFalse(note("keyboard", true))
+ assertFalse(note("android", true))
+ assertFalse(note("systemui", true))
+ assertFalse(note("launcher"))
+ assertFalse(note("launcher"))
+ }
+ }
+
+ @Test fun `reopening the launcher trampoline does not count as home navigation`() {
+ assertFalse(note("launcher"))
+ assertFalse(note("launcher"))
+ assertFalse(note("andee"))
+ assertFalse(note("systemui", true))
+ assertFalse(note("launcher"))
+ }
+
+ @Test fun `return from another app still counts after transient system events`() {
+ assertFalse(note("browser"))
+ assertFalse(note("systemui", true))
+ assertTrue(note("launcher"))
+ assertFalse(note("launcher"))
+ }
+ @Test fun `first home event has no previous app and cannot fold`() {
+ assertFalse(note("launcher"))
+ assertFalse(note("launcher"))
+ }
+
+ @Test fun `IME event between real apps does not replace navigation history`() {
+ assertFalse(note("browser"))
+ assertFalse(note("newly_enabled_keyboard", true))
+ assertFalse(note("mail"))
+ assertFalse(note("keyboard", true))
+ assertTrue(note("launcher"))
+ assertFalse(note("launcher"))
+ }
+
+ @Test fun `unresolved launcher cannot be classified as home`() {
+ assertFalse(tracker.note("browser", "andee", null, false))
+ assertFalse(tracker.note("launcher", "andee", null, false))
+ }
+
+}
diff --git a/app/src/test/java/net/kuafuai/andee/ui/HomeSwipeRegionTest.kt b/app/src/test/java/net/kuafuai/andee/ui/HomeSwipeRegionTest.kt
new file mode 100644
index 0000000..3bfa57c
--- /dev/null
+++ b/app/src/test/java/net/kuafuai/andee/ui/HomeSwipeRegionTest.kt
@@ -0,0 +1,22 @@
+package net.kuafuai.andee.ui
+
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class HomeSwipeRegionTest {
+ @Test fun `input row and resized card edge cannot start home`() {
+ // 1200x2664 phone at 3.25 px per dp; 24 dp navigation edge.
+ for (y in listOf(1537f, 1600f, 2390f, 2500f, 2585f)) {
+ assertFalse(HomeSwipeRegion.contains(y, 2664, 78))
+ }
+ assertTrue(HomeSwipeRegion.contains(2586f, 2664, 78))
+ assertTrue(HomeSwipeRegion.contains(2645f, 2664, 78))
+ assertFalse(HomeSwipeRegion.contains(2664f, 2664, 78))
+ }
+
+ @Test fun `landscape uses the current screen edge`() {
+ assertFalse(HomeSwipeRegion.contains(1100f, 1200, 78))
+ assertTrue(HomeSwipeRegion.contains(1190f, 1200, 78))
+ }
+}