org.teleal.cling.android
Class AndroidWifiSwitchableRouter

java.lang.Object
  extended by org.teleal.cling.transport.SwitchableRouterImpl
      extended by org.teleal.cling.android.AndroidWifiSwitchableRouter
All Implemented Interfaces:
Router, SwitchableRouter

public class AndroidWifiSwitchableRouter
extends SwitchableRouterImpl

Switches the network transport layer on/off by monitoring WiFi connectivity.

This implementation listens to connectivity changes in an Android environment. Register the getBroadcastReceiver() instance with intent android.net.conn.CONNECTIVITY_CHANGE.

Author:
Christian Bauer

Nested Class Summary
 
Nested classes/interfaces inherited from class org.teleal.cling.transport.SwitchableRouterImpl
SwitchableRouterImpl.RouterLockAcquisitionException
 
Field Summary
 
Fields inherited from class org.teleal.cling.transport.SwitchableRouterImpl
readLock, routerLock, writeLock
 
Constructor Summary
AndroidWifiSwitchableRouter(UpnpServiceConfiguration configuration, ProtocolFactory protocolFactory, android.net.wifi.WifiManager wifiManager, android.net.ConnectivityManager connectivityManager)
           
 
Method Summary
 boolean disable()
           
 boolean enable()
           
 android.content.BroadcastReceiver getBroadcastReceiver()
           
protected  android.net.ConnectivityManager getConnectivityManager()
           
protected  int getLockTimeoutMillis()
           
protected  android.net.wifi.WifiManager getWifiManager()
           
 void handleStartFailure(InitializationException ex)
          Called by the SwitchableRouter.enable() method before it returns.
 
Methods inherited from class org.teleal.cling.transport.SwitchableRouterImpl
broadcast, getActiveStreamServers, getConfiguration, getNetworkAddressFactory, getProtocolFactory, isEnabled, lock, lock, received, received, send, send, shutdown, unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidWifiSwitchableRouter

public AndroidWifiSwitchableRouter(UpnpServiceConfiguration configuration,
                                   ProtocolFactory protocolFactory,
                                   android.net.wifi.WifiManager wifiManager,
                                   android.net.ConnectivityManager connectivityManager)
Method Detail

getBroadcastReceiver

public android.content.BroadcastReceiver getBroadcastReceiver()

getWifiManager

protected android.net.wifi.WifiManager getWifiManager()

getConnectivityManager

protected android.net.ConnectivityManager getConnectivityManager()

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

handleStartFailure

public void handleStartFailure(InitializationException ex)
Description copied from interface: SwitchableRouter
Called by the SwitchableRouter.enable() method before it returns.

Specified by:
handleStartFailure in interface SwitchableRouter
Overrides:
handleStartFailure in class SwitchableRouterImpl
Parameters:
ex - The cause of the failure.

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

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.


Copyright © 2011 Teleal GmbH, Switzerland. All Rights Reserved.