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:32:08 +0900 |
commit | 25f3b7bb2d05e4a020e7d82ada1543d2cdc75fbb (patch) | |
tree | 726c4e5c76261b4df5be07a3fd5564e20a206869 /core/java/android/net | |
parent | 0e08a225dab277d367b6665b933869dc7587090e (diff) | |
download | frameworks_base-25f3b7bb2d05e4a020e7d82ada1543d2cdc75fbb.zip frameworks_base-25f3b7bb2d05e4a020e7d82ada1543d2cdc75fbb.tar.gz frameworks_base-25f3b7bb2d05e4a020e7d82ada1543d2cdc75fbb.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 65d325a1..67ecb5d 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; |