WifiLockManager


@UnstableApi
public final 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, Looper wifiLockLooper, Clock clock)

Creates the wifi lock manager.

Public methods

void
setEnabled(boolean enabled)

Sets whether to enable the usage of a WifiLock.

void
setStayAwake(boolean stayAwake)

Sets whether to acquire or release the WifiLock.

Public constructors

WifiLockManager

public WifiLockManager(Context context, Looper wifiLockLooper, Clock clock)

Creates the wifi lock manager.

Parameters
Context context

A Context

Looper wifiLockLooper

A background Looper to call wifi lock system calls on.

Clock clock

The Clock to schedule handler messages.

Public methods

setEnabled

public void setEnabled(boolean enabled)

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
boolean enabled

True if the player should handle a WifiLock.

setStayAwake

public void setStayAwake(boolean stayAwake)

Sets whether to acquire or release the WifiLock.

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

Parameters
boolean stayAwake

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