Open History to see the last commit
1/**
2 * Android reports the app as backgrounded while one of these covers the activity, so
3 * background-triggered work — like a deferred app update restart — has to wait them out instead
4 * of tearing down the mid-flow runtime.
5 */
6let activeHandoffs = 0;
7
8/** Returns an idempotent end function; call it when the handoff resolves. */
9export function beginForegroundHandoff(): () => void {
10 activeHandoffs += 1;
11 let ended = false;
12 return () => {
13 if (ended) return;
14 ended = true;
15 activeHandoffs -= 1;
16 };
17}
18
19export function isForegroundHandoffActive(): boolean {
20 return activeHandoffs > 0;
21}