hotfix: fallback to retry when install confirmation stays pending

When Android remains in pendingUserAction without progressing, the app could stay stuck in Requesting installation.
Add a minimal timeout fallback in the Android package manager flow: after 10s in pending confirmation, transition to InstallCancelled and release the install slot so users can immediately retry.
This commit is contained in:
Henrique Velloso
2026-02-20 15:25:11 -03:00
parent 60e2bac3a2
commit 7b1f2a3ef7
@@ -69,6 +69,7 @@ final class AndroidPackageManager extends PackageManager {
static const _methodChannel = MethodChannel('android_package_manager');
static const _eventChannel = EventChannel('android_package_manager/events');
static const _pendingUserActionTimeout = Duration(seconds: 10);
bool _supportsSilentInstall = false;
int _syncGeneration = 0;
@@ -227,6 +228,24 @@ final class AndroidPackageManager extends PackageManager {
break;
case InstallStatus.pendingUserAction:
// If pending user action lingers too long, treat it like dismiss/cancel
// and surface "Install (retry)" instead of staying stuck requesting.
if (existingOp is Installing &&
!existingOp.isSilent &&
DateTime.now().difference(existingOp.startedAt) >=
_pendingUserActionTimeout) {
if (filePath != null) {
setOperation(
appId,
InstallCancelled(target: target, filePath: filePath),
);
} else {
clearOperation(appId);
}
clearInstallSlot(appId);
break;
}
// User action required. Ensure we don't get stuck in Verifying if the
// STARTED event was missed; show Installing state.
// Skip if already in Installing or SystemProcessing to preserve the