YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.upnp.server.ResumeRefreshPolicy Class Reference

What to do when a browser screen comes back to the foreground after the device or the app was suspended (screen off, Doze, a long time in the background). More...

Collaboration diagram for de.yaacc.upnp.server.ResumeRefreshPolicy:
Collaboration graph

Classes

enum  ListenerCheck
 The state of the network listener found on resume. More...
 

Static Public Member Functions

static ListenerCheck checkListener (boolean networkUsable, boolean initialized, boolean networkChanged, boolean multicastReceiving, boolean unicastReceiving)
 
static boolean shouldSearch (boolean listenerReenabled, long lastSearchAtMillis, long nowMillis)
 

Static Public Attributes

static final long SEARCH_MIN_INTERVAL_MILLIS = 30_000L
 A search that ran less than this ago is not repeated on resume.
 
static final long NEVER = -1L
 Value of "time of the last search" when there was none.
 

Detailed Description

What to do when a browser screen comes back to the foreground after the device or the app was suspended (screen off, Doze, a long time in the background).

No Android classes: unit-testable on the JVM.

Two decisions: whether the network listener (multicast receiver, unicast socket) is still usable or has to be re-created, and whether the devices are searched again.

Member Function Documentation

◆ checkListener()

static ListenerCheck de.yaacc.upnp.server.ResumeRefreshPolicy.checkListener ( boolean networkUsable,
boolean initialized,
boolean networkChanged,
boolean multicastReceiving,
boolean unicastReceiving )
static
Parameters
networkUsablea Wi-Fi, hotspot or other non-cellular network is there
initializedthe listener is enabled (handler and both sockets exist)
networkChangedthe active network differs from the one the listener was enabled on
multicastReceivingthe multicast receive loop is running
unicastReceivingthe unicast receive loop is running

Referenced by de.yaacc.upnp.server.NetworkDeviceListener.reenableIfStale().

Here is the caller graph for this function:

◆ shouldSearch()

static boolean de.yaacc.upnp.server.ResumeRefreshPolicy.shouldSearch ( boolean listenerReenabled,
long lastSearchAtMillis,
long nowMillis )
static
Parameters
listenerReenabledthe listener was re-created just now: its new sockets know no device
lastSearchAtMillismonotonic time of the last search, NEVER if none
nowMillismonotonic time now (same clock)
Returns
true if the devices are searched again now

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