Add LinkCapabilities
Change-Id: Ia1599ade936b79f12526252c0a2e6b453abb136e
This commit is contained in:
22
core/java/android/net/LinkCapabilities.aidl
Normal file
22
core/java/android/net/LinkCapabilities.aidl
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
**
|
||||
** Copyright (C) 2009 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
||||
** Copyright (C) 2009 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;
|
||||
|
||||
362
core/java/android/net/LinkCapabilities.java
Normal file
362
core/java/android/net/LinkCapabilities.java
Normal file
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* 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 = "0";
|
||||
/** 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("\"");
|
||||
return mCapabilities.toString();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
private Handler mTarget;
|
||||
private Context mContext;
|
||||
private LinkProperties mLinkProperties;
|
||||
private LinkCapabilities mLinkCapabilities;
|
||||
private boolean mPrivateDnsRouteSet = false;
|
||||
private int mDefaultGatewayAddr = 0;
|
||||
private boolean mDefaultRouteSet = false;
|
||||
@@ -231,8 +232,14 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
mLinkProperties = intent.getParcelableExtra(
|
||||
Phone.DATA_LINK_PROPERTIES_KEY);
|
||||
if (mLinkProperties == null) {
|
||||
Log.d(TAG,
|
||||
"CONNECTED event did not supply link properties.");
|
||||
Log.d(TAG, "CONNECTED event did not supply link properties.");
|
||||
mLinkProperties = new LinkProperties();
|
||||
}
|
||||
mLinkCapabilities = intent.getParcelableExtra(
|
||||
Phone.DATA_LINK_CAPABILITIES_KEY);
|
||||
if (mLinkCapabilities == null) {
|
||||
Log.d(TAG, "CONNECTED event did not supply link capabilities.");
|
||||
mLinkCapabilities = new LinkCapabilities();
|
||||
}
|
||||
setDetailedState(DetailedState.CONNECTED, reason, apnName);
|
||||
break;
|
||||
@@ -517,7 +524,17 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see android.net.NetworkStateTracker#getLinkProperties()
|
||||
*/
|
||||
public LinkProperties getLinkProperties() {
|
||||
return new LinkProperties(mLinkProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see android.net.NetworkStateTracker#getLinkCapabilities()
|
||||
*/
|
||||
public LinkCapabilities getLinkCapabilities() {
|
||||
return new LinkCapabilities(mLinkCapabilities);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,10 +103,20 @@ public interface NetworkStateTracker {
|
||||
public NetworkInfo getNetworkInfo();
|
||||
|
||||
/**
|
||||
* Fetch LinkProperties for the network
|
||||
* Return the LinkProperties for the connection.
|
||||
*
|
||||
* @return a copy of the LinkProperties, is never null.
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* Return the system properties name associated with the tcp buffer sizes
|
||||
* for this network.
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.server;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
@@ -92,7 +93,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
|
||||
private ArrayList<String> mConnectedApns;
|
||||
|
||||
private LinkProperties mDataConnectionProperties;
|
||||
private LinkProperties mDataConnectionLinkProperties;
|
||||
|
||||
private LinkCapabilities mDataConnectionLinkCapabilities;
|
||||
|
||||
private Bundle mCellLocation = new Bundle();
|
||||
|
||||
@@ -356,7 +359,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
|
||||
public void notifyDataConnection(int state, boolean isDataConnectivityPossible,
|
||||
String reason, String apn, String apnType, LinkProperties linkProperties,
|
||||
int networkType) {
|
||||
LinkCapabilities linkCapabilities, int networkType) {
|
||||
if (!checkNotifyPermission("notifyDataConnection()" )) {
|
||||
return;
|
||||
}
|
||||
@@ -382,8 +385,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
mDataConnectionPossible = isDataConnectivityPossible;
|
||||
mDataConnectionReason = reason;
|
||||
mDataConnectionApn = apn;
|
||||
mDataConnectionProperties = linkProperties;
|
||||
mDataConnectionLinkProperties = linkProperties;
|
||||
mDataConnectionLinkCapabilities = linkCapabilities;
|
||||
if (mDataConnectionNetworkType != networkType) {
|
||||
mDataConnectionNetworkType = networkType;
|
||||
modified = true;
|
||||
@@ -403,7 +406,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
}
|
||||
broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
|
||||
apnType, linkProperties);
|
||||
apnType, linkProperties, linkCapabilities);
|
||||
}
|
||||
|
||||
public void notifyDataConnectionFailed(String reason, String apnType) {
|
||||
@@ -490,7 +493,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
pw.println(" mDataConnectionPossible=" + mDataConnectionPossible);
|
||||
pw.println(" mDataConnectionReason=" + mDataConnectionReason);
|
||||
pw.println(" mDataConnectionApn=" + mDataConnectionApn);
|
||||
pw.println(" mDataConnectionProperties=" + mDataConnectionProperties);
|
||||
pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties);
|
||||
pw.println(" mDataConnectionLinkCapabilities=" + mDataConnectionLinkCapabilities);
|
||||
pw.println(" mCellLocation=" + mCellLocation);
|
||||
pw.println("registrations: count=" + recordCount);
|
||||
for (Record r : mRecords) {
|
||||
@@ -564,7 +568,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
|
||||
private void broadcastDataConnectionStateChanged(int state,
|
||||
boolean isDataConnectivityPossible,
|
||||
String reason, String apn, String apnType, LinkProperties linkProperties) {
|
||||
String reason, String apn, String apnType, LinkProperties linkProperties,
|
||||
LinkCapabilities linkCapabilities) {
|
||||
// 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.
|
||||
@@ -584,6 +589,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
intent.putExtra(Phone.DATA_IFACE_NAME_KEY, iface.getName());
|
||||
}
|
||||
}
|
||||
if (linkCapabilities != null) {
|
||||
intent.putExtra(Phone.DATA_LINK_CAPABILITIES_KEY, linkCapabilities);
|
||||
}
|
||||
intent.putExtra(Phone.DATA_APN_KEY, apn);
|
||||
intent.putExtra(Phone.DATA_APN_TYPE_KEY, apnType);
|
||||
mContext.sendStickyBroadcast(intent);
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.android.internal.telephony.gsm.ApnSetting;
|
||||
import com.android.internal.util.HierarchicalState;
|
||||
import com.android.internal.util.HierarchicalStateMachine;
|
||||
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.os.AsyncResult;
|
||||
import android.os.Message;
|
||||
@@ -31,6 +32,7 @@ import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
@@ -262,6 +264,7 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
protected PhoneBase phone;
|
||||
protected int cid;
|
||||
protected LinkProperties mLinkProperties = new LinkProperties();
|
||||
protected LinkCapabilities mCapabilities = new LinkCapabilities();
|
||||
protected long createTime;
|
||||
protected long lastFailTime;
|
||||
protected FailCause lastFailCause;
|
||||
@@ -912,12 +915,24 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the connections LinkProperties
|
||||
* Return the LinkProperties for the connection.
|
||||
*
|
||||
* @return a copy of the LinkProperties, is never null.
|
||||
*/
|
||||
public LinkProperties getLinkProperties() {
|
||||
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(mCapabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current state as a string.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.internal.telephony;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.os.AsyncResult;
|
||||
import android.os.Handler;
|
||||
@@ -192,8 +193,11 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
/** indication of our availability (preconditions to trysetupData are met) **/
|
||||
protected boolean mAvailability = false;
|
||||
|
||||
/** all our link properties (dns, gateway, ip, etc) */
|
||||
protected LinkProperties mLinkProperties;
|
||||
/** The link properties (dns, gateway, ip, etc) */
|
||||
protected LinkProperties mLinkProperties = new LinkProperties();
|
||||
|
||||
/** The link capabilities */
|
||||
protected LinkCapabilities mLinkCapabilities = new LinkCapabilities();
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -425,10 +429,40 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
if (isApnIdEnabled(id)) {
|
||||
return new LinkProperties(mLinkProperties);
|
||||
} else {
|
||||
return null;
|
||||
return new LinkProperties();
|
||||
}
|
||||
}
|
||||
|
||||
protected LinkCapabilities getLinkCapabilities(String apnType) {
|
||||
int id = apnTypeToId(apnType);
|
||||
if (isApnIdEnabled(id)) {
|
||||
return new LinkCapabilities(mLinkCapabilities);
|
||||
} else {
|
||||
return new LinkCapabilities();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the LinkProperties for the connection.
|
||||
*
|
||||
* @param connection
|
||||
* @return a copy of the LinkProperties, is never null.
|
||||
*/
|
||||
protected LinkProperties getLinkProperties(DataConnection connection) {
|
||||
return connection.getLinkProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* A capability is an Integer/String pair, the capabilities
|
||||
* are defined in the class LinkSocket#Key.
|
||||
*
|
||||
* @param connection
|
||||
* @return a copy of this connections capabilities, may be empty but never null.
|
||||
*/
|
||||
protected LinkCapabilities getLinkCapabilities(DataConnection connection) {
|
||||
return connection.getLinkCapabilities();
|
||||
}
|
||||
|
||||
// tell all active apns of the current condition
|
||||
protected void notifyDataConnection(String reason) {
|
||||
for (int id = 0; id < APN_NUM_TYPES; id++) {
|
||||
@@ -672,8 +706,4 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected LinkProperties getLinkProperties(DataConnection connection) {
|
||||
return connection.getLinkProperties();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.internal.telephony;
|
||||
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
@@ -109,8 +110,10 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
|
||||
// pass apnType back up to fetch particular for this one.
|
||||
TelephonyManager telephony = TelephonyManager.getDefault();
|
||||
LinkProperties linkProperties = null;
|
||||
LinkCapabilities linkCapabilities = null;
|
||||
if (state == Phone.DataState.CONNECTED) {
|
||||
linkProperties = sender.getLinkProperties(apnType);
|
||||
linkCapabilities = sender.getLinkCapabilities(apnType);
|
||||
}
|
||||
try {
|
||||
mRegistry.notifyDataConnection(
|
||||
@@ -119,6 +122,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
|
||||
sender.getActiveApn(),
|
||||
apnType,
|
||||
linkProperties,
|
||||
linkCapabilities,
|
||||
((telephony!=null) ? telephony.getNetworkType() :
|
||||
TelephonyManager.NETWORK_TYPE_UNKNOWN));
|
||||
} catch (RemoteException ex) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.internal.telephony;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SignalStrength;
|
||||
@@ -34,7 +35,7 @@ interface ITelephonyRegistry {
|
||||
void notifyDataActivity(int state);
|
||||
void notifyDataConnection(int state, boolean isDataConnectivityPossible,
|
||||
String reason, String apn, String apnType, in LinkProperties linkProperties,
|
||||
int networkType);
|
||||
in LinkCapabilities linkCapabilities, int networkType);
|
||||
void notifyDataConnectionFailed(String reason, String apnType);
|
||||
void notifyCellLocation(in Bundle cellLocation);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.internal.telephony;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -102,6 +103,7 @@ public interface Phone {
|
||||
static final String DATA_APN_TYPE_KEY = "apnType";
|
||||
static final String DATA_APN_KEY = "apn";
|
||||
static final String DATA_LINK_PROPERTIES_KEY = "linkProperties";
|
||||
static final String DATA_LINK_CAPABILITIES_KEY = "linkCapabilities";
|
||||
|
||||
static final String DATA_IFACE_NAME_KEY = "iface";
|
||||
static final String NETWORK_UNAVAILABLE_KEY = "networkUnvailable";
|
||||
@@ -325,6 +327,11 @@ public interface Phone {
|
||||
*/
|
||||
LinkProperties getLinkProperties(String apnType);
|
||||
|
||||
/**
|
||||
* Return the LinkCapabilities
|
||||
*/
|
||||
LinkCapabilities getLinkCapabilities(String apnType);
|
||||
|
||||
/**
|
||||
* Get current signal strength. No change notification available on this
|
||||
* interface. Use <code>PhoneStateNotifier</code> or an equivalent.
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.app.IActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.AsyncResult;
|
||||
@@ -942,6 +943,10 @@ public abstract class PhoneBase extends Handler implements Phone {
|
||||
return mDataConnection.getLinkProperties(apnType);
|
||||
}
|
||||
|
||||
public LinkCapabilities getLinkCapabilities(String apnType) {
|
||||
return mDataConnection.getLinkCapabilities(apnType);
|
||||
}
|
||||
|
||||
public String getActiveApn() {
|
||||
return mDataConnection.getActiveApnString();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.android.internal.telephony;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -212,6 +213,10 @@ public class PhoneProxy extends Handler implements Phone {
|
||||
return mActivePhone.getLinkProperties(apnType);
|
||||
}
|
||||
|
||||
public LinkCapabilities getLinkCapabilities(String apnType) {
|
||||
return mActivePhone.getLinkCapabilities(apnType);
|
||||
}
|
||||
|
||||
public String getActiveApn() {
|
||||
return mActivePhone.getActiveApn();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.internal.telephony;
|
||||
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.LinkProperties;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
@@ -111,8 +112,10 @@ public class SipPhoneNotifier implements PhoneNotifier {
|
||||
// pass apnType back up to fetch particular for this one.
|
||||
TelephonyManager telephony = TelephonyManager.getDefault();
|
||||
LinkProperties linkProperties = null;
|
||||
LinkCapabilities linkCapabilities = null;
|
||||
if (state == Phone.DataState.CONNECTED) {
|
||||
linkProperties = sender.getLinkProperties(apnType);
|
||||
linkCapabilities = sender.getLinkCapabilities(apnType);
|
||||
}
|
||||
try {
|
||||
mRegistry.notifyDataConnection(
|
||||
@@ -121,6 +124,7 @@ public class SipPhoneNotifier implements PhoneNotifier {
|
||||
sender.getActiveApn(),
|
||||
apnType,
|
||||
linkProperties,
|
||||
linkCapabilities,
|
||||
((telephony!=null) ? telephony.getNetworkType() :
|
||||
TelephonyManager.NETWORK_TYPE_UNKNOWN));
|
||||
} catch (RemoteException ex) {
|
||||
|
||||
@@ -732,7 +732,9 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
if (ar.exception == null) {
|
||||
// TODO: We should clear LinkProperties/Capabilities when torn down or disconnected
|
||||
mLinkProperties = getLinkProperties(mActiveDataConnection);
|
||||
mLinkCapabilities = getLinkCapabilities(mActiveDataConnection);
|
||||
|
||||
// everything is setup
|
||||
notifyDefaultData(reason);
|
||||
|
||||
@@ -1099,7 +1099,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
if (ar.exception == null) {
|
||||
// TODO: We should clear LinkProperties/Capabilities when torn down or disconnected
|
||||
mLinkProperties = getLinkProperties(mActivePdp);
|
||||
mLinkCapabilities = getLinkCapabilities(mActivePdp);
|
||||
|
||||
ApnSetting apn = mActivePdp.getApn();
|
||||
if (apn.proxy != null && apn.proxy.length() != 0) {
|
||||
|
||||
@@ -307,6 +307,7 @@ public class WifiManager {
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||
public static final String CONFIG_CHANGED_ACTION = "android.net.wifi.CONFIG_CHANGED";
|
||||
|
||||
/**
|
||||
* The lookup key for a {@link android.net.LinkProperties} object associated with the
|
||||
* Wi-Fi network. Retrieve with
|
||||
@@ -315,6 +316,14 @@ public class WifiManager {
|
||||
*/
|
||||
public static final String EXTRA_LINK_PROPERTIES = "linkProperties";
|
||||
|
||||
/**
|
||||
* The lookup key for a {@link android.net.LinkCapabilities} object associated with the
|
||||
* Wi-Fi network. Retrieve with
|
||||
* {@link android.content.Intent#getParcelableExtra(String)}.
|
||||
* @hide
|
||||
*/
|
||||
public static final String EXTRA_LINK_CAPABILITIES = "linkCapabilities";
|
||||
|
||||
/**
|
||||
* The network IDs of the configured networks could have changed.
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.NetworkStateTracker;
|
||||
@@ -48,6 +49,7 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
private AtomicBoolean mDefaultRouteSet = new AtomicBoolean(false);
|
||||
|
||||
private LinkProperties mLinkProperties;
|
||||
private LinkCapabilities mLinkCapabilities;
|
||||
private NetworkInfo mNetworkInfo;
|
||||
|
||||
/* For sending events to connectivity service handler */
|
||||
@@ -59,9 +61,9 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
public WifiStateTracker() {
|
||||
mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, NETWORKTYPE, "");
|
||||
mLinkProperties = new LinkProperties();
|
||||
mLinkCapabilities = new LinkCapabilities();
|
||||
|
||||
mNetworkInfo.setIsAvailable(false);
|
||||
mLinkProperties.clear();
|
||||
setTeardownRequested(false);
|
||||
}
|
||||
|
||||
@@ -195,6 +197,16 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
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
|
||||
*/
|
||||
@@ -230,8 +242,16 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
|
||||
mNetworkInfo = (NetworkInfo) intent.getParcelableExtra(
|
||||
WifiManager.EXTRA_NETWORK_INFO);
|
||||
mLinkProperties = (LinkProperties) intent.getParcelableExtra(
|
||||
mLinkProperties = intent.getParcelableExtra(
|
||||
WifiManager.EXTRA_LINK_PROPERTIES);
|
||||
if (mLinkProperties == null) {
|
||||
mLinkProperties = new LinkProperties();
|
||||
}
|
||||
mLinkCapabilities = intent.getParcelableExtra(
|
||||
WifiManager.EXTRA_LINK_CAPABILITIES);
|
||||
if (mLinkCapabilities == null) {
|
||||
mLinkCapabilities = new LinkCapabilities();
|
||||
}
|
||||
Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
|
||||
msg.sendToTarget();
|
||||
} else if (intent.getAction().equals(WifiManager.CONFIG_CHANGED_ACTION)) {
|
||||
|
||||
Reference in New Issue
Block a user