Skip to content

Commit

Permalink
don't track PackageInstaller sessions across app launches
Browse files Browse the repository at this point in the history
  • Loading branch information
muhomorr authored and thestinger committed Mar 20, 2023
1 parent e57d1f0 commit 89d8b84
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/src/main/java/app/grapheneos/apps/core/InstallerSessions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app.grapheneos.apps.core

import android.content.pm.PackageInstaller
import android.content.pm.PackageInstaller.SessionParams
import android.os.Build
import android.util.Log
import android.util.SparseArray
import app.grapheneos.apps.BuildConfig
Expand Down Expand Up @@ -71,6 +72,20 @@ object InstallerSessions {
continue
}

if (Build.VERSION.SDK_INT <= 33) {
// As of Android 13, committed PackageInstaller sessions sometimes get stuck and
// never complete. Sessions are persisted by the OS across reboots, which means that
// the package is stuck in "Installing..." state until the OS removes the session
// when it gets too old (see MAX_AGE_MILLIS in
// frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java),
// which is currently set to 3 days.
//
// As a workaround, don't track PackageInstaller sessions across app launches and
// abandon existing PackageInstaller sessions on startup.
abandonSession(sessionInfo)
continue
}

fun isSessionWaitingForUserAction(sessionInfo: PackageInstaller.SessionInfo): Boolean {
return if (isPrivilegedInstaller) {
val pkgName = getSessionPackageName(sessionInfo)
Expand Down

0 comments on commit 89d8b84

Please sign in to comment.