WifiLockManager


@UnstableApi
class WifiLockManager


Utility class to handle a WifiLock

The handling of wifi locks requires the WAKE_LOCK permission.

The class must be used from a single thread. This can be the main thread as all blocking operations are internally handled on the background Looper thread provided in the constructor.

Summary

Public constructors

WifiLockManager(context: Context!, wifiLockLooper: Looper!, clock: Clock!)

Creates the wifi lock manager.

Public functions

Unit
setEnabled(enabled: Boolean)

Sets whether to enable the usage of a WifiLock.

Unit
setStayAwake(stayAwake: Boolean)

Sets whether to acquire or release the WifiLock.

Public constructors

WifiLockManager

WifiLockManager(context: Context!, wifiLockLooper: Looper!, clock: Clock!)

Creates the wifi lock manager.

Parameters
context: Context!

A Context

wifiLockLooper: Looper!

A background Looper to call wifi lock system calls on.

clock: Clock!

The Clock to schedule handler messages.

Public functions

setEnabled

fun setEnabled(enabled: Boolean): Unit

Sets whether to enable the usage of a WifiLock.

By default, wifi lock handling is not enabled. Enabling will acquire the wifi lock if necessary. Disabling will release the wifi lock if held.

Enabling WifiLock requires the WAKE_LOCK.

Parameters
enabled: Boolean

True if the player should handle a WifiLock.

setStayAwake

fun setStayAwake(stayAwake: Boolean): Unit

Sets whether to acquire or release the WifiLock.

The wifi lock will not be acquired unless handling has been enabled through setEnabled.

Parameters
stayAwake: Boolean

True if the player should acquire the WifiLock. False if it should release.