Class ShadowNetwork


  • @Implements(value=android.net.Network.class,
                minSdk=21)
    public class ShadowNetwork
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ShadowNetwork()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void bindSocket​(java.io.FileDescriptor fd)
      Simulates a socket bind.
      protected void bindSocket​(java.net.DatagramSocket socket)
      Simulates a socket bind.
      protected void bindSocket​(java.net.Socket socket)
      Simulates a socket bind.
      int boundSocketCount()
      Returns the total number of sockets bound to this network interface.
      int getNetId()
      Allows to get the stored netId.
      boolean isSocketBound​(java.io.FileDescriptor fd)
      Checks if the fileDescriptor was previously bound to this network.
      boolean isSocketBound​(java.net.DatagramSocket socket)
      Checks if the datagramSocket was previously bound to this network.
      boolean isSocketBound​(java.net.Socket socket)
      Checks if the socket was previously bound to this network.
      static android.net.Network newInstance​(int netId)
      Creates new instance of Network, because its constructor is hidden.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowNetwork

        public ShadowNetwork()
    • Method Detail

      • newInstance

        public static android.net.Network newInstance​(int netId)
        Creates new instance of Network, because its constructor is hidden.
        Parameters:
        netId - The netId.
        Returns:
        The Network instance.
      • isSocketBound

        public boolean isSocketBound​(java.net.Socket socket)
        Checks if the socket was previously bound to this network.
      • isSocketBound

        public boolean isSocketBound​(java.net.DatagramSocket socket)
        Checks if the datagramSocket was previously bound to this network.
      • isSocketBound

        public boolean isSocketBound​(java.io.FileDescriptor fd)
        Checks if the fileDescriptor was previously bound to this network.
      • boundSocketCount

        public int boundSocketCount()
        Returns the total number of sockets bound to this network interface.
      • bindSocket

        @Implementation(minSdk=22)
        protected void bindSocket​(java.net.DatagramSocket socket)
        Simulates a socket bind. isSocketBound can be called to verify that the socket was bound to this network interface, and boundSocketCount() will increment for any unique socket.
      • bindSocket

        @Implementation
        protected void bindSocket​(java.net.Socket socket)
        Simulates a socket bind. isSocketBound can be called to verify that the socket was bound to this network interface, and boundSocketCount() will increment for any unique socket.
      • bindSocket

        @Implementation(minSdk=23)
        protected void bindSocket​(java.io.FileDescriptor fd)
        Simulates a socket bind. isSocketBound can be called to verify that the fd was bound to this network interface, and boundSocketCount() will increment for any unique socket.
      • getNetId

        public int getNetId()
        Allows to get the stored netId.
        Returns:
        The netId.