diff options
-rw-r--r-- | core/java/android/net/BaseNetworkStateTracker.java | 2 | ||||
-rw-r--r-- | core/java/android/net/ConnectivityManager.java | 12 | ||||
-rw-r--r-- | core/java/android/net/IConnectivityManager.aidl | 8 | ||||
-rw-r--r-- | core/java/android/net/LinkInfo.java | 128 | ||||
-rw-r--r-- | core/java/android/net/LinkQualityInfo.aidl (renamed from core/java/android/net/LinkInfo.aidl) | 2 | ||||
-rw-r--r-- | core/java/android/net/LinkQualityInfo.java | 286 | ||||
-rw-r--r-- | core/java/android/net/MobileDataStateTracker.java | 94 | ||||
-rw-r--r-- | core/java/android/net/MobileLinkInfo.java | 89 | ||||
-rw-r--r-- | core/java/android/net/MobileLinkQualityInfo.java | 286 | ||||
-rw-r--r-- | core/java/android/net/NetworkStateTracker.java | 2 | ||||
-rw-r--r-- | core/java/android/net/SamplingDataTracker.java | 30 | ||||
-rw-r--r-- | core/java/android/net/WifiLinkInfo.java | 75 | ||||
-rw-r--r-- | core/java/android/net/WifiLinkQualityInfo.java | 149 | ||||
-rw-r--r-- | services/java/com/android/server/ConnectivityService.java | 18 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateTracker.java | 26 |
15 files changed, 819 insertions, 388 deletions
diff --git a/core/java/android/net/BaseNetworkStateTracker.java b/core/java/android/net/BaseNetworkStateTracker.java index c39488e..476fefe 100644 --- a/core/java/android/net/BaseNetworkStateTracker.java +++ b/core/java/android/net/BaseNetworkStateTracker.java @@ -103,7 +103,7 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker { } @Override - public LinkInfo getLinkInfo() { + public LinkQualityInfo getLinkQualityInfo() { return null; } diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 3874369..4cf38b6 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -1426,9 +1426,9 @@ public class ConnectivityManager { * get the information about a specific network link * @hide */ - public LinkInfo getLinkInfo(int networkType) { + public LinkQualityInfo getLinkQualityInfo(int networkType) { try { - LinkInfo li = mService.getLinkInfo(networkType); + LinkQualityInfo li = mService.getLinkQualityInfo(networkType); return li; } catch (RemoteException e) { return null; @@ -1439,9 +1439,9 @@ public class ConnectivityManager { * get the information of currently active network link * @hide */ - public LinkInfo getActiveLinkInfo() { + public LinkQualityInfo getActiveLinkQualityInfo() { try { - LinkInfo li = mService.getActiveLinkInfo(); + LinkQualityInfo li = mService.getActiveLinkQualityInfo(); return li; } catch (RemoteException e) { return null; @@ -1452,9 +1452,9 @@ public class ConnectivityManager { * get the information of all network links * @hide */ - public LinkInfo[] getAllLinkInfo() { + public LinkQualityInfo[] getAllLinkQualityInfo() { try { - LinkInfo[] li = mService.getAllLinkInfo(); + LinkQualityInfo[] li = mService.getAllLinkQualityInfo(); return li; } catch (RemoteException e) { return null; diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index c07e900..a6f10ec 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -16,7 +16,7 @@ package android.net; -import android.net.LinkInfo; +import android.net.LinkQualityInfo; import android.net.LinkProperties; import android.net.NetworkInfo; import android.net.NetworkQuotaInfo; @@ -149,11 +149,11 @@ interface IConnectivityManager String getMobileRedirectedProvisioningUrl(); - LinkInfo getLinkInfo(int networkType); + LinkQualityInfo getLinkQualityInfo(int networkType); - LinkInfo getActiveLinkInfo(); + LinkQualityInfo getActiveLinkQualityInfo(); - LinkInfo[] getAllLinkInfo(); + LinkQualityInfo[] getAllLinkQualityInfo(); void setProvisioningNotificationVisible(boolean visible, int networkType, in String extraInfo, in String url); } diff --git a/core/java/android/net/LinkInfo.java b/core/java/android/net/LinkInfo.java deleted file mode 100644 index 47b8a95..0000000 --- a/core/java/android/net/LinkInfo.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2013 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.Parcel; -import android.os.Parcelable; - -/** - * Class that represents useful attributes of generic network links - * such as the upload/download throughput or packet error rate. - * Generally speaking, you should be dealing with instances of - * LinkInfo subclasses, such as {@link android.net.#WifiLinkInfo} - * or {@link android.net.#MobileLinkInfo} which provide additional - * information. - * @hide - */ -public class LinkInfo implements Parcelable -{ - public static final int UNKNOWN = -1; - - public static final int NORMALIZED_MIN_SIGNAL_STRENGTH = 0; - - public static final int NORMALIZED_MAX_SIGNAL_STRENGTH = 99; - - public static final int NORMALIZED_SIGNAL_STRENGTH_RANGE = NORMALIZED_MAX_SIGNAL_STRENGTH + 1; - - /* Network type as defined by ConnectivityManager */ - public int mNetworkType = ConnectivityManager.TYPE_NONE; - - public int mNormalizedSignalStrength = UNKNOWN; - - public long mPacketCount = UNKNOWN; - public long mPacketErrorCount = UNKNOWN; - public int mTheoreticalTxBandwidth = UNKNOWN; - public int mTheoreticalRxBandwidth = UNKNOWN; - public int mTheoreticalLatency = UNKNOWN; - - /* Timestamp when last sample was made available */ - public long mLastDataSampleTime = UNKNOWN; - - /* Sample duration in millisecond */ - public int mDataSampleDuration = UNKNOWN; - - public LinkInfo() { - - } - - /** - * Implement the Parcelable interface - * @hide - */ - public int describeContents() { - return 0; - } - /** - * Implement the Parcelable interface. - */ - - protected static final int OBJECT_TYPE_LINKINFO = 1; - protected static final int OBJECT_TYPE_WIFI_LINKINFO = 2; - protected static final int OBJECT_TYPE_MOBILE_LINKINFO = 3; - - public void writeToParcel(Parcel dest, int flags) { - writeToParcel(dest, flags, OBJECT_TYPE_LINKINFO); - } - - public void writeToParcel(Parcel dest, int flags, int objectType) { - dest.writeInt(objectType); - dest.writeInt(mNetworkType); - dest.writeInt(mNormalizedSignalStrength); - dest.writeLong(mPacketCount); - dest.writeLong(mPacketErrorCount); - dest.writeInt(mTheoreticalTxBandwidth); - dest.writeInt(mTheoreticalRxBandwidth); - dest.writeInt(mTheoreticalLatency); - dest.writeLong(mLastDataSampleTime); - dest.writeInt(mDataSampleDuration); - } - - public static final Creator<LinkInfo> CREATOR = - new Creator<LinkInfo>() { - public LinkInfo createFromParcel(Parcel in) { - int objectType = in.readInt(); - if (objectType == OBJECT_TYPE_LINKINFO) { - LinkInfo li = new LinkInfo(); - li.initializeFromParcel(in); - return li; - } else if (objectType == OBJECT_TYPE_WIFI_LINKINFO) { - return WifiLinkInfo.createFromParcelBody(in); - } else if (objectType == OBJECT_TYPE_MOBILE_LINKINFO) { - return MobileLinkInfo.createFromParcelBody(in); - } else { - return null; - } - } - - public LinkInfo[] newArray(int size) { - return new LinkInfo[size]; - } - }; - - protected void initializeFromParcel(Parcel in) { - mNetworkType = in.readInt(); - mNormalizedSignalStrength = in.readInt(); - mPacketCount = in.readLong(); - mPacketErrorCount = in.readLong(); - mTheoreticalTxBandwidth = in.readInt(); - mTheoreticalRxBandwidth = in.readInt(); - mTheoreticalLatency = in.readInt(); - mLastDataSampleTime = in.readLong(); - mDataSampleDuration = in.readInt(); - } - -} diff --git a/core/java/android/net/LinkInfo.aidl b/core/java/android/net/LinkQualityInfo.aidl index 716674b..5e072bf 100644 --- a/core/java/android/net/LinkInfo.aidl +++ b/core/java/android/net/LinkQualityInfo.aidl @@ -16,4 +16,4 @@ package android.net; -parcelable LinkInfo; +parcelable LinkQualityInfo; diff --git a/core/java/android/net/LinkQualityInfo.java b/core/java/android/net/LinkQualityInfo.java new file mode 100644 index 0000000..9c8e61d --- /dev/null +++ b/core/java/android/net/LinkQualityInfo.java @@ -0,0 +1,286 @@ +/* + * Copyright (C) 2013 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.Parcel; +import android.os.Parcelable; + +/** + * Class that represents useful attributes of generic network links + * such as the upload/download throughput or packet error rate. + * Generally speaking, you should be dealing with instances of + * LinkQualityInfo subclasses, such as {@link android.net.#WifiLinkQualityInfo} + * or {@link android.net.#MobileLinkQualityInfo} which provide additional + * information. + * @hide + */ +public class LinkQualityInfo implements Parcelable { + + /** + * Represents a value that you can use to test if an integer field is set to a good value + */ + public static final int UNKNOWN_INT = Integer.MAX_VALUE; + + /** + * Represents a value that you can use to test if a long field is set to a good value + */ + public static final long UNKNOWN_LONG = Long.MAX_VALUE; + + public static final int NORMALIZED_MIN_SIGNAL_STRENGTH = 0; + + public static final int NORMALIZED_MAX_SIGNAL_STRENGTH = 99; + + public static final int NORMALIZED_SIGNAL_STRENGTH_RANGE = + NORMALIZED_MAX_SIGNAL_STRENGTH - NORMALIZED_MIN_SIGNAL_STRENGTH + 1; + + /* Network type as defined by ConnectivityManager */ + private int mNetworkType = ConnectivityManager.TYPE_NONE; + + private int mNormalizedSignalStrength = UNKNOWN_INT; + + private long mPacketCount = UNKNOWN_LONG; + private long mPacketErrorCount = UNKNOWN_LONG; + private int mTheoreticalTxBandwidth = UNKNOWN_INT; + private int mTheoreticalRxBandwidth = UNKNOWN_INT; + private int mTheoreticalLatency = UNKNOWN_INT; + + /* Timestamp when last sample was made available */ + private long mLastDataSampleTime = UNKNOWN_LONG; + + /* Sample duration in millisecond */ + private int mDataSampleDuration = UNKNOWN_INT; + + public LinkQualityInfo() { + + } + + /** + * Implement the Parcelable interface + * @hide + */ + public int describeContents() { + return 0; + } + + /** + * Implement the Parcelable interface. + */ + + protected static final int OBJECT_TYPE_LINK_QUALITY_INFO = 1; + protected static final int OBJECT_TYPE_WIFI_LINK_QUALITY_INFO = 2; + protected static final int OBJECT_TYPE_MOBILE_LINK_QUALITY_INFO = 3; + + /** + * @hide + */ + public void writeToParcel(Parcel dest, int flags) { + writeToParcel(dest, flags, OBJECT_TYPE_LINK_QUALITY_INFO); + } + + /** + * @hide + */ + public void writeToParcel(Parcel dest, int flags, int objectType) { + dest.writeInt(objectType); + dest.writeInt(mNetworkType); + dest.writeInt(mNormalizedSignalStrength); + dest.writeLong(mPacketCount); + dest.writeLong(mPacketErrorCount); + dest.writeInt(mTheoreticalTxBandwidth); + dest.writeInt(mTheoreticalRxBandwidth); + dest.writeInt(mTheoreticalLatency); + dest.writeLong(mLastDataSampleTime); + dest.writeInt(mDataSampleDuration); + } + + /** + * @hide + */ + public static final Creator<LinkQualityInfo> CREATOR = + new Creator<LinkQualityInfo>() { + public LinkQualityInfo createFromParcel(Parcel in) { + int objectType = in.readInt(); + if (objectType == OBJECT_TYPE_LINK_QUALITY_INFO) { + LinkQualityInfo li = new LinkQualityInfo(); + li.initializeFromParcel(in); + return li; + } else if (objectType == OBJECT_TYPE_WIFI_LINK_QUALITY_INFO) { + return WifiLinkQualityInfo.createFromParcelBody(in); + } else if (objectType == OBJECT_TYPE_MOBILE_LINK_QUALITY_INFO) { + return MobileLinkQualityInfo.createFromParcelBody(in); + } else { + return null; + } + } + + public LinkQualityInfo[] newArray(int size) { + return new LinkQualityInfo[size]; + } + }; + + /** + * @hide + */ + protected void initializeFromParcel(Parcel in) { + mNetworkType = in.readInt(); + mNormalizedSignalStrength = in.readInt(); + mPacketCount = in.readLong(); + mPacketErrorCount = in.readLong(); + mTheoreticalTxBandwidth = in.readInt(); + mTheoreticalRxBandwidth = in.readInt(); + mTheoreticalLatency = in.readInt(); + mLastDataSampleTime = in.readLong(); + mDataSampleDuration = in.readInt(); + } + + /** + * returns the type of network this link is connected to + * @return network type as defined by {@link android.net.ConnectivityManager} or + * {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getNetworkType() { + return mNetworkType; + } + + /** + * @hide + */ + public void setNetworkType(int networkType) { + mNetworkType = networkType; + } + + /** + * returns the signal strength normalized across multiple types of networks + * @return an integer value from 0 - 99 or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getNormalizedSignalStrength() { + return mNormalizedSignalStrength; + } + + /** + * @hide + */ + public void setNormalizedSignalStrength(int normalizedSignalStrength) { + mNormalizedSignalStrength = normalizedSignalStrength; + } + + /** + * returns the total number of packets sent or received in sample duration + * @return number of packets or {@link android.net.LinkQualityInfo#UNKNOWN_LONG} + */ + public long getPacketCount() { + return mPacketCount; + } + + /** + * @hide + */ + public void setPacketCount(long packetCount) { + mPacketCount = packetCount; + } + + /** + * returns the total number of packets errors encountered in sample duration + * @return number of errors or {@link android.net.LinkQualityInfo#UNKNOWN_LONG} + */ + public long getPacketErrorCount() { + return mPacketErrorCount; + } + + /** + * @hide + */ + public void setPacketErrorCount(long packetErrorCount) { + mPacketErrorCount = packetErrorCount; + } + + /** + * returns the theoretical upload bandwidth of this network + * @return bandwidth in Kbps or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getTheoreticalTxBandwidth() { + return mTheoreticalTxBandwidth; + } + + /** + * @hide + */ + public void setTheoreticalTxBandwidth(int theoreticalTxBandwidth) { + mTheoreticalTxBandwidth = theoreticalTxBandwidth; + } + + /** + * returns the theoretical download bandwidth of this network + * @return bandwidth in Kbps or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getTheoreticalRxBandwidth() { + return mTheoreticalRxBandwidth; + } + + /** + * @hide + */ + public void setTheoreticalRxBandwidth(int theoreticalRxBandwidth) { + mTheoreticalRxBandwidth = theoreticalRxBandwidth; + } + + /** + * returns the theoretical latency of this network + * @return latency in milliseconds or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getTheoreticalLatency() { + return mTheoreticalLatency; + } + + /** + * @hide + */ + public void setTheoreticalLatency(int theoreticalLatency) { + mTheoreticalLatency = theoreticalLatency; + } + + /** + * returns the time stamp of the last sample + * @return milliseconds elapsed since start and sample time or + * {@link android.net.LinkQualityInfo#UNKNOWN_LONG} + */ + public long getLastDataSampleTime() { + return mLastDataSampleTime; + } + + /** + * @hide + */ + public void setLastDataSampleTime(long lastDataSampleTime) { + mLastDataSampleTime = lastDataSampleTime; + } + + /** + * returns the sample duration used + * @return duration in milliseconds or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getDataSampleDuration() { + return mDataSampleDuration; + } + + /** + * @hide + */ + public void setDataSampleDuration(int dataSampleDuration) { + mDataSampleDuration = dataSampleDuration; + } +} diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index 125d5c1..b5d8489 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -84,6 +84,8 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker { private SamplingDataTracker mSamplingDataTracker = new SamplingDataTracker(); + private static final int UNKNOWN = LinkQualityInfo.UNKNOWN_INT; + /** * Create a new MobileDataStateTracker * @param netType the ConnectivityManager network type @@ -756,59 +758,59 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker { } @Override - public LinkInfo getLinkInfo() { + public LinkQualityInfo getLinkQualityInfo() { if (mNetworkInfo == null || mNetworkInfo.getType() == ConnectivityManager.TYPE_NONE) { // no data available yet; just return return null; } - MobileLinkInfo li = new MobileLinkInfo(); + MobileLinkQualityInfo li = new MobileLinkQualityInfo(); - li.mNetworkType = mNetworkInfo.getType(); + li.setNetworkType(mNetworkInfo.getType()); - mSamplingDataTracker.setCommonLinkInfoFields(li); + mSamplingDataTracker.setCommonLinkQualityInfoFields(li); if (mNetworkInfo.getSubtype() != TelephonyManager.NETWORK_TYPE_UNKNOWN) { - li.mMobileNetworkType = mNetworkInfo.getSubtype(); + li.setMobileNetworkType(mNetworkInfo.getSubtype()); NetworkDataEntry entry = getNetworkDataEntry(mNetworkInfo.getSubtype()); if (entry != null) { - li.mTheoreticalRxBandwidth = entry.downloadBandwidth; - li.mTheoreticalRxBandwidth = entry.uploadBandwidth; - li.mTheoreticalLatency = entry.latency; + li.setTheoreticalRxBandwidth(entry.downloadBandwidth); + li.setTheoreticalRxBandwidth(entry.uploadBandwidth); + li.setTheoreticalLatency(entry.latency); } if (mSignalStrength != null) { - li.mNormalizedSignalStrength = getNormalizedSignalStrength( - li.mMobileNetworkType, mSignalStrength); + li.setNormalizedSignalStrength(getNormalizedSignalStrength( + li.getMobileNetworkType(), mSignalStrength)); } } SignalStrength ss = mSignalStrength; if (ss != null) { - li.mRssi = ss.getGsmSignalStrength(); - li.mGsmErrorRate = ss.getGsmBitErrorRate(); - li.mCdmaDbm = ss.getCdmaDbm(); - li.mCdmaEcio = ss.getCdmaEcio(); - li.mEvdoDbm = ss.getEvdoDbm(); - li.mEvdoEcio = ss.getEvdoEcio(); - li.mEvdoSnr = ss.getEvdoSnr(); - li.mLteSignalStrength = ss.getLteSignalStrength(); - li.mLteRsrp = ss.getLteRsrp(); - li.mLteRsrq = ss.getLteRsrq(); - li.mLteRssnr = ss.getLteRssnr(); - li.mLteCqi = ss.getLteCqi(); + li.setRssi(ss.getGsmSignalStrength()); + li.setGsmErrorRate(ss.getGsmBitErrorRate()); + li.setCdmaDbm(ss.getCdmaDbm()); + li.setCdmaEcio(ss.getCdmaEcio()); + li.setEvdoDbm(ss.getEvdoDbm()); + li.setEvdoEcio(ss.getEvdoEcio()); + li.setEvdoSnr(ss.getEvdoSnr()); + li.setLteSignalStrength(ss.getLteSignalStrength()); + li.setLteRsrp(ss.getLteRsrp()); + li.setLteRsrq(ss.getLteRsrq()); + li.setLteRssnr(ss.getLteRssnr()); + li.setLteCqi(ss.getLteCqi()); } if (VDBG) { - Slog.d(TAG, "Returning LinkInfo with" - + " MobileNetworkType = " + String.valueOf(li.mMobileNetworkType) - + " Theoretical Rx BW = " + String.valueOf(li.mTheoreticalRxBandwidth) - + " gsm Signal Strength = " + String.valueOf(li.mRssi) - + " cdma Signal Strength = " + String.valueOf(li.mCdmaDbm) - + " evdo Signal Strength = " + String.valueOf(li.mEvdoDbm) - + " Lte Signal Strength = " + String.valueOf(li.mLteSignalStrength)); + Slog.d(TAG, "Returning LinkQualityInfo with" + + " MobileNetworkType = " + String.valueOf(li.getMobileNetworkType()) + + " Theoretical Rx BW = " + String.valueOf(li.getTheoreticalRxBandwidth()) + + " gsm Signal Strength = " + String.valueOf(li.getRssi()) + + " cdma Signal Strength = " + String.valueOf(li.getCdmaDbm()) + + " evdo Signal Strength = " + String.valueOf(li.getEvdoDbm()) + + " Lte Signal Strength = " + String.valueOf(li.getLteSignalStrength())); } return li; @@ -829,21 +831,21 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker { } private static NetworkDataEntry [] mTheoreticalBWTable = new NetworkDataEntry[] { - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EDGE, 237, 118, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_GPRS, 48, 40, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_UMTS, 384, 64, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSDPA, 14400, -1, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSUPA, 14400, 5760, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSPA, 14400, 5760, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSPAP, 21000, 5760, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_CDMA, -1, -1, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_1xRTT, -1, -1, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_0, 2468, 153, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_A, 3072, 1800, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_B, 14700, 1800, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_IDEN, -1, -1, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_LTE, 100000, 50000, -1), - new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EHRPD, -1, -1, -1), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EDGE, 237, 118, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_GPRS, 48, 40, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_UMTS, 384, 64, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSDPA, 14400, UNKNOWN, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSUPA, 14400, 5760, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSPA, 14400, 5760, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSPAP, 21000, 5760, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_CDMA, UNKNOWN, UNKNOWN, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_1xRTT, UNKNOWN, UNKNOWN, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_0, 2468, 153, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_A, 3072, 1800, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_B, 14700, 1800, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_IDEN, UNKNOWN, UNKNOWN, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_LTE, 100000, 50000, UNKNOWN), + new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EHRPD, UNKNOWN, UNKNOWN, UNKNOWN), }; private static NetworkDataEntry getNetworkDataEntry(int networkType) { @@ -886,10 +888,10 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker { case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_EHRPD: default: - return LinkInfo.UNKNOWN; + return UNKNOWN; } - return (level * LinkInfo.NORMALIZED_SIGNAL_STRENGTH_RANGE) / + return (level * LinkQualityInfo.NORMALIZED_SIGNAL_STRENGTH_RANGE) / SignalStrength.NUM_SIGNAL_STRENGTH_BINS; } diff --git a/core/java/android/net/MobileLinkInfo.java b/core/java/android/net/MobileLinkInfo.java deleted file mode 100644 index 2d18275..0000000 --- a/core/java/android/net/MobileLinkInfo.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2013 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.Parcel; -import android.net.LinkInfo; - -/** - * Class that represents useful attributes of mobile network links - * such as the upload/download throughput or error rate etc. - * @hide - */ -public final class MobileLinkInfo extends LinkInfo -{ - // Represents TelephonyManager.NetworkType - public int mMobileNetworkType = UNKNOWN; - public int mRssi = UNKNOWN; - public int mGsmErrorRate = UNKNOWN; - public int mCdmaDbm = UNKNOWN; - public int mCdmaEcio = UNKNOWN; - public int mEvdoDbm = UNKNOWN; - public int mEvdoEcio = UNKNOWN; - public int mEvdoSnr = UNKNOWN; - public int mLteSignalStrength = UNKNOWN; - public int mLteRsrp = UNKNOWN; - public int mLteRsrq = UNKNOWN; - public int mLteRssnr = UNKNOWN; - public int mLteCqi = UNKNOWN; - - /** - * Implement the Parcelable interface. - */ - @Override - public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags, OBJECT_TYPE_MOBILE_LINKINFO); - - dest.writeInt(mMobileNetworkType); - dest.writeInt(mRssi); - dest.writeInt(mGsmErrorRate); - dest.writeInt(mCdmaDbm); - dest.writeInt(mCdmaEcio); - dest.writeInt(mEvdoDbm); - dest.writeInt(mEvdoEcio); - dest.writeInt(mEvdoSnr); - dest.writeInt(mLteSignalStrength); - dest.writeInt(mLteRsrp); - dest.writeInt(mLteRsrq); - dest.writeInt(mLteRssnr); - dest.writeInt(mLteCqi); - } - - /* Un-parceling helper */ - public static MobileLinkInfo createFromParcelBody(Parcel in) { - - MobileLinkInfo li = new MobileLinkInfo(); - - li.initializeFromParcel(in); - - li.mMobileNetworkType = in.readInt(); - li.mRssi = in.readInt(); - li.mGsmErrorRate = in.readInt(); - li.mCdmaDbm = in.readInt(); - li.mCdmaEcio = in.readInt(); - li.mEvdoDbm = in.readInt(); - li.mEvdoEcio = in.readInt(); - li.mEvdoSnr = in.readInt(); - li.mLteSignalStrength = in.readInt(); - li.mLteRsrp = in.readInt(); - li.mLteRsrq = in.readInt(); - li.mLteRssnr = in.readInt(); - li.mLteCqi = in.readInt(); - - return li; - } -} diff --git a/core/java/android/net/MobileLinkQualityInfo.java b/core/java/android/net/MobileLinkQualityInfo.java new file mode 100644 index 0000000..a01fc80 --- /dev/null +++ b/core/java/android/net/MobileLinkQualityInfo.java @@ -0,0 +1,286 @@ +/* + * Copyright (C) 2013 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.Parcel; + +/** + * Class that represents useful attributes of mobile network links + * such as the upload/download throughput or error rate etc. + * @hide + */ +public class MobileLinkQualityInfo extends LinkQualityInfo { + // Represents TelephonyManager.NetworkType + private int mMobileNetworkType = UNKNOWN_INT; + private int mRssi = UNKNOWN_INT; + private int mGsmErrorRate = UNKNOWN_INT; + private int mCdmaDbm = UNKNOWN_INT; + private int mCdmaEcio = UNKNOWN_INT; + private int mEvdoDbm = UNKNOWN_INT; + private int mEvdoEcio = UNKNOWN_INT; + private int mEvdoSnr = UNKNOWN_INT; + private int mLteSignalStrength = UNKNOWN_INT; + private int mLteRsrp = UNKNOWN_INT; + private int mLteRsrq = UNKNOWN_INT; + private int mLteRssnr = UNKNOWN_INT; + private int mLteCqi = UNKNOWN_INT; + + /** + * Implement the Parcelable interface. + * @hide + */ + @Override + public void writeToParcel(Parcel dest, int flags) { + super.writeToParcel(dest, flags, OBJECT_TYPE_MOBILE_LINK_QUALITY_INFO); + + dest.writeInt(mMobileNetworkType); + dest.writeInt(mRssi); + dest.writeInt(mGsmErrorRate); + dest.writeInt(mCdmaDbm); + dest.writeInt(mCdmaEcio); + dest.writeInt(mEvdoDbm); + dest.writeInt(mEvdoEcio); + dest.writeInt(mEvdoSnr); + dest.writeInt(mLteSignalStrength); + dest.writeInt(mLteRsrp); + dest.writeInt(mLteRsrq); + dest.writeInt(mLteRssnr); + dest.writeInt(mLteCqi); + } + + /* Un-parceling helper */ + /** + * @hide + */ + public static MobileLinkQualityInfo createFromParcelBody(Parcel in) { + + MobileLinkQualityInfo li = new MobileLinkQualityInfo(); + + li.initializeFromParcel(in); + + li.mMobileNetworkType = in.readInt(); + li.mRssi = in.readInt(); + li.mGsmErrorRate = in.readInt(); + li.mCdmaDbm = in.readInt(); + li.mCdmaEcio = in.readInt(); + li.mEvdoDbm = in.readInt(); + li.mEvdoEcio = in.readInt(); + li.mEvdoSnr = in.readInt(); + li.mLteSignalStrength = in.readInt(); + li.mLteRsrp = in.readInt(); + li.mLteRsrq = in.readInt(); + li.mLteRssnr = in.readInt(); + li.mLteCqi = in.readInt(); + + return li; + } + + /** + * returns mobile network type as defined by {@link android.telephony.TelephonyManager} + * @return network type or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getMobileNetworkType() { + return mMobileNetworkType; + } + + /** + * @hide + */ + public void setMobileNetworkType(int mobileNetworkType) { + mMobileNetworkType = mobileNetworkType; + } + + /** + * returns signal strength for GSM networks + * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getRssi() { + return mRssi; + } + + /** + * @hide + */ + public void setRssi(int Rssi) { + mRssi = Rssi; + } + + /** + * returns error rates for GSM networks + * @return error rate or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getGsmErrorRate() { + return mGsmErrorRate; + } + + /** + * @hide + */ + public void setGsmErrorRate(int gsmErrorRate) { + mGsmErrorRate = gsmErrorRate; + } + + /** + * returns signal strength for CDMA networks + * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getCdmaDbm() { + return mCdmaDbm; + } + + /** + * @hide + */ + public void setCdmaDbm(int cdmaDbm) { + mCdmaDbm = cdmaDbm; + } + + /** + * returns signal to noise ratio for CDMA networks + * @return signal to noise ratio in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getCdmaEcio() { + return mCdmaEcio; + } + + /** + * @hide + */ + public void setCdmaEcio(int cdmaEcio) { + mCdmaEcio = cdmaEcio; + } + + /** + * returns signal strength for EVDO networks + * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getEvdoDbm() { + return mEvdoDbm; + } + + /** + * @hide + */ + public void setEvdoDbm(int evdoDbm) { + mEvdoDbm = evdoDbm; + } + + /** + * returns signal to noise ratio for EVDO spectrum + * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getEvdoEcio() { + return mEvdoEcio; + } + + /** + * @hide + */ + public void setEvdoEcio(int evdoEcio) { + mEvdoEcio = evdoEcio; + } + + /** + * returns end-to-end signal to noise ratio for EVDO networks + * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getEvdoSnr() { + return mEvdoSnr; + } + + /** + * @hide + */ + public void setEvdoSnr(int evdoSnr) { + mEvdoSnr = evdoSnr; + } + + /** + * returns signal strength for LTE network + * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getLteSignalStrength() { + return mLteSignalStrength; + } + + /** + * @hide + */ + public void setLteSignalStrength(int lteSignalStrength) { + mLteSignalStrength = lteSignalStrength; + } + + /** + * returns RSRP (Reference Signal Received Power) for LTE network + * @return RSRP in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getLteRsrp() { + return mLteRsrp; + } + + /** + * @hide + */ + public void setLteRsrp(int lteRsrp) { + mLteRsrp = lteRsrp; + } + + /** + * returns RSRQ (Reference Signal Received Quality) for LTE network + * @return RSRQ ??? or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getLteRsrq() { + return mLteRsrq; + } + + /** + * @hide + */ + public void setLteRsrq(int lteRsrq) { + mLteRsrq = lteRsrq; + } + + /** + * returns signal to noise ratio for LTE networks + * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getLteRssnr() { + return mLteRssnr; + } + + /** + * @hide + */ + public void setLteRssnr(int lteRssnr) { + mLteRssnr = lteRssnr; + } + + /** + * returns channel quality indicator for LTE networks + * @return CQI or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getLteCqi() { + return mLteCqi; + } + + /** + * @hide + */ + public void setLteCqi(int lteCqi) { + mLteCqi = lteCqi; + } +} diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java index a3d7b14..1ca9255 100644 --- a/core/java/android/net/NetworkStateTracker.java +++ b/core/java/android/net/NetworkStateTracker.java @@ -122,7 +122,7 @@ public interface NetworkStateTracker { * Get interesting information about this network link * @return a copy of link information, null if not available */ - public LinkInfo getLinkInfo(); + public LinkQualityInfo getLinkQualityInfo(); /** * Return the system properties name associated with the tcp buffer sizes diff --git a/core/java/android/net/SamplingDataTracker.java b/core/java/android/net/SamplingDataTracker.java index ac24930..acd56f2 100644 --- a/core/java/android/net/SamplingDataTracker.java +++ b/core/java/android/net/SamplingDataTracker.java @@ -189,7 +189,7 @@ public class SamplingDataTracker if (mBeginningSample != null && mEndingSample != null) { return mEndingSample.mTxByteCount - mBeginningSample.mTxByteCount; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } } @@ -199,7 +199,7 @@ public class SamplingDataTracker if (mBeginningSample != null && mEndingSample != null) { return mEndingSample.mTxPacketCount - mBeginningSample.mTxPacketCount; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } } @@ -209,7 +209,7 @@ public class SamplingDataTracker if (mBeginningSample != null && mEndingSample != null) { return mEndingSample.mTxPacketErrorCount - mBeginningSample.mTxPacketErrorCount; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } } @@ -219,7 +219,7 @@ public class SamplingDataTracker if (mBeginningSample != null && mEndingSample != null) { return mEndingSample.mRxByteCount - mBeginningSample.mRxByteCount; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } } @@ -229,7 +229,7 @@ public class SamplingDataTracker if (mBeginningSample != null && mEndingSample != null) { return mEndingSample.mRxPacketCount - mBeginningSample.mRxPacketCount; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } } @@ -244,7 +244,7 @@ public class SamplingDataTracker long txPacketCount = end.mTxPacketCount - begin.mTxPacketCount; return rxPacketCount + txPacketCount; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } @@ -254,7 +254,7 @@ public class SamplingDataTracker long txPacketErrorCount = getSampledTxPacketErrorCount(); return rxPacketErrorCount + txPacketErrorCount; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } @@ -263,7 +263,7 @@ public class SamplingDataTracker if (mBeginningSample != null && mEndingSample != null) { return mEndingSample.mRxPacketErrorCount - mBeginningSample.mRxPacketErrorCount; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } } @@ -273,7 +273,7 @@ public class SamplingDataTracker if (mEndingSample != null) { return mEndingSample.mTimestamp; } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_LONG; } } } @@ -283,17 +283,17 @@ public class SamplingDataTracker if (mBeginningSample != null && mEndingSample != null) { return (int) (mEndingSample.mTimestamp - mBeginningSample.mTimestamp); } else { - return LinkInfo.UNKNOWN; + return LinkQualityInfo.UNKNOWN_INT; } } } - public void setCommonLinkInfoFields(LinkInfo li) { + public void setCommonLinkQualityInfoFields(LinkQualityInfo li) { synchronized(mSamplingDataLock) { - li.mLastDataSampleTime = getSampleTimestamp(); - li.mDataSampleDuration = getSampleDuration(); - li.mPacketCount = getSampledPacketCount(); - li.mPacketErrorCount = getSampledPacketErrorCount(); + li.setLastDataSampleTime(getSampleTimestamp()); + li.setDataSampleDuration(getSampleDuration()); + li.setPacketCount(getSampledPacketCount()); + li.setPacketErrorCount(getSampledPacketErrorCount()); } } } diff --git a/core/java/android/net/WifiLinkInfo.java b/core/java/android/net/WifiLinkInfo.java deleted file mode 100644 index a21f1fe..0000000 --- a/core/java/android/net/WifiLinkInfo.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2013 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.Parcel; -import android.net.LinkInfo; - -/** - * Class that represents useful attributes of wifi network links - * such as the upload/download throughput or error rate etc. - * @hide - */ -public final class WifiLinkInfo extends LinkInfo -{ - /** - * Type enumerations for Wifi Network - */ - - /* Indicates Wifi network type such as b/g etc*/ - public int mType = UNKNOWN; - - public String mBssid; - - /* Rssi found by scans */ - public int mRssi = UNKNOWN; - - /* packet statistics */ - public long mTxGood = UNKNOWN; - public long mTxBad = UNKNOWN; - - /** - * Implement the Parcelable interface. - */ - @Override - public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags, OBJECT_TYPE_WIFI_LINKINFO); - - dest.writeInt(mType); - dest.writeInt(mRssi); - dest.writeLong(mTxGood); - dest.writeLong(mTxBad); - - dest.writeString(mBssid); - } - - /* Un-parceling helper */ - public static WifiLinkInfo createFromParcelBody(Parcel in) { - WifiLinkInfo li = new WifiLinkInfo(); - - li.initializeFromParcel(in); - - li.mType = in.readInt(); - li.mRssi = in.readInt(); - li.mTxGood = in.readLong(); - li.mTxBad = in.readLong(); - - li.mBssid = in.readString(); - - return li; - } -} diff --git a/core/java/android/net/WifiLinkQualityInfo.java b/core/java/android/net/WifiLinkQualityInfo.java new file mode 100644 index 0000000..20ec9a7 --- /dev/null +++ b/core/java/android/net/WifiLinkQualityInfo.java @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2013 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.Parcel; + +/** + * Class that represents useful attributes of wifi network links + * such as the upload/download throughput or error rate etc. + * @hide + */ +public class WifiLinkQualityInfo extends LinkQualityInfo { + + /* Indicates Wifi network type such as b/g etc*/ + private int mType = UNKNOWN_INT; + + private String mBssid; + + /* Rssi found by scans */ + private int mRssi = UNKNOWN_INT; + + /* packet statistics */ + private long mTxGood = UNKNOWN_LONG; + private long mTxBad = UNKNOWN_LONG; + + /** + * Implement the Parcelable interface. + * @hide + */ + @Override + public void writeToParcel(Parcel dest, int flags) { + super.writeToParcel(dest, flags, OBJECT_TYPE_WIFI_LINK_QUALITY_INFO); + + dest.writeInt(mType); + dest.writeInt(mRssi); + dest.writeLong(mTxGood); + dest.writeLong(mTxBad); + + dest.writeString(mBssid); + } + + /* Un-parceling helper */ + /** + * @hide + */ + public static WifiLinkQualityInfo createFromParcelBody(Parcel in) { + WifiLinkQualityInfo li = new WifiLinkQualityInfo(); + + li.initializeFromParcel(in); + + li.mType = in.readInt(); + li.mRssi = in.readInt(); + li.mTxGood = in.readLong(); + li.mTxBad = in.readLong(); + + li.mBssid = in.readString(); + + return li; + } + + /** + * returns Wifi network type + * @return network type or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getType() { + return mType; + } + + /** + * @hide + */ + public void setType(int type) { + mType = type; + } + + /** + * returns BSSID of the access point + * @return the BSSID, in the form of a six-byte MAC address: {@code XX:XX:XX:XX:XX:XX} or null + */ + public String getBssid() { + return mBssid; + } + + /** + * @hide + */ + public void setBssid(String bssid) { + mBssid = bssid; + } + + /** + * returns RSSI of the network in raw form + * @return un-normalized RSSI or {@link android.net.LinkQualityInfo#UNKNOWN_INT} + */ + public int getRssi() { + return mRssi; + } + + /** + * @hide + */ + public void setRssi(int rssi) { + mRssi = rssi; + } + + /** + * returns number of packets transmitted without error + * @return number of packets or {@link android.net.LinkQualityInfo#UNKNOWN_LONG} + */ + public long getTxGood() { + return mTxGood; + } + + /** + * @hide + */ + public void setTxGood(long txGood) { + mTxGood = txGood; + } + + /** + * returns number of transmitted packets that encountered errors + * @return number of packets or {@link android.net.LinkQualityInfo#UNKNOWN_LONG} + */ + public long getTxBad() { + return mTxBad; + } + + /** + * @hide + */ + public void setTxBad(long txBad) { + mTxBad = txBad; + } +} diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 9c14654..9bf2d3b 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -58,7 +58,7 @@ import android.net.INetworkPolicyManager; import android.net.INetworkStatsService; import android.net.LinkAddress; import android.net.LinkProperties; -import android.net.LinkInfo; +import android.net.LinkQualityInfo; import android.net.LinkProperties.CompareResult; import android.net.MobileDataStateTracker; import android.net.NetworkConfig; @@ -4689,39 +4689,39 @@ public class ConnectivityService extends IConnectivityManager.Stub { }; @Override - public LinkInfo getLinkInfo(int networkType) { + public LinkQualityInfo getLinkQualityInfo(int networkType) { enforceAccessPermission(); if (isNetworkTypeValid(networkType)) { - return mNetTrackers[networkType].getLinkInfo(); + return mNetTrackers[networkType].getLinkQualityInfo(); } else { return null; } } @Override - public LinkInfo getActiveLinkInfo() { + public LinkQualityInfo getActiveLinkQualityInfo() { enforceAccessPermission(); if (isNetworkTypeValid(mActiveDefaultNetwork)) { - return mNetTrackers[mActiveDefaultNetwork].getLinkInfo(); + return mNetTrackers[mActiveDefaultNetwork].getLinkQualityInfo(); } else { return null; } } @Override - public LinkInfo[] getAllLinkInfo() { + public LinkQualityInfo[] getAllLinkQualityInfo() { enforceAccessPermission(); - final ArrayList<LinkInfo> result = Lists.newArrayList(); + final ArrayList<LinkQualityInfo> result = Lists.newArrayList(); for (NetworkStateTracker tracker : mNetTrackers) { if (tracker != null) { - LinkInfo li = tracker.getLinkInfo(); + LinkQualityInfo li = tracker.getLinkQualityInfo(); if (li != null) { result.add(li); } } } - return result.toArray(new LinkInfo[result.size()]); + return result.toArray(new LinkQualityInfo[result.size()]); } /* Infrastructure for network sampling */ diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index 62630d6..615c893 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -22,12 +22,12 @@ import android.content.Intent; import android.content.IntentFilter; import android.net.BaseNetworkStateTracker; import android.net.LinkCapabilities; -import android.net.LinkInfo; +import android.net.LinkQualityInfo; import android.net.LinkProperties; import android.net.NetworkInfo; import android.net.NetworkInfo.DetailedState; import android.net.SamplingDataTracker; -import android.net.WifiLinkInfo; +import android.net.WifiLinkQualityInfo; import android.os.Handler; import android.os.Message; import android.os.Messenger; @@ -203,35 +203,35 @@ public class WifiStateTracker extends BaseNetworkStateTracker { /** * Return link info - * @return an object of type WifiLinkInfo + * @return an object of type WifiLinkQualityInfo */ @Override - public LinkInfo getLinkInfo() { + public LinkQualityInfo getLinkQualityInfo() { if (mNetworkInfo == null) { // no data available yet; just return return null; } - WifiLinkInfo li = new WifiLinkInfo(); - li.mNetworkType = mNetworkInfo.getType(); + WifiLinkQualityInfo li = new WifiLinkQualityInfo(); + li.setNetworkType(mNetworkInfo.getType()); synchronized(mSamplingDataTracker.mSamplingDataLock) { - mSamplingDataTracker.setCommonLinkInfoFields(li); - li.mTxGood = mSamplingDataTracker.getSampledTxPacketCount(); - li.mTxBad = mSamplingDataTracker.getSampledTxPacketErrorCount(); + mSamplingDataTracker.setCommonLinkQualityInfoFields(li); + li.setTxGood(mSamplingDataTracker.getSampledTxPacketCount()); + li.setTxBad(mSamplingDataTracker.getSampledTxPacketErrorCount()); } // li.setTheoreticalRxBandwidth(??); // li.setTheoreticalTxBandwidth(??); if (mWifiInfo != null) { - li.mBssid = mWifiInfo.getBSSID(); + li.setBssid(mWifiInfo.getBSSID()); int rssi = mWifiInfo.getRssi(); - li.mRssi = rssi; + li.setRssi(rssi); - li.mNormalizedSignalStrength = mWifiManager.calculateSignalLevel(rssi, - LinkInfo.NORMALIZED_SIGNAL_STRENGTH_RANGE); + li.setNormalizedSignalStrength(mWifiManager.calculateSignalLevel(rssi, + LinkQualityInfo.NORMALIZED_SIGNAL_STRENGTH_RANGE)); } return li; |