org.fourthline.cling.android
Class AndroidSwitchableRouter
java.lang.Object
org.fourthline.cling.transport.SwitchableRouterImpl
org.fourthline.cling.android.AndroidSwitchableRouter
- All Implemented Interfaces:
- Router, SwitchableRouter
public class AndroidSwitchableRouter
- extends SwitchableRouterImpl
Monitors all network connectivity changes, switching the router accordingly.
- Author:
- Michael Pujos, Christian Bauer
Field Summary |
protected android.content.BroadcastReceiver |
broadcastReceiver
|
protected android.net.wifi.WifiManager.MulticastLock |
multicastLock
|
protected android.net.NetworkInfo |
networkInfo
|
protected android.net.wifi.WifiManager.WifiLock |
wifiLock
|
Methods inherited from class org.fourthline.cling.transport.SwitchableRouterImpl |
broadcast, disable, enable, getActiveStreamServers, getConfiguration, getNetworkAddressFactory, getProtocolFactory, handleStartFailure, isEnabled, lock, lock, received, received, send, send, unlock |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
multicastLock
protected android.net.wifi.WifiManager.MulticastLock multicastLock
wifiLock
protected android.net.wifi.WifiManager.WifiLock wifiLock
networkInfo
protected android.net.NetworkInfo networkInfo
broadcastReceiver
protected android.content.BroadcastReceiver broadcastReceiver
AndroidSwitchableRouter
public AndroidSwitchableRouter(UpnpServiceConfiguration configuration,
ProtocolFactory protocolFactory,
android.content.Context context)
throws InitializationException
- Throws:
InitializationException
getLockTimeoutMillis
protected int getLockTimeoutMillis()
- Overrides:
getLockTimeoutMillis
in class SwitchableRouterImpl
- Returns:
- Defaults to 6 seconds, should be longer than the HTTP client
request connection/data read timeouts. Should be longer than
it takes the router to be started/shutdown.
shutdown
public void shutdown()
- Description copied from interface:
Router
- Unbinds all sockets and stops all listening threads for datagrams and streams.
- Specified by:
shutdown
in interface Router
- Overrides:
shutdown
in class SwitchableRouterImpl
enable
public boolean enable()
throws SwitchableRouterImpl.RouterLockAcquisitionException
- Specified by:
enable
in interface SwitchableRouter
- Overrides:
enable
in class SwitchableRouterImpl
- Returns:
true
if the router was enabled. false
if it's already running.
- Throws:
SwitchableRouterImpl.RouterLockAcquisitionException
disable
public boolean disable()
throws SwitchableRouterImpl.RouterLockAcquisitionException
- Specified by:
disable
in interface SwitchableRouter
- Overrides:
disable
in class SwitchableRouterImpl
- Returns:
true
if the router was disabled. false
if it wasn't running.
- Throws:
SwitchableRouterImpl.RouterLockAcquisitionException
getNetworkInfo
public android.net.NetworkInfo getNetworkInfo()
isMobile
public boolean isMobile()
isWifi
public boolean isWifi()
isEthernet
public boolean isEthernet()
enableWiFi
public boolean enableWiFi()
setWiFiMulticastLock
protected void setWiFiMulticastLock(boolean enable)
setWifiLock
protected void setWifiLock(boolean enable)
createWiFiLock
protected android.net.wifi.WifiManager.WifiLock createWiFiLock()
onNetworkTypeChange
protected void onNetworkTypeChange(android.net.NetworkInfo oldNetwork,
android.net.NetworkInfo newNetwork)
- Can be overriden by subclasses to do additional work.
- Parameters:
oldNetwork
- null
when first called by constructor.
Copyright © 2013 4th Line GmbH, Switzerland. All Rights Reserved.