diff options
author | Erik Kline <ek@google.com> | 2015-03-05 15:13:37 +0900 |
---|---|---|
committer | Erik Kline <ek@google.com> | 2015-04-15 15:52:31 +0900 |
commit | 104b0f1353934fc5caa045441d22becf0f90dac2 (patch) | |
tree | df764e95116e8a6d1d1c402125633e06784971b3 /core/java/android/net | |
parent | de93575d86d57011493c820e24558bce586a41e1 (diff) | |
download | frameworks_base-104b0f1353934fc5caa045441d22becf0f90dac2.zip frameworks_base-104b0f1353934fc5caa045441d22becf0f90dac2.tar.gz frameworks_base-104b0f1353934fc5caa045441d22becf0f90dac2.tar.bz2 |
multinetwork API: native implementation
Bug: 19537384
Change-Id: I04f4a7de2b1e583989b67a853df6ab50289c2185
Diffstat (limited to 'core/java/android/net')
-rw-r--r-- | core/java/android/net/Network.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/java/android/net/Network.java b/core/java/android/net/Network.java index 39db41d..4ce9e68 100644 --- a/core/java/android/net/Network.java +++ b/core/java/android/net/Network.java @@ -340,6 +340,35 @@ public class Network implements Parcelable { } } + /** + * Returns a handle representing this {@code Network}, for use with the NDK API. + */ + public long getNetworkHandle() { + // The network handle is explicitly not the same as the netId. + // + // The netId is an implementation detail which might be changed in the + // future, or which alone (i.e. in the absence of some additional + // context) might not be sufficient to fully identify a Network. + // + // As such, the intention is to prevent accidental misuse of the API + // that might result if a developer assumed that handles and netIds + // were identical and passing a netId to a call expecting a handle + // "just worked". Such accidental misuse, if widely deployed, might + // prevent future changes to the semantics of the netId field or + // inhibit the expansion of state required for Network objects. + // + // This extra layer of indirection might be seen as paranoia, and might + // never end up being necessary, but the added complexity is trivial. + // 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 HANDLE_MAGIC value MUST be kept in sync with the corresponding + // value in the native/android/net.c NDK implementation. + final long HANDLE_MAGIC = 0xfacade; + return (((long) netId) << 32) | HANDLE_MAGIC; + } + // implement the Parcelable interface public int describeContents() { return 0; |