public class SystemWatchdogManager
extends java.lang.Object
It allows applications to initialize and refresh the system watchdog service. If the system watchdog is not refreshed within the configured timeout, the system will reboot.
Unless noted, all system watchdog API methods require the
com.digi.android.permission.WATCHDOG
permission. If your
application does not have this permission it will not be able to interact
with the system watchdog API.
ApplicationWatchdogManager
Modifier and Type | Field and Description |
---|---|
static long |
MINIMUM_WATCHDOG_TIMEOUT
Minimum configurable timeout for the system watchdog service:
500L milliseconds.
|
Constructor and Description |
---|
SystemWatchdogManager(android.content.Context context)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
getTimeout()
Returns the configured system watchdog service timeout.
|
long |
init(long timeout)
Initializes the system watchdog service with the given timeout (in
milliseconds).
|
boolean |
isRunning()
Returns whether the system watchdog service has been initialized or not.
|
void |
refresh()
Refreshes the system watchdog.
|
public static final long MINIMUM_WATCHDOG_TIMEOUT
public SystemWatchdogManager(android.content.Context context)
SystemWatchdogManager
using the given application context.
The SystemWatchdogManager
allows your application to interact
with the system watchdog service.
context
- Android application context.java.lang.NullPointerException
- If context == null
.public long init(long timeout)
This method can be called only once per device boot. Once system watchdog service is started, it can't be stopped. Any Android application can refresh the system watchdog service. If the system watchdog service is not refreshed within the configured timeout after initialization, the system will reboot.
If this method is called again when the system watchdog service is
already running, an UnsupportedOperationException
will be thrown.
Note the possibility that system driver may not be able to set the
desired timeout. The real timeout value that is set is returned in this
method after initialization. You can also use getTimeout()
to
read the real driver assigned watchdog timeout any time after
initialization.
timeout
- System watchdog service timeout in milliseconds (must be
greater than MINIMUM_WATCHDOG_TIMEOUT
).java.lang.IllegalArgumentException
- If timeout < MINIMUM_WATCHDOG_TIMEOUT
.java.lang.UnsupportedOperationException
- If system watchdog service has been
already initialized.MINIMUM_WATCHDOG_TIMEOUT
,
getTimeout()
,
isRunning()
,
refresh()
public long getTimeout()
This method can be called only after the system watchdog service is
initialized, otherwise an UnsupportedOperationException
will be
thrown.
java.lang.UnsupportedOperationException
- If the system watchdog service has
not been initialized.init(long)
,
isRunning()
,
refresh()
public boolean isRunning()
true
if the system watchdog service has been initialized,
false
otherwise.init(long)
,
getTimeout()
,
refresh()
public void refresh()
java.lang.UnsupportedOperationException
- If the system watchdog service has
not been initialized.init(long)
,
isRunning()
,
getTimeout()