diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2014-04-08 17:34:00 -0700 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2014-05-12 16:52:56 -0700 |
commit | f9cb86aebe9647e0fe0137fc198ba16c017445c6 (patch) | |
tree | 5f7d1e0ab2f48cb39092881266f21f7e11ea33b3 | |
parent | 6681e32fff77174b1b93557c08d1fd00375422c0 (diff) | |
download | frameworks_base-f9cb86aebe9647e0fe0137fc198ba16c017445c6.zip frameworks_base-f9cb86aebe9647e0fe0137fc198ba16c017445c6.tar.gz frameworks_base-f9cb86aebe9647e0fe0137fc198ba16c017445c6.tar.bz2 |
Replace LinkCapabilities with NetworkCapabilities
Also remove unused LinkSocket and LinkSocketNotifier.
bug:13885501
Change-Id: Id426e31b201fa4f29109b5fea485d8efb34519d3
19 files changed, 47 insertions, 886 deletions
diff --git a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java index a0b603e..f0c8299 100644 --- a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java +++ b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java @@ -20,7 +20,7 @@ import android.net.BaseNetworkStateTracker; import android.content.Context; import android.net.ConnectivityManager; import android.net.DhcpResults; -import android.net.LinkCapabilities; +import android.net.NetworkCapabilities; import android.net.LinkProperties; import android.net.NetworkInfo; import android.net.NetworkInfo.DetailedState; @@ -75,7 +75,7 @@ public class BluetoothTetheringDataTracker extends BaseNetworkStateTracker { private BluetoothTetheringDataTracker() { mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_BLUETOOTH, 0, NETWORKTYPE, ""); mLinkProperties = new LinkProperties(); - mLinkCapabilities = new LinkCapabilities(); + mNetworkCapabilities = new NetworkCapabilities(); mNetworkInfo.setIsAvailable(false); setTeardownRequested(false); @@ -242,16 +242,6 @@ public class BluetoothTetheringDataTracker extends BaseNetworkStateTracker { } } - /** - * A capability is an Integer/String pair, the capabilities - * are defined in the class LinkSocket#Key. - * - * @return a copy of this connections capabilities, may be empty but never null. - */ - public LinkCapabilities getLinkCapabilities() { - return new LinkCapabilities(mLinkCapabilities); - } - /** * Fetch default gateway address for the network */ diff --git a/core/java/android/net/BaseNetworkStateTracker.java b/core/java/android/net/BaseNetworkStateTracker.java index 862d59e..79db389 100644 --- a/core/java/android/net/BaseNetworkStateTracker.java +++ b/core/java/android/net/BaseNetworkStateTracker.java @@ -44,7 +44,7 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker { protected NetworkInfo mNetworkInfo; protected LinkProperties mLinkProperties; - protected LinkCapabilities mLinkCapabilities; + protected NetworkCapabilities mNetworkCapabilities; protected Network mNetwork = new Network(ConnectivityManager.INVALID_NET_ID); private AtomicBoolean mTeardownRequested = new AtomicBoolean(false); @@ -55,7 +55,7 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker { mNetworkInfo = new NetworkInfo( networkType, -1, ConnectivityManager.getNetworkTypeName(networkType), null); mLinkProperties = new LinkProperties(); - mLinkCapabilities = new LinkCapabilities(); + mNetworkCapabilities = new NetworkCapabilities(); } protected BaseNetworkStateTracker() { @@ -99,8 +99,8 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker { } @Override - public LinkCapabilities getLinkCapabilities() { - return new LinkCapabilities(mLinkCapabilities); + public NetworkCapabilities getNetworkCapabilities() { + return new NetworkCapabilities(mNetworkCapabilities); } @Override diff --git a/core/java/android/net/DummyDataStateTracker.java b/core/java/android/net/DummyDataStateTracker.java index a5d059e..eff9f9f 100644 --- a/core/java/android/net/DummyDataStateTracker.java +++ b/core/java/android/net/DummyDataStateTracker.java @@ -190,13 +190,6 @@ public class DummyDataStateTracker extends BaseNetworkStateTracker { return new LinkProperties(mLinkProperties); } - /** - * @see android.net.NetworkStateTracker#getLinkCapabilities() - */ - public LinkCapabilities getLinkCapabilities() { - return new LinkCapabilities(mLinkCapabilities); - } - public void setDependencyMet(boolean met) { // not supported on this network } diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java index 10b5d0b..c1afc9b 100644 --- a/core/java/android/net/EthernetDataTracker.java +++ b/core/java/android/net/EthernetDataTracker.java @@ -103,7 +103,7 @@ public class EthernetDataTracker extends BaseNetworkStateTracker { private EthernetDataTracker() { mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_ETHERNET, 0, NETWORKTYPE, ""); mLinkProperties = new LinkProperties(); - mLinkCapabilities = new LinkCapabilities(); + mNetworkCapabilities = new NetworkCapabilities(); } private void interfaceUpdated() { @@ -372,16 +372,6 @@ public class EthernetDataTracker extends BaseNetworkStateTracker { return new LinkProperties(mLinkProperties); } - /** - * A capability is an Integer/String pair, the capabilities - * are defined in the class LinkSocket#Key. - * - * @return a copy of this connections capabilities, may be empty but never null. - */ - public LinkCapabilities getLinkCapabilities() { - return new LinkCapabilities(mLinkCapabilities); - } - /** * Fetch default gateway address for the network */ diff --git a/core/java/android/net/LinkCapabilities.aidl b/core/java/android/net/LinkCapabilities.aidl deleted file mode 100644 index df72599..0000000 --- a/core/java/android/net/LinkCapabilities.aidl +++ /dev/null @@ -1,21 +0,0 @@ -/* -** -** Copyright (C) 2010 The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -package android.net; - -parcelable LinkCapabilities; - diff --git a/core/java/android/net/LinkCapabilities.java b/core/java/android/net/LinkCapabilities.java deleted file mode 100644 index fb444ea..0000000 --- a/core/java/android/net/LinkCapabilities.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.net; - -import android.os.Parcelable; -import android.os.Parcel; -import android.util.Log; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -/** - * A class representing the capabilities of a link - * - * @hide - */ -public class LinkCapabilities implements Parcelable { - private static final String TAG = "LinkCapabilities"; - private static final boolean DBG = false; - - /** The Map of Keys to Values */ - private HashMap<Integer, String> mCapabilities; - - - /** - * The set of keys defined for a links capabilities. - * - * Keys starting with RW are read + write, i.e. the application - * can request for a certain requirement corresponding to that key. - * Keys starting with RO are read only, i.e. the the application - * can read the value of that key from the socket but cannot request - * a corresponding requirement. - * - * TODO: Provide a documentation technique for concisely and precisely - * define the syntax for each value string associated with a key. - */ - public static final class Key { - /** No constructor */ - private Key() {} - - /** - * An integer representing the network type. - * @see ConnectivityManager - */ - public final static int RO_NETWORK_TYPE = 1; - - /** - * Desired minimum forward link (download) bandwidth for the - * in kilobits per second (kbps). Values should be strings such - * "50", "100", "1500", etc. - */ - public final static int RW_DESIRED_FWD_BW = 2; - - /** - * Required minimum forward link (download) bandwidth, in - * per second (kbps), below which the socket cannot function. - * Values should be strings such as "50", "100", "1500", etc. - */ - public final static int RW_REQUIRED_FWD_BW = 3; - - /** - * Available forward link (download) bandwidth for the socket. - * This value is in kilobits per second (kbps). - * Values will be strings such as "50", "100", "1500", etc. - */ - public final static int RO_AVAILABLE_FWD_BW = 4; - - /** - * Desired minimum reverse link (upload) bandwidth for the socket - * in kilobits per second (kbps). - * Values should be strings such as "50", "100", "1500", etc. - * <p> - * This key is set via the needs map. - */ - public final static int RW_DESIRED_REV_BW = 5; - - /** - * Required minimum reverse link (upload) bandwidth, in kilobits - * per second (kbps), below which the socket cannot function. - * If a rate is not specified, the default rate of kbps will be - * Values should be strings such as "50", "100", "1500", etc. - */ - public final static int RW_REQUIRED_REV_BW = 6; - - /** - * Available reverse link (upload) bandwidth for the socket. - * This value is in kilobits per second (kbps). - * Values will be strings such as "50", "100", "1500", etc. - */ - public final static int RO_AVAILABLE_REV_BW = 7; - - /** - * Maximum latency for the socket, in milliseconds, above which - * socket cannot function. - * Values should be strings such as "50", "300", "500", etc. - */ - public final static int RW_MAX_ALLOWED_LATENCY = 8; - - /** - * Interface that the socket is bound to. This can be a virtual - * interface (e.g. VPN or Mobile IP) or a physical interface - * (e.g. wlan0 or rmnet0). - * Values will be strings such as "wlan0", "rmnet0" - */ - public final static int RO_BOUND_INTERFACE = 9; - - /** - * Physical interface that the socket is routed on. - * This can be different from BOUND_INTERFACE in cases such as - * VPN or Mobile IP. The physical interface may change over time - * if seamless mobility is supported. - * Values will be strings such as "wlan0", "rmnet0" - */ - public final static int RO_PHYSICAL_INTERFACE = 10; - } - - /** - * Role informs the LinkSocket about the data usage patterns of your - * application. - * <P> - * {@code Role.DEFAULT} is the default role, and is used whenever - * a role isn't set. - */ - public static final class Role { - /** No constructor */ - private Role() {} - - // examples only, discuss which roles should be defined, and then - // code these to match - - /** Default Role */ - public static final String DEFAULT = "default"; - /** Bulk down load */ - public static final String BULK_DOWNLOAD = "bulk.download"; - /** Bulk upload */ - public static final String BULK_UPLOAD = "bulk.upload"; - - /** VoIP Application at 24kbps */ - public static final String VOIP_24KBPS = "voip.24k"; - /** VoIP Application at 32kbps */ - public static final String VOIP_32KBPS = "voip.32k"; - - /** Video Streaming at 480p */ - public static final String VIDEO_STREAMING_480P = "video.streaming.480p"; - /** Video Streaming at 720p */ - public static final String VIDEO_STREAMING_720I = "video.streaming.720i"; - - /** Video Chat Application at 360p */ - public static final String VIDEO_CHAT_360P = "video.chat.360p"; - /** Video Chat Application at 480p */ - public static final String VIDEO_CHAT_480P = "video.chat.480i"; - } - - /** - * Constructor - */ - public LinkCapabilities() { - mCapabilities = new HashMap<Integer, String>(); - } - - /** - * Copy constructor. - * - * @param source - */ - public LinkCapabilities(LinkCapabilities source) { - if (source != null) { - mCapabilities = new HashMap<Integer, String>(source.mCapabilities); - } else { - mCapabilities = new HashMap<Integer, String>(); - } - } - - /** - * Create the {@code LinkCapabilities} with values depending on role type. - * @param applicationRole a {@code LinkSocket.Role} - * @return the {@code LinkCapabilities} associated with the applicationRole, empty if none - */ - public static LinkCapabilities createNeedsMap(String applicationRole) { - if (DBG) log("createNeededCapabilities(applicationRole) EX"); - return new LinkCapabilities(); - } - - /** - * Remove all capabilities - */ - public void clear() { - mCapabilities.clear(); - } - - /** - * Returns whether this map is empty. - */ - public boolean isEmpty() { - return mCapabilities.isEmpty(); - } - - /** - * Returns the number of elements in this map. - * - * @return the number of elements in this map. - */ - public int size() { - return mCapabilities.size(); - } - - /** - * Given the key return the capability string - * - * @param key - * @return the capability string - */ - public String get(int key) { - return mCapabilities.get(key); - } - - /** - * Store the key/value capability pair - * - * @param key - * @param value - */ - public void put(int key, String value) { - mCapabilities.put(key, value); - } - - /** - * Returns whether this map contains the specified key. - * - * @param key to search for. - * @return {@code true} if this map contains the specified key, - * {@code false} otherwise. - */ - public boolean containsKey(int key) { - return mCapabilities.containsKey(key); - } - - /** - * Returns whether this map contains the specified value. - * - * @param value to search for. - * @return {@code true} if this map contains the specified value, - * {@code false} otherwise. - */ - public boolean containsValue(String value) { - return mCapabilities.containsValue(value); - } - - /** - * Returns a set containing all of the mappings in this map. Each mapping is - * an instance of {@link Map.Entry}. As the set is backed by this map, - * changes in one will be reflected in the other. - * - * @return a set of the mappings. - */ - public Set<Entry<Integer, String>> entrySet() { - return mCapabilities.entrySet(); - } - - /** - * @return the set of the keys. - */ - public Set<Integer> keySet() { - return mCapabilities.keySet(); - } - - /** - * @return the set of values - */ - public Collection<String> values() { - return mCapabilities.values(); - } - - /** - * Implement the Parcelable interface - * @hide - */ - public int describeContents() { - return 0; - } - - /** - * Convert to string for debugging - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("{"); - boolean firstTime = true; - for (Entry<Integer, String> entry : mCapabilities.entrySet()) { - if (firstTime) { - firstTime = false; - } else { - sb.append(","); - } - sb.append(entry.getKey()); - sb.append(":\""); - sb.append(entry.getValue()); - sb.append("\""); - } - sb.append("}"); - return sb.toString(); - } - - /** - * Implement the Parcelable interface. - * @hide - */ - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mCapabilities.size()); - for (Entry<Integer, String> entry : mCapabilities.entrySet()) { - dest.writeInt(entry.getKey().intValue()); - dest.writeString(entry.getValue()); - } - } - - /** - * Implement the Parcelable interface. - * @hide - */ - public static final Creator<LinkCapabilities> CREATOR = - new Creator<LinkCapabilities>() { - public LinkCapabilities createFromParcel(Parcel in) { - LinkCapabilities capabilities = new LinkCapabilities(); - int size = in.readInt(); - while (size-- != 0) { - int key = in.readInt(); - String value = in.readString(); - capabilities.mCapabilities.put(key, value); - } - return capabilities; - } - - public LinkCapabilities[] newArray(int size) { - return new LinkCapabilities[size]; - } - }; - - /** - * Debug logging - */ - protected static void log(String s) { - Log.d(TAG, s); - } -} diff --git a/core/java/android/net/LinkSocket.java b/core/java/android/net/LinkSocket.java deleted file mode 100644 index 5aa6451..0000000 --- a/core/java/android/net/LinkSocket.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.net; - -import android.net.LinkCapabilities; -import android.net.LinkProperties; -import android.net.LinkSocketNotifier; - -import android.util.Log; - -import java.io.IOException; -import java.net.Socket; -import java.net.SocketAddress; -import java.net.SocketTimeoutException; -import java.net.UnknownHostException; -import java.util.HashSet; -import java.util.Set; - -/** @hide */ -public class LinkSocket extends Socket { - private final static String TAG = "LinkSocket"; - private final static boolean DBG = true; - - /** - * Default constructor - */ - public LinkSocket() { - if (DBG) log("LinkSocket() EX"); - } - - /** - * Creates a new unconnected socket. - * @param notifier a reference to a class that implements {@code LinkSocketNotifier} - */ - public LinkSocket(LinkSocketNotifier notifier) { - if (DBG) log("LinkSocket(notifier) EX"); - } - - /** - * Creates a new unconnected socket usign the given proxy type. - * @param notifier a reference to a class that implements {@code LinkSocketNotifier} - * @param proxy the specified proxy for this socket - * @throws IllegalArgumentException if the argument proxy is null or of an invalid type. - * @throws SecurityException if a security manager exists and it denies the permission - * to connect to the given proxy. - */ - public LinkSocket(LinkSocketNotifier notifier, Proxy proxy) { - if (DBG) log("LinkSocket(notifier, proxy) EX"); - } - - /** - * @return the {@code LinkProperties} for the socket - */ - public LinkProperties getLinkProperties() { - if (DBG) log("LinkProperties() EX"); - return new LinkProperties(); - } - - /** - * Set the {@code LinkCapabilies} needed for this socket. If the socket is already connected - * or is a duplicate socket the request is ignored and {@code false} will - * be returned. A needs map can be created via the {@code createNeedsMap} static - * method. - * @param needs the needs of the socket - * @return {@code true} if needs are successfully set, {@code false} otherwise - */ - public boolean setNeededCapabilities(LinkCapabilities needs) { - if (DBG) log("setNeeds() EX"); - return false; - } - - /** - * @return the LinkCapabilites set by setNeededCapabilities, empty if none has been set - */ - public LinkCapabilities getNeededCapabilities() { - if (DBG) log("getNeeds() EX"); - return null; - } - - /** - * @return all of the {@code LinkCapabilities} of the link used by this socket - */ - public LinkCapabilities getCapabilities() { - if (DBG) log("getCapabilities() EX"); - return null; - } - - /** - * Returns this LinkSockets set of capabilities, filtered according to - * the given {@code Set}. Capabilities in the Set but not available from - * the link will not be reported in the results. Capabilities of the link - * but not listed in the Set will also not be reported in the results. - * @param capabilities {@code Set} of capabilities requested - * @return the filtered {@code LinkCapabilities} of this LinkSocket, may be empty - */ - public LinkCapabilities getCapabilities(Set<Integer> capabilities) { - if (DBG) log("getCapabilities(capabilities) EX"); - return new LinkCapabilities(); - } - - /** - * Provide the set of capabilities the application is interested in tracking - * for this LinkSocket. - * @param capabilities a {@code Set} of capabilities to track - */ - public void setTrackedCapabilities(Set<Integer> capabilities) { - if (DBG) log("setTrackedCapabilities(capabilities) EX"); - } - - /** - * @return the {@code LinkCapabilities} that are tracked, empty if none has been set. - */ - public Set<Integer> getTrackedCapabilities() { - if (DBG) log("getTrackedCapabilities(capabilities) EX"); - return new HashSet<Integer>(); - } - - /** - * Connects this socket to the given remote host address and port specified - * by dstName and dstPort. - * @param dstName the address of the remote host to connect to - * @param dstPort the port to connect to on the remote host - * @param timeout the timeout value in milliseconds or 0 for infinite timeout - * @throws UnknownHostException if the given dstName is invalid - * @throws IOException if the socket is already connected or an error occurs - * while connecting - * @throws SocketTimeoutException if the timeout fires - */ - public void connect(String dstName, int dstPort, int timeout) - throws UnknownHostException, IOException, SocketTimeoutException { - if (DBG) log("connect(dstName, dstPort, timeout) EX"); - } - - /** - * Connects this socket to the given remote host address and port specified - * by dstName and dstPort. - * @param dstName the address of the remote host to connect to - * @param dstPort the port to connect to on the remote host - * @throws UnknownHostException if the given dstName is invalid - * @throws IOException if the socket is already connected or an error occurs - * while connecting - */ - public void connect(String dstName, int dstPort) - throws UnknownHostException, IOException { - if (DBG) log("connect(dstName, dstPort, timeout) EX"); - } - - /** - * Connects this socket to the given remote host address and port specified - * by the SocketAddress with the specified timeout. - * @deprecated Use {@code connect(String dstName, int dstPort, int timeout)} - * instead. Using this method may result in reduced functionality. - * @param remoteAddr the address and port of the remote host to connect to - * @throws IllegalArgumentException if the given SocketAddress is invalid - * @throws IOException if the socket is already connected or an error occurs - * while connecting - * @throws SocketTimeoutException if the timeout expires - */ - @Override - @Deprecated - public void connect(SocketAddress remoteAddr, int timeout) - throws IOException, SocketTimeoutException { - if (DBG) log("connect(remoteAddr, timeout) EX DEPRECATED"); - } - - /** - * Connects this socket to the given remote host address and port specified - * by the SocketAddress. - * TODO add comment on all these that the network selection happens during connect - * and may take 30 seconds - * @deprecated Use {@code connect(String dstName, int dstPort)} - * Using this method may result in reduced functionality. - * @param remoteAddr the address and port of the remote host to connect to. - * @throws IllegalArgumentException if the SocketAddress is invalid or not supported. - * @throws IOException if the socket is already connected or an error occurs - * while connecting - */ - @Override - @Deprecated - public void connect(SocketAddress remoteAddr) throws IOException { - if (DBG) log("connect(remoteAddr) EX DEPRECATED"); - } - - /** - * Connect a duplicate socket socket to the same remote host address and port - * as the original with a timeout parameter. - * @param timeout the timeout value in milliseconds or 0 for infinite timeout - * @throws IOException if the socket is already connected or an error occurs - * while connecting - */ - public void connect(int timeout) throws IOException { - if (DBG) log("connect(timeout) EX"); - } - - /** - * Connect a duplicate socket socket to the same remote host address and port - * as the original. - * @throws IOException if the socket is already connected or an error occurs - * while connecting - */ - public void connect() throws IOException { - if (DBG) log("connect() EX"); - } - - /** - * Closes the socket. It is not possible to reconnect or rebind to this - * socket thereafter which means a new socket instance has to be created. - * @throws IOException if an error occurs while closing the socket - */ - @Override - public synchronized void close() throws IOException { - if (DBG) log("close() EX"); - } - - /** - * Request that a new LinkSocket be created using a different radio - * (such as WiFi or 3G) than the current LinkSocket. If a different - * radio is available a call back will be made via {@code onBetterLinkAvail}. - * If unable to find a better radio, application will be notified via - * {@code onNewLinkUnavailable} - * @see LinkSocketNotifier#onBetterLinkAvailable(LinkSocket, LinkSocket) - * @param linkRequestReason reason for requesting a new link. - */ - public void requestNewLink(LinkRequestReason linkRequestReason) { - if (DBG) log("requestNewLink(linkRequestReason) EX"); - } - - /** - * @deprecated LinkSocket will automatically pick the optimum interface - * to bind to - * @param localAddr the specific address and port on the local machine - * to bind to - * @throws IOException always as this method is deprecated for LinkSocket - */ - @Override - @Deprecated - public void bind(SocketAddress localAddr) throws UnsupportedOperationException { - if (DBG) log("bind(localAddr) EX throws IOException"); - throw new UnsupportedOperationException("bind is deprecated for LinkSocket"); - } - - /** - * Reason codes an application can specify when requesting for a new link. - * TODO: need better documentation - */ - public static final class LinkRequestReason { - /** No constructor */ - private LinkRequestReason() {} - - /** This link is working properly */ - public static final int LINK_PROBLEM_NONE = 0; - /** This link has an unknown issue */ - public static final int LINK_PROBLEM_UNKNOWN = 1; - } - - /** - * Debug logging - */ - protected static void log(String s) { - Log.d(TAG, s); - } -} diff --git a/core/java/android/net/LinkSocketNotifier.java b/core/java/android/net/LinkSocketNotifier.java deleted file mode 100644 index e2429d8..0000000 --- a/core/java/android/net/LinkSocketNotifier.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.net; - -/** - * Interface used to get feedback about a {@link android.net.LinkSocket}. Instance is optionally - * passed when a LinkSocket is constructed. Multiple LinkSockets may use the same notifier. - * @hide - */ -public interface LinkSocketNotifier { - /** - * This callback function will be called if a better link - * becomes available. - * TODO - this shouldn't be checked for all cases - what's the conditional - * flag? - * If the duplicate socket is accepted, the original will be marked invalid - * and additional use will throw exceptions. - * @param original the original LinkSocket - * @param duplicate the new LinkSocket that better meets the application - * requirements - * @return {@code true} if the application intends to use this link - * - * REM - * TODO - how agressive should we be? - * At a minimum CS tracks which LS have this turned on and tracks the requirements - * When a new link becomes available, automatically check if any of the LinkSockets - * will care. - * If found, grab a refcount on the link so it doesn't go away and send notification - * Optionally, periodically setup connection on available networks to check for better links - * Maybe pass this info into the LinkFactories so condition changes can be acted on more quickly - */ - public boolean onBetterLinkAvailable(LinkSocket original, LinkSocket duplicate); - - /** - * This callback function will be called when a LinkSocket no longer has - * an active link. - * @param socket the LinkSocket that lost its link - * - * REM - * NetworkStateTracker tells us it is disconnected - * CS checks the table for LS on that link - * CS calls each callback (need to work out p2p cross process callback) - */ - public void onLinkLost(LinkSocket socket); - - /** - * This callback function will be called when an application calls - * requestNewLink on a LinkSocket but the LinkSocket is unable to find - * a suitable new link. - * @param socket the LinkSocket for which a new link was not found - * TODO - why the diff between initial request (sync) and requestNewLink? - * - * REM - * CS process of trying to find a new link must track the LS that started it - * on failure, call callback - */ - public void onNewLinkUnavailable(LinkSocket socket); - - /** - * This callback function will be called when any of the notification-marked - * capabilities of the LinkSocket (e.g. upstream bandwidth) have changed. - * @param socket the linkSocet for which capabilities have changed - * @param changedCapabilities the set of capabilities that the application - * is interested in and have changed (with new values) - * - * REM - * Maybe pass the interesting capabilities into the Links. - * Get notified of every capability change - * check for LinkSockets on that Link that are interested in that Capability - call them - */ - public void onCapabilitiesChanged(LinkSocket socket, LinkCapabilities changedCapabilities); -} diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index 30b61c5..535bbe2 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -66,7 +66,6 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker { private Handler mTarget; private Context mContext; private LinkProperties mLinkProperties; - private LinkCapabilities mLinkCapabilities; private boolean mPrivateDnsRouteSet = false; private boolean mDefaultRouteSet = false; @@ -200,11 +199,11 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker { } mLinkProperties.setMtu(mContext.getResources().getInteger( com.android.internal.R.integer.config_mobile_mtu)); - mLinkCapabilities = intent.getParcelableExtra( - PhoneConstants.DATA_LINK_CAPABILITIES_KEY); - if (mLinkCapabilities == null) { - loge("CONNECTED event did not supply link capabilities."); - mLinkCapabilities = new LinkCapabilities(); + mNetworkCapabilities = intent.getParcelableExtra( + PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY); + if (mNetworkCapabilities == null) { + loge("CONNECTED event did not supply network capabilities."); + mNetworkCapabilities = new NetworkCapabilities(); } } @@ -316,10 +315,10 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker { Slog.d(TAG, "LinkProperties = " ); } - if (mLinkCapabilities != null) { - Slog.d(TAG, "LinkCapabilities = " + mLinkCapabilities); + if (mNetworkCapabilities != null) { + Slog.d(TAG, mNetworkCapabilities.toString()); } else { - Slog.d(TAG, "LinkCapabilities = " ); + Slog.d(TAG, "NetworkCapabilities = " ); } } @@ -750,14 +749,6 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker { return new LinkProperties(mLinkProperties); } - /** - * @see android.net.NetworkStateTracker#getLinkCapabilities() - */ - @Override - public LinkCapabilities getLinkCapabilities() { - return new LinkCapabilities(mLinkCapabilities); - } - public void supplyMessenger(Messenger messenger) { if (VDBG) log(mApnType + " got supplyMessenger"); AsyncChannel ac = new AsyncChannel(); diff --git a/core/java/android/net/NetworkState.java b/core/java/android/net/NetworkState.java index fbe1f82..2e0e9e4 100644 --- a/core/java/android/net/NetworkState.java +++ b/core/java/android/net/NetworkState.java @@ -28,21 +28,21 @@ public class NetworkState implements Parcelable { public final NetworkInfo networkInfo; public final LinkProperties linkProperties; - public final LinkCapabilities linkCapabilities; + public final NetworkCapabilities networkCapabilities; /** Currently only used by testing. */ public final String subscriberId; public final String networkId; public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties, - LinkCapabilities linkCapabilities) { - this(networkInfo, linkProperties, linkCapabilities, null, null); + NetworkCapabilities networkCapabilities) { + this(networkInfo, linkProperties, networkCapabilities, null, null); } public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties, - LinkCapabilities linkCapabilities, String subscriberId, String networkId) { + NetworkCapabilities networkCapabilities, String subscriberId, String networkId) { this.networkInfo = networkInfo; this.linkProperties = linkProperties; - this.linkCapabilities = linkCapabilities; + this.networkCapabilities = networkCapabilities; this.subscriberId = subscriberId; this.networkId = networkId; } @@ -50,7 +50,7 @@ public class NetworkState implements Parcelable { public NetworkState(Parcel in) { networkInfo = in.readParcelable(null); linkProperties = in.readParcelable(null); - linkCapabilities = in.readParcelable(null); + networkCapabilities = in.readParcelable(null); subscriberId = in.readString(); networkId = in.readString(); } @@ -64,7 +64,7 @@ public class NetworkState implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeParcelable(networkInfo, flags); out.writeParcelable(linkProperties, flags); - out.writeParcelable(linkCapabilities, flags); + out.writeParcelable(networkCapabilities, flags); out.writeString(subscriberId); out.writeString(networkId); } diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java index 29b57a5..35500cc 100644 --- a/core/java/android/net/NetworkStateTracker.java +++ b/core/java/android/net/NetworkStateTracker.java @@ -111,12 +111,9 @@ public interface NetworkStateTracker { public LinkProperties getLinkProperties(); /** - * A capability is an Integer/String pair, the capabilities - * are defined in the class LinkSocket#Key. - * * @return a copy of this connections capabilities, may be empty but never null. */ - public LinkCapabilities getLinkCapabilities(); + public NetworkCapabilities getNetworkCapabilities(); /** * Get interesting information about this network link diff --git a/core/java/android/net/ProxyDataTracker.java b/core/java/android/net/ProxyDataTracker.java index 461e8b8..4973b3d 100644 --- a/core/java/android/net/ProxyDataTracker.java +++ b/core/java/android/net/ProxyDataTracker.java @@ -104,7 +104,7 @@ public class ProxyDataTracker extends BaseNetworkStateTracker { public ProxyDataTracker() { mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_PROXY, 0, NETWORK_TYPE, ""); mLinkProperties = new LinkProperties(); - mLinkCapabilities = new LinkCapabilities(); + mNetworkCapabilities = new NetworkCapabilities(); mNetworkInfo.setIsAvailable(true); try { mLinkProperties.addDns(InetAddress.getByName(DNS1)); diff --git a/core/tests/coretests/src/android/net/LinkSocketTest.java b/core/tests/coretests/src/android/net/LinkSocketTest.java deleted file mode 100644 index af77d63..0000000 --- a/core/tests/coretests/src/android/net/LinkSocketTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.net; - -import android.net.LinkSocket; -import android.test.suitebuilder.annotation.SmallTest; -import junit.framework.TestCase; - -/** - * Test LinkSocket - */ -public class LinkSocketTest extends TestCase { - - @SmallTest - public void testBasic() throws Exception { - LinkSocket ls; - - ls = new LinkSocket(); - ls.close(); - } - - @SmallTest - public void testLinkCapabilities() throws Exception { - LinkCapabilities lc; - - lc = new LinkCapabilities(); - assertEquals(0, lc.size()); - assertEquals(true, lc.isEmpty()); - } -} diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 4ea33db..c1ffd56 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -1117,7 +1117,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (tracker != null) { final NetworkInfo info = getFilteredNetworkInfo(tracker, uid); result.add(new NetworkState( - info, tracker.getLinkProperties(), tracker.getLinkCapabilities())); + info, tracker.getLinkProperties(), tracker.getNetworkCapabilities())); } } } @@ -1129,7 +1129,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { final NetworkStateTracker tracker = mNetTrackers[networkType]; if (tracker != null) { return new NetworkState(tracker.getNetworkInfo(), tracker.getLinkProperties(), - tracker.getLinkCapabilities()); + tracker.getNetworkCapabilities()); } } return null; diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index d4565b6..cfaf016 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -22,8 +22,8 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; -import android.net.LinkCapabilities; import android.net.LinkProperties; +import android.net.NetworkCapabilities; import android.os.Binder; import android.os.Bundle; import android.os.Handler; @@ -120,7 +120,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private LinkProperties mDataConnectionLinkProperties; - private LinkCapabilities mDataConnectionLinkCapabilities; + private NetworkCapabilities mDataConnectionNetworkCapabilities; private Bundle mCellLocation = new Bundle(); @@ -553,7 +553,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { public void notifyDataConnection(int state, boolean isDataConnectivityPossible, String reason, String apn, String apnType, LinkProperties linkProperties, - LinkCapabilities linkCapabilities, int networkType, boolean roaming) { + NetworkCapabilities networkCapabilities, int networkType, boolean roaming) { if (!checkNotifyPermission("notifyDataConnection()" )) { return; } @@ -587,7 +587,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mDataConnectionPossible = isDataConnectivityPossible; mDataConnectionReason = reason; mDataConnectionLinkProperties = linkProperties; - mDataConnectionLinkCapabilities = linkCapabilities; + mDataConnectionNetworkCapabilities = networkCapabilities; if (mDataConnectionNetworkType != networkType) { mDataConnectionNetworkType = networkType; // need to tell registered listeners about the new network type @@ -624,7 +624,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { handleRemoveListLocked(); } broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn, - apnType, linkProperties, linkCapabilities, roaming); + apnType, linkProperties, networkCapabilities, roaming); broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason, linkProperties, ""); } @@ -794,7 +794,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { pw.println(" mDataConnectionReason=" + mDataConnectionReason); pw.println(" mDataConnectionApn=" + mDataConnectionApn); pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties); - pw.println(" mDataConnectionLinkCapabilities=" + mDataConnectionLinkCapabilities); + pw.println(" mDataConnectionNetworkCapabilities=" + + mDataConnectionNetworkCapabilities); pw.println(" mCellLocation=" + mCellLocation); pw.println(" mCellInfo=" + mCellInfo); pw.println(" mDcRtInfo=" + mDcRtInfo); @@ -862,7 +863,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { private void broadcastDataConnectionStateChanged(int state, boolean isDataConnectivityPossible, String reason, String apn, String apnType, LinkProperties linkProperties, - LinkCapabilities linkCapabilities, boolean roaming) { + NetworkCapabilities networkCapabilities, boolean roaming) { // Note: not reporting to the battery stats service here, because the // status bar takes care of that after taking into account all of the // required info. @@ -882,8 +883,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface); } } - if (linkCapabilities != null) { - intent.putExtra(PhoneConstants.DATA_LINK_CAPABILITIES_KEY, linkCapabilities); + if (networkCapabilities != null) { + intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities); } if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true); diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 8ea9b0d..b104c11 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -18,7 +18,7 @@ package com.android.internal.telephony; import android.content.Intent; import android.net.LinkProperties; -import android.net.LinkCapabilities; +import android.net.NetworkCapabilities; import android.os.Bundle; import android.telephony.CellInfo; import android.telephony.DataConnectionRealTimeInfo; @@ -37,7 +37,7 @@ interface ITelephonyRegistry { void notifyDataActivity(int state); void notifyDataConnection(int state, boolean isDataConnectivityPossible, String reason, String apn, String apnType, in LinkProperties linkProperties, - in LinkCapabilities linkCapabilities, int networkType, boolean roaming); + in NetworkCapabilities networkCapabilities, int networkType, boolean roaming); void notifyDataConnectionFailed(String reason, String apnType); void notifyCellLocation(in Bundle cellLocation); void notifyOtaspChanged(in int otaspMode); diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index 8c42d25..6ad57cf 100644 --- a/telephony/java/com/android/internal/telephony/PhoneConstants.java +++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java @@ -78,7 +78,7 @@ public class PhoneConstants { public static final String DATA_APN_TYPE_KEY = "apnType"; public static final String DATA_APN_KEY = "apn"; public static final String DATA_LINK_PROPERTIES_KEY = "linkProperties"; - public static final String DATA_LINK_CAPABILITIES_KEY = "linkCapabilities"; + public static final String DATA_NETWORK_CAPABILITIES_KEY = "networkCapabilities"; public static final String DATA_IFACE_NAME_KEY = "iface"; public static final String NETWORK_UNAVAILABLE_KEY = "networkUnvailable"; diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 5af1e4e..15b65c1 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -402,12 +402,12 @@ public class WifiManager { public static final String EXTRA_LINK_PROPERTIES = "linkProperties"; /** - * The lookup key for a {@link android.net.LinkCapabilities} object associated with the + * The lookup key for a {@link android.net.NetworkCapabilities} object associated with the * Wi-Fi network. Retrieve with * {@link android.content.Intent#getParcelableExtra(String)}. * @hide */ - public static final String EXTRA_LINK_CAPABILITIES = "linkCapabilities"; + public static final String EXTRA_NETWORK_CAPABILITIES = "networkCapabilities"; /** * The network IDs of the configured networks could have changed. diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index 7ded171..40e6649 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -21,7 +21,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.BaseNetworkStateTracker; -import android.net.LinkCapabilities; +import android.net.NetworkCapabilities; import android.net.LinkQualityInfo; import android.net.LinkProperties; import android.net.NetworkInfo; @@ -65,7 +65,7 @@ public class WifiStateTracker extends BaseNetworkStateTracker { public WifiStateTracker(int netType, String networkName) { mNetworkInfo = new NetworkInfo(netType, 0, networkName, ""); mLinkProperties = new LinkProperties(); - mLinkCapabilities = new LinkCapabilities(); + mNetworkCapabilities = new NetworkCapabilities(); mNetworkInfo.setIsAvailable(false); setTeardownRequested(false); @@ -183,17 +183,6 @@ public class WifiStateTracker extends BaseNetworkStateTracker { } /** - * A capability is an Integer/String pair, the capabilities - * are defined in the class LinkSocket#Key. - * - * @return a copy of this connections capabilities, may be empty but never null. - */ - @Override - public LinkCapabilities getLinkCapabilities() { - return new LinkCapabilities(mLinkCapabilities); - } - - /** * Return link info * @return an object of type WifiLinkQualityInfo */ @@ -264,10 +253,10 @@ public class WifiStateTracker extends BaseNetworkStateTracker { if (mLinkProperties == null) { mLinkProperties = new LinkProperties(); } - mLinkCapabilities = intent.getParcelableExtra( - WifiManager.EXTRA_LINK_CAPABILITIES); - if (mLinkCapabilities == null) { - mLinkCapabilities = new LinkCapabilities(); + mNetworkCapabilities = intent.getParcelableExtra( + WifiManager.EXTRA_NETWORK_CAPABILITIES); + if (mNetworkCapabilities == null) { + mNetworkCapabilities = new NetworkCapabilities(); } mWifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO); @@ -323,4 +312,3 @@ public class WifiStateTracker extends BaseNetworkStateTracker { mSamplingDataTracker.stopSampling(s); } } - |