YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.util.ExitRestartGuard Class Reference

Decides whether a start that comes right after an explicit exit (exit button, shutdown timer, idle timer) is a start the user wanted or the system bringing the app back (task 12.2). More...

Collaboration diagram for de.yaacc.util.ExitRestartGuard:
Collaboration graph

Classes

enum  Decision
 What the starting side does. More...
 
enum  StartReason
 Why something starts. More...
 
interface  Store
 Where the mark is kept (survives the process). More...
 

Public Member Functions

 ExitRestartGuard (Store store, LongSupplier clock)
 
void markExitRequested ()
 Called first thing in the exit, before anything is stopped.
 
void clearOnUserStart ()
 Called when the user starts the app: whatever starts later is a normal start.
 
Decision decide (StartReason reason)
 What a start for this reason does now.
 

Static Public Member Functions

static Decision decide (long exitRequestedAtMillis, long nowMillis, StartReason reason)
 The decision itself, without a store.
 

Static Public Attributes

static final long WINDOW_MILLIS = 120_000L
 The restart of a service after a process end comes within seconds (the system's first delay is one second, then it backs off).
 
static final long CLOCK_SKEW_MILLIS = 5_000L
 A clock that stepped back by this much or less still counts as "right after"; further back the mark can not be judged.
 

Detailed Description

Decides whether a start that comes right after an explicit exit (exit button, shutdown timer, idle timer) is a start the user wanted or the system bringing the app back (task 12.2).

The exit marks the time it was asked for before anything is stopped, and the mark is persisted (the process ends right after). What the system does afterwards can not be controlled from the process (a sticky restart of a service, a new process for some other reason, and every new process starts the UPnP server service), so the starting side asks: an sticky restart, a process start or a restored screen within WINDOW_MILLIS of the mark stops itself. A start by the user (StartReason#USER_LAUNCH) is never blocked and clears the mark, so a later start by anything is a normal start; the window is the second safety, the mark never blocks for long even if nobody clears it. A boot is a new session and always starts (the autostart is the user's choice).

Fails open: a store that can not be read or written never blocks a start and never makes the exit fail.

Member Function Documentation

◆ clearOnUserStart()

void de.yaacc.util.ExitRestartGuard.clearOnUserStart ( )

Called when the user starts the app: whatever starts later is a normal start.

Never throws.

Referenced by de.yaacc.Yaacc.userStarted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decide()

Decision de.yaacc.util.ExitRestartGuard.decide ( StartReason reason)

What a start for this reason does now.

Never throws; an unreadable store allows the start; after a user start in this process always START.

Here is the call graph for this function:

◆ markExitRequested()

void de.yaacc.util.ExitRestartGuard.markExitRequested ( )

Called first thing in the exit, before anything is stopped.

Never throws.

Referenced by de.yaacc.Yaacc.exit().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: