Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -27142,6 +27142,7 @@ package android.net { method public void bindSocket(java.net.Socket) throws java.io.IOException; method public void bindSocket(java.io.FileDescriptor) throws java.io.IOException; method public int describeContents(); method public static android.net.Network fromNetworkHandle(long); method public java.net.InetAddress[] getAllByName(java.lang.String) throws java.net.UnknownHostException; method public java.net.InetAddress getByName(java.lang.String) throws java.net.UnknownHostException; method public long getNetworkHandle(); core/java/android/net/Network.java +25 −5 Original line number Diff line number Diff line Loading @@ -77,6 +77,11 @@ public class Network implements Parcelable { httpKeepAlive ? Integer.parseInt(System.getProperty("http.maxConnections", "5")) : 0; private static final long httpKeepAliveDurationMs = Long.parseLong(System.getProperty("http.keepAliveDuration", "300000")); // 5 minutes. // Value used to obfuscate network handle longs. // The HANDLE_MAGIC value MUST be kept in sync with the corresponding // value in the native/android/net.c NDK implementation. private static final long HANDLE_MAGIC = 0xcafed00dL; private static final int HANDLE_MAGIC_SIZE = 32; /** * @hide Loading Loading @@ -334,6 +339,25 @@ public class Network implements Parcelable { } } /** * Returns a {@link Network} object given a handle returned from {@link #getNetworkHandle}. * * @param networkHandle a handle returned from {@link #getNetworkHandle}. * @return A {@link Network} object derived from {@code networkHandle}. */ public static Network fromNetworkHandle(long networkHandle) { if (networkHandle == 0) { throw new IllegalArgumentException( "Network.fromNetworkHandle refusing to instantiate NETID_UNSET Network."); } if ((networkHandle & ((1L << HANDLE_MAGIC_SIZE) - 1)) != HANDLE_MAGIC || networkHandle < 0) { throw new IllegalArgumentException( "Value passed to fromNetworkHandle() is not a network handle."); } return new Network((int) (networkHandle >> HANDLE_MAGIC_SIZE)); } /** * Returns a handle representing this {@code Network}, for use with the NDK API. */ Loading @@ -356,14 +380,10 @@ public class Network implements Parcelable { // At some future date it may be desirable to realign the handle with // Multiple Provisioning Domains API recommendations, as made by the // IETF mif working group. // // The handleMagic value MUST be kept in sync with the corresponding // value in the native/android/net.c NDK implementation. if (netId == 0) { return 0L; // make this zero condition obvious for debugging } final long handleMagic = 0xcafed00dL; return (((long) netId) << 32) | handleMagic; return (((long) netId) << HANDLE_MAGIC_SIZE) | HANDLE_MAGIC; } // implement the Parcelable interface Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -27142,6 +27142,7 @@ package android.net { method public void bindSocket(java.net.Socket) throws java.io.IOException; method public void bindSocket(java.io.FileDescriptor) throws java.io.IOException; method public int describeContents(); method public static android.net.Network fromNetworkHandle(long); method public java.net.InetAddress[] getAllByName(java.lang.String) throws java.net.UnknownHostException; method public java.net.InetAddress getByName(java.lang.String) throws java.net.UnknownHostException; method public long getNetworkHandle();
core/java/android/net/Network.java +25 −5 Original line number Diff line number Diff line Loading @@ -77,6 +77,11 @@ public class Network implements Parcelable { httpKeepAlive ? Integer.parseInt(System.getProperty("http.maxConnections", "5")) : 0; private static final long httpKeepAliveDurationMs = Long.parseLong(System.getProperty("http.keepAliveDuration", "300000")); // 5 minutes. // Value used to obfuscate network handle longs. // The HANDLE_MAGIC value MUST be kept in sync with the corresponding // value in the native/android/net.c NDK implementation. private static final long HANDLE_MAGIC = 0xcafed00dL; private static final int HANDLE_MAGIC_SIZE = 32; /** * @hide Loading Loading @@ -334,6 +339,25 @@ public class Network implements Parcelable { } } /** * Returns a {@link Network} object given a handle returned from {@link #getNetworkHandle}. * * @param networkHandle a handle returned from {@link #getNetworkHandle}. * @return A {@link Network} object derived from {@code networkHandle}. */ public static Network fromNetworkHandle(long networkHandle) { if (networkHandle == 0) { throw new IllegalArgumentException( "Network.fromNetworkHandle refusing to instantiate NETID_UNSET Network."); } if ((networkHandle & ((1L << HANDLE_MAGIC_SIZE) - 1)) != HANDLE_MAGIC || networkHandle < 0) { throw new IllegalArgumentException( "Value passed to fromNetworkHandle() is not a network handle."); } return new Network((int) (networkHandle >> HANDLE_MAGIC_SIZE)); } /** * Returns a handle representing this {@code Network}, for use with the NDK API. */ Loading @@ -356,14 +380,10 @@ public class Network implements Parcelable { // At some future date it may be desirable to realign the handle with // Multiple Provisioning Domains API recommendations, as made by the // IETF mif working group. // // The handleMagic value MUST be kept in sync with the corresponding // value in the native/android/net.c NDK implementation. if (netId == 0) { return 0L; // make this zero condition obvious for debugging } final long handleMagic = 0xcafed00dL; return (((long) netId) << 32) | handleMagic; return (((long) netId) << HANDLE_MAGIC_SIZE) | HANDLE_MAGIC; } // implement the Parcelable interface Loading