am b402fb2f: Merge "Rename LinkInfo to LinkQualityInfo" into klp-dev
* commit 'b402fb2fddbee48ef3b518358dc5c86db63f7780': Rename LinkInfo to LinkQualityInfo
This commit is contained in:
@@ -103,7 +103,7 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkInfo getLinkInfo() {
|
public LinkQualityInfo getLinkQualityInfo() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1426,9 +1426,9 @@ public class ConnectivityManager {
|
|||||||
* get the information about a specific network link
|
* get the information about a specific network link
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public LinkInfo getLinkInfo(int networkType) {
|
public LinkQualityInfo getLinkQualityInfo(int networkType) {
|
||||||
try {
|
try {
|
||||||
LinkInfo li = mService.getLinkInfo(networkType);
|
LinkQualityInfo li = mService.getLinkQualityInfo(networkType);
|
||||||
return li;
|
return li;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
return null;
|
return null;
|
||||||
@@ -1439,9 +1439,9 @@ public class ConnectivityManager {
|
|||||||
* get the information of currently active network link
|
* get the information of currently active network link
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public LinkInfo getActiveLinkInfo() {
|
public LinkQualityInfo getActiveLinkQualityInfo() {
|
||||||
try {
|
try {
|
||||||
LinkInfo li = mService.getActiveLinkInfo();
|
LinkQualityInfo li = mService.getActiveLinkQualityInfo();
|
||||||
return li;
|
return li;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
return null;
|
return null;
|
||||||
@@ -1452,9 +1452,9 @@ public class ConnectivityManager {
|
|||||||
* get the information of all network links
|
* get the information of all network links
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public LinkInfo[] getAllLinkInfo() {
|
public LinkQualityInfo[] getAllLinkQualityInfo() {
|
||||||
try {
|
try {
|
||||||
LinkInfo[] li = mService.getAllLinkInfo();
|
LinkQualityInfo[] li = mService.getAllLinkQualityInfo();
|
||||||
return li;
|
return li;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
import android.net.LinkInfo;
|
import android.net.LinkQualityInfo;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkQuotaInfo;
|
import android.net.NetworkQuotaInfo;
|
||||||
@@ -149,11 +149,11 @@ interface IConnectivityManager
|
|||||||
|
|
||||||
String getMobileRedirectedProvisioningUrl();
|
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);
|
void setProvisioningNotificationVisible(boolean visible, int networkType, in String extraInfo, in String url);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -16,4 +16,4 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
parcelable LinkInfo;
|
parcelable LinkQualityInfo;
|
||||||
286
core/java/android/net/LinkQualityInfo.java
Normal file
286
core/java/android/net/LinkQualityInfo.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,6 +84,8 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
|
|||||||
|
|
||||||
private SamplingDataTracker mSamplingDataTracker = new SamplingDataTracker();
|
private SamplingDataTracker mSamplingDataTracker = new SamplingDataTracker();
|
||||||
|
|
||||||
|
private static final int UNKNOWN = LinkQualityInfo.UNKNOWN_INT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new MobileDataStateTracker
|
* Create a new MobileDataStateTracker
|
||||||
* @param netType the ConnectivityManager network type
|
* @param netType the ConnectivityManager network type
|
||||||
@@ -756,59 +758,59 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkInfo getLinkInfo() {
|
public LinkQualityInfo getLinkQualityInfo() {
|
||||||
if (mNetworkInfo == null || mNetworkInfo.getType() == ConnectivityManager.TYPE_NONE) {
|
if (mNetworkInfo == null || mNetworkInfo.getType() == ConnectivityManager.TYPE_NONE) {
|
||||||
// no data available yet; just return
|
// no data available yet; just return
|
||||||
return null;
|
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) {
|
if (mNetworkInfo.getSubtype() != TelephonyManager.NETWORK_TYPE_UNKNOWN) {
|
||||||
li.mMobileNetworkType = mNetworkInfo.getSubtype();
|
li.setMobileNetworkType(mNetworkInfo.getSubtype());
|
||||||
|
|
||||||
NetworkDataEntry entry = getNetworkDataEntry(mNetworkInfo.getSubtype());
|
NetworkDataEntry entry = getNetworkDataEntry(mNetworkInfo.getSubtype());
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
li.mTheoreticalRxBandwidth = entry.downloadBandwidth;
|
li.setTheoreticalRxBandwidth(entry.downloadBandwidth);
|
||||||
li.mTheoreticalRxBandwidth = entry.uploadBandwidth;
|
li.setTheoreticalRxBandwidth(entry.uploadBandwidth);
|
||||||
li.mTheoreticalLatency = entry.latency;
|
li.setTheoreticalLatency(entry.latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSignalStrength != null) {
|
if (mSignalStrength != null) {
|
||||||
li.mNormalizedSignalStrength = getNormalizedSignalStrength(
|
li.setNormalizedSignalStrength(getNormalizedSignalStrength(
|
||||||
li.mMobileNetworkType, mSignalStrength);
|
li.getMobileNetworkType(), mSignalStrength));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalStrength ss = mSignalStrength;
|
SignalStrength ss = mSignalStrength;
|
||||||
if (ss != null) {
|
if (ss != null) {
|
||||||
|
|
||||||
li.mRssi = ss.getGsmSignalStrength();
|
li.setRssi(ss.getGsmSignalStrength());
|
||||||
li.mGsmErrorRate = ss.getGsmBitErrorRate();
|
li.setGsmErrorRate(ss.getGsmBitErrorRate());
|
||||||
li.mCdmaDbm = ss.getCdmaDbm();
|
li.setCdmaDbm(ss.getCdmaDbm());
|
||||||
li.mCdmaEcio = ss.getCdmaEcio();
|
li.setCdmaEcio(ss.getCdmaEcio());
|
||||||
li.mEvdoDbm = ss.getEvdoDbm();
|
li.setEvdoDbm(ss.getEvdoDbm());
|
||||||
li.mEvdoEcio = ss.getEvdoEcio();
|
li.setEvdoEcio(ss.getEvdoEcio());
|
||||||
li.mEvdoSnr = ss.getEvdoSnr();
|
li.setEvdoSnr(ss.getEvdoSnr());
|
||||||
li.mLteSignalStrength = ss.getLteSignalStrength();
|
li.setLteSignalStrength(ss.getLteSignalStrength());
|
||||||
li.mLteRsrp = ss.getLteRsrp();
|
li.setLteRsrp(ss.getLteRsrp());
|
||||||
li.mLteRsrq = ss.getLteRsrq();
|
li.setLteRsrq(ss.getLteRsrq());
|
||||||
li.mLteRssnr = ss.getLteRssnr();
|
li.setLteRssnr(ss.getLteRssnr());
|
||||||
li.mLteCqi = ss.getLteCqi();
|
li.setLteCqi(ss.getLteCqi());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
Slog.d(TAG, "Returning LinkInfo with"
|
Slog.d(TAG, "Returning LinkQualityInfo with"
|
||||||
+ " MobileNetworkType = " + String.valueOf(li.mMobileNetworkType)
|
+ " MobileNetworkType = " + String.valueOf(li.getMobileNetworkType())
|
||||||
+ " Theoretical Rx BW = " + String.valueOf(li.mTheoreticalRxBandwidth)
|
+ " Theoretical Rx BW = " + String.valueOf(li.getTheoreticalRxBandwidth())
|
||||||
+ " gsm Signal Strength = " + String.valueOf(li.mRssi)
|
+ " gsm Signal Strength = " + String.valueOf(li.getRssi())
|
||||||
+ " cdma Signal Strength = " + String.valueOf(li.mCdmaDbm)
|
+ " cdma Signal Strength = " + String.valueOf(li.getCdmaDbm())
|
||||||
+ " evdo Signal Strength = " + String.valueOf(li.mEvdoDbm)
|
+ " evdo Signal Strength = " + String.valueOf(li.getEvdoDbm())
|
||||||
+ " Lte Signal Strength = " + String.valueOf(li.mLteSignalStrength));
|
+ " Lte Signal Strength = " + String.valueOf(li.getLteSignalStrength()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return li;
|
return li;
|
||||||
@@ -829,21 +831,21 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static NetworkDataEntry [] mTheoreticalBWTable = new NetworkDataEntry[] {
|
private static NetworkDataEntry [] mTheoreticalBWTable = new NetworkDataEntry[] {
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EDGE, 237, 118, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EDGE, 237, 118, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_GPRS, 48, 40, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_GPRS, 48, 40, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_UMTS, 384, 64, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_UMTS, 384, 64, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSDPA, 14400, -1, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSDPA, 14400, UNKNOWN, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSUPA, 14400, 5760, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSUPA, 14400, 5760, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSPA, 14400, 5760, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSPA, 14400, 5760, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSPAP, 21000, 5760, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_HSPAP, 21000, 5760, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_CDMA, -1, -1, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_CDMA, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_1xRTT, -1, -1, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_1xRTT, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_0, 2468, 153, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_0, 2468, 153, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_A, 3072, 1800, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_A, 3072, 1800, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_B, 14700, 1800, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EVDO_B, 14700, 1800, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_IDEN, -1, -1, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_IDEN, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_LTE, 100000, 50000, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_LTE, 100000, 50000, UNKNOWN),
|
||||||
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EHRPD, -1, -1, -1),
|
new NetworkDataEntry(TelephonyManager.NETWORK_TYPE_EHRPD, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static NetworkDataEntry getNetworkDataEntry(int networkType) {
|
private static NetworkDataEntry getNetworkDataEntry(int networkType) {
|
||||||
@@ -886,10 +888,10 @@ public class MobileDataStateTracker extends BaseNetworkStateTracker {
|
|||||||
case TelephonyManager.NETWORK_TYPE_IDEN:
|
case TelephonyManager.NETWORK_TYPE_IDEN:
|
||||||
case TelephonyManager.NETWORK_TYPE_EHRPD:
|
case TelephonyManager.NETWORK_TYPE_EHRPD:
|
||||||
default:
|
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;
|
SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
286
core/java/android/net/MobileLinkQualityInfo.java
Normal file
286
core/java/android/net/MobileLinkQualityInfo.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -122,7 +122,7 @@ public interface NetworkStateTracker {
|
|||||||
* Get interesting information about this network link
|
* Get interesting information about this network link
|
||||||
* @return a copy of link information, null if not available
|
* @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
|
* Return the system properties name associated with the tcp buffer sizes
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public class SamplingDataTracker
|
|||||||
if (mBeginningSample != null && mEndingSample != null) {
|
if (mBeginningSample != null && mEndingSample != null) {
|
||||||
return mEndingSample.mTxByteCount - mBeginningSample.mTxByteCount;
|
return mEndingSample.mTxByteCount - mBeginningSample.mTxByteCount;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ public class SamplingDataTracker
|
|||||||
if (mBeginningSample != null && mEndingSample != null) {
|
if (mBeginningSample != null && mEndingSample != null) {
|
||||||
return mEndingSample.mTxPacketCount - mBeginningSample.mTxPacketCount;
|
return mEndingSample.mTxPacketCount - mBeginningSample.mTxPacketCount;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@ public class SamplingDataTracker
|
|||||||
if (mBeginningSample != null && mEndingSample != null) {
|
if (mBeginningSample != null && mEndingSample != null) {
|
||||||
return mEndingSample.mTxPacketErrorCount - mBeginningSample.mTxPacketErrorCount;
|
return mEndingSample.mTxPacketErrorCount - mBeginningSample.mTxPacketErrorCount;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ public class SamplingDataTracker
|
|||||||
if (mBeginningSample != null && mEndingSample != null) {
|
if (mBeginningSample != null && mEndingSample != null) {
|
||||||
return mEndingSample.mRxByteCount - mBeginningSample.mRxByteCount;
|
return mEndingSample.mRxByteCount - mBeginningSample.mRxByteCount;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ public class SamplingDataTracker
|
|||||||
if (mBeginningSample != null && mEndingSample != null) {
|
if (mBeginningSample != null && mEndingSample != null) {
|
||||||
return mEndingSample.mRxPacketCount - mBeginningSample.mRxPacketCount;
|
return mEndingSample.mRxPacketCount - mBeginningSample.mRxPacketCount;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ public class SamplingDataTracker
|
|||||||
long txPacketCount = end.mTxPacketCount - begin.mTxPacketCount;
|
long txPacketCount = end.mTxPacketCount - begin.mTxPacketCount;
|
||||||
return rxPacketCount + txPacketCount;
|
return rxPacketCount + txPacketCount;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ public class SamplingDataTracker
|
|||||||
long txPacketErrorCount = getSampledTxPacketErrorCount();
|
long txPacketErrorCount = getSampledTxPacketErrorCount();
|
||||||
return rxPacketErrorCount + txPacketErrorCount;
|
return rxPacketErrorCount + txPacketErrorCount;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ public class SamplingDataTracker
|
|||||||
if (mBeginningSample != null && mEndingSample != null) {
|
if (mBeginningSample != null && mEndingSample != null) {
|
||||||
return mEndingSample.mRxPacketErrorCount - mBeginningSample.mRxPacketErrorCount;
|
return mEndingSample.mRxPacketErrorCount - mBeginningSample.mRxPacketErrorCount;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,7 +273,7 @@ public class SamplingDataTracker
|
|||||||
if (mEndingSample != null) {
|
if (mEndingSample != null) {
|
||||||
return mEndingSample.mTimestamp;
|
return mEndingSample.mTimestamp;
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,17 +283,17 @@ public class SamplingDataTracker
|
|||||||
if (mBeginningSample != null && mEndingSample != null) {
|
if (mBeginningSample != null && mEndingSample != null) {
|
||||||
return (int) (mEndingSample.mTimestamp - mBeginningSample.mTimestamp);
|
return (int) (mEndingSample.mTimestamp - mBeginningSample.mTimestamp);
|
||||||
} else {
|
} else {
|
||||||
return LinkInfo.UNKNOWN;
|
return LinkQualityInfo.UNKNOWN_INT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommonLinkInfoFields(LinkInfo li) {
|
public void setCommonLinkQualityInfoFields(LinkQualityInfo li) {
|
||||||
synchronized(mSamplingDataLock) {
|
synchronized(mSamplingDataLock) {
|
||||||
li.mLastDataSampleTime = getSampleTimestamp();
|
li.setLastDataSampleTime(getSampleTimestamp());
|
||||||
li.mDataSampleDuration = getSampleDuration();
|
li.setDataSampleDuration(getSampleDuration());
|
||||||
li.mPacketCount = getSampledPacketCount();
|
li.setPacketCount(getSampledPacketCount());
|
||||||
li.mPacketErrorCount = getSampledPacketErrorCount();
|
li.setPacketErrorCount(getSampledPacketErrorCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
149
core/java/android/net/WifiLinkQualityInfo.java
Normal file
149
core/java/android/net/WifiLinkQualityInfo.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,7 +58,7 @@ import android.net.INetworkPolicyManager;
|
|||||||
import android.net.INetworkStatsService;
|
import android.net.INetworkStatsService;
|
||||||
import android.net.LinkAddress;
|
import android.net.LinkAddress;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.LinkInfo;
|
import android.net.LinkQualityInfo;
|
||||||
import android.net.LinkProperties.CompareResult;
|
import android.net.LinkProperties.CompareResult;
|
||||||
import android.net.MobileDataStateTracker;
|
import android.net.MobileDataStateTracker;
|
||||||
import android.net.NetworkConfig;
|
import android.net.NetworkConfig;
|
||||||
@@ -4689,39 +4689,39 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkInfo getLinkInfo(int networkType) {
|
public LinkQualityInfo getLinkQualityInfo(int networkType) {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
if (isNetworkTypeValid(networkType)) {
|
if (isNetworkTypeValid(networkType)) {
|
||||||
return mNetTrackers[networkType].getLinkInfo();
|
return mNetTrackers[networkType].getLinkQualityInfo();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkInfo getActiveLinkInfo() {
|
public LinkQualityInfo getActiveLinkQualityInfo() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
if (isNetworkTypeValid(mActiveDefaultNetwork)) {
|
if (isNetworkTypeValid(mActiveDefaultNetwork)) {
|
||||||
return mNetTrackers[mActiveDefaultNetwork].getLinkInfo();
|
return mNetTrackers[mActiveDefaultNetwork].getLinkQualityInfo();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkInfo[] getAllLinkInfo() {
|
public LinkQualityInfo[] getAllLinkQualityInfo() {
|
||||||
enforceAccessPermission();
|
enforceAccessPermission();
|
||||||
final ArrayList<LinkInfo> result = Lists.newArrayList();
|
final ArrayList<LinkQualityInfo> result = Lists.newArrayList();
|
||||||
for (NetworkStateTracker tracker : mNetTrackers) {
|
for (NetworkStateTracker tracker : mNetTrackers) {
|
||||||
if (tracker != null) {
|
if (tracker != null) {
|
||||||
LinkInfo li = tracker.getLinkInfo();
|
LinkQualityInfo li = tracker.getLinkQualityInfo();
|
||||||
if (li != null) {
|
if (li != null) {
|
||||||
result.add(li);
|
result.add(li);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.toArray(new LinkInfo[result.size()]);
|
return result.toArray(new LinkQualityInfo[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Infrastructure for network sampling */
|
/* Infrastructure for network sampling */
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.net.BaseNetworkStateTracker;
|
import android.net.BaseNetworkStateTracker;
|
||||||
import android.net.LinkCapabilities;
|
import android.net.LinkCapabilities;
|
||||||
import android.net.LinkInfo;
|
import android.net.LinkQualityInfo;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.NetworkInfo.DetailedState;
|
import android.net.NetworkInfo.DetailedState;
|
||||||
import android.net.SamplingDataTracker;
|
import android.net.SamplingDataTracker;
|
||||||
import android.net.WifiLinkInfo;
|
import android.net.WifiLinkQualityInfo;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
@@ -203,35 +203,35 @@ public class WifiStateTracker extends BaseNetworkStateTracker {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return link info
|
* Return link info
|
||||||
* @return an object of type WifiLinkInfo
|
* @return an object of type WifiLinkQualityInfo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LinkInfo getLinkInfo() {
|
public LinkQualityInfo getLinkQualityInfo() {
|
||||||
if (mNetworkInfo == null) {
|
if (mNetworkInfo == null) {
|
||||||
// no data available yet; just return
|
// no data available yet; just return
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiLinkInfo li = new WifiLinkInfo();
|
WifiLinkQualityInfo li = new WifiLinkQualityInfo();
|
||||||
li.mNetworkType = mNetworkInfo.getType();
|
li.setNetworkType(mNetworkInfo.getType());
|
||||||
|
|
||||||
synchronized(mSamplingDataTracker.mSamplingDataLock) {
|
synchronized(mSamplingDataTracker.mSamplingDataLock) {
|
||||||
mSamplingDataTracker.setCommonLinkInfoFields(li);
|
mSamplingDataTracker.setCommonLinkQualityInfoFields(li);
|
||||||
li.mTxGood = mSamplingDataTracker.getSampledTxPacketCount();
|
li.setTxGood(mSamplingDataTracker.getSampledTxPacketCount());
|
||||||
li.mTxBad = mSamplingDataTracker.getSampledTxPacketErrorCount();
|
li.setTxBad(mSamplingDataTracker.getSampledTxPacketErrorCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
// li.setTheoreticalRxBandwidth(??);
|
// li.setTheoreticalRxBandwidth(??);
|
||||||
// li.setTheoreticalTxBandwidth(??);
|
// li.setTheoreticalTxBandwidth(??);
|
||||||
|
|
||||||
if (mWifiInfo != null) {
|
if (mWifiInfo != null) {
|
||||||
li.mBssid = mWifiInfo.getBSSID();
|
li.setBssid(mWifiInfo.getBSSID());
|
||||||
|
|
||||||
int rssi = mWifiInfo.getRssi();
|
int rssi = mWifiInfo.getRssi();
|
||||||
li.mRssi = rssi;
|
li.setRssi(rssi);
|
||||||
|
|
||||||
li.mNormalizedSignalStrength = mWifiManager.calculateSignalLevel(rssi,
|
li.setNormalizedSignalStrength(mWifiManager.calculateSignalLevel(rssi,
|
||||||
LinkInfo.NORMALIZED_SIGNAL_STRENGTH_RANGE);
|
LinkQualityInfo.NORMALIZED_SIGNAL_STRENGTH_RANGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
return li;
|
return li;
|
||||||
|
|||||||
Reference in New Issue
Block a user