appstore: abandon installer session on write SecurityException
- Commit
87619f18d2a4dfc6d5bc1b5f76088913748e6e59- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 19:41 UTC (28 days ago)
- Parents
43acd03
Symptom: if PackageInstaller.Session.openWrite/fsync refused with SecurityException (rather than IOException), commit() returned false but left the session open and un-abandoned. The leaked pending session then sat against the package until the next install attempt's abandonPendingSessions sweep. Root cause: the writeFiles call site only caught IOException; SecurityException fell through to commit()'s outer catch, which logs and returns without touching the session it created. Fix: catch SecurityException at the write site too, abandon the session, and report failure the same way as an IO write failure. Mitigated already by the next attempt abandoning stale sessions, so this is a lifecycle leak, not a user-facing failure. Verification: :appstore:compileDevKotlin and :appstore:testDevUnitTest pass. No unit test: SessionInstaller needs a real PackageInstaller, unavailable to JVM tests.
Diff
appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.ktindex d6f6afb313..15b0c21ae6 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt@@ -82,6 +82,14 @@ class SessionInstaller( Log.error(TAG, "Write failed for $packageName: ${expected.message}", expected) abandonQuietly(session) return false+ } catch (expected: SecurityException) {+ // openWrite/fsync can refuse with SecurityException, not just+ // IOException. Without this the outer catch returns false with+ // the session still open and un-abandoned: a leaked pending+ // session for this package.+ Log.error(TAG, "Write failed for $packageName: ${expected.message}", expected)+ abandonQuietly(session)+ return false } commitSession(session, sessionId, packageName)