Modern Apps git

← Modern-Apps.git

auto: a rebound host session no longer inherits the dead app's screen stack

Commit
224497ce5115d7aafb43cf3948f9a249d2ab8217
Author
Vayun Mathur <[email protected]>
When
2026-12-01 04:59 UTC (5 days ago)
Parents
3ccbfef
resetApp reuses the same HostSession (unbind -> bind) and is
documented as 'the app builds a fresh screen stack from its
root'; the stack's own doc says resetApp clears the mirror.
But unbind() cleared carApp/handshakeDone/surfaceCallback
and never taskStack, whose reset() ran only from
navigationStarted. An app that had pushed six distinct
non-Navigation templates (depth > 5, 'Too many screens' shown)
was judged against that dead stack after rebind — non-
Navigation apps could never recover their screen quota.
(A re-appearance via dropGone was safe: it builds a new
object.)

unbind() now calls taskStack.reset() beside the other
teardown, making the rebind actually start from the app
root. New regression test records six templates, unbinds,
and asserts the quota is fresh (disallowed pre-fix). Note:
the remotely module named in the hunt brief does not exist;
this work was scoped to :auto, the remote-access module.
Verified: :auto:testDevUnitTest 377 tests pass; lint errors
are pre-existing on an untouched file.

Diff

auto/src/main/java/com/vayunmathur/auto/platform/HostSession.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/HostSession.kt b/auto/src/main/java/com/vayunmathur/auto/platform/HostSession.ktindex 2fd8cdab7a..7bb8b48382 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/HostSession.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/HostSession.kt@@ -91,7 +91,7 @@ class HostSession(     private var connection: ServiceConnection? = null      /** Host-side mirror of the app's 5-template task stack (SPEC §2.2). */-    private val taskStack = HostTaskStack()+    internal val taskStack = HostTaskStack()      /** The component this session hosts. */     fun componentName(): ComponentName = component@@ -257,6 +257,10 @@ class HostSession(         val app = carApp         carApp = null         handshakeDone = false+        // The app's own stack dies with the binding, so the host's quota+        // mirror must too: a rebind (resetApp) starts from the app's root,+        // not from wherever the dead stack left the count.+        taskStack.reset()         if (app != null) {             runCatching { app.onAppPause(doneCallback()) }             runCatching { app.onAppStop(doneCallback()) }
auto/src/test/java/com/vayunmathur/auto/platform/HostSessionTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/platform/HostSessionTest.kt b/auto/src/test/java/com/vayunmathur/auto/platform/HostSessionTest.ktindex 6c8607dd29..61643f3c9a 100644--- a/auto/src/test/java/com/vayunmathur/auto/platform/HostSessionTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/platform/HostSessionTest.kt@@ -67,6 +67,23 @@ class HostSessionTest {         assertTrue(stack.isAllowed(HostTemplate.Grid()))     } +    @Test fun `unbind clears the task quota so a rebind starts from the app root`() {+        val session = HostSession(ctx, component, "nav", "Maps")+        // Drive the mirror past the 5-template quota with distinct kinds.+        session.taskStack.record(HostTemplate.Pane(title = "a"))+        session.taskStack.record(HostTemplate.Grid())+        session.taskStack.record(HostTemplate.PlaceList())+        session.taskStack.record(HostTemplate.Search())+        session.taskStack.record(HostTemplate.Tabs())+        session.taskStack.record(HostTemplate.SignIn())+        assertFalse(session.taskStack.isAllowed(HostTemplate.Grid()))+        // resetApp is unbind() then bind() on this same session object; the+        // dead app's stack is gone, so the mirror must be too or the fresh+        // root is judged against the dead depth and stuck on the error pane.+        session.unbind()+        assertTrue(session.taskStack.isAllowed(HostTemplate.Grid()))+    }+     @Test fun `display lifecycle steps to resumed then destroyed`() {         val lifecycle = CarDisplayLifecycle()         lifecycle.moveToResumed()