| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.net; |
| 18 |
|
| 19 |
import android.compat.annotation.UnsupportedAppUsage; |
| 20 |
import android.os.Build; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public class LinkQualityInfo implements Parcelable { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public static final int UNKNOWN_INT = Integer.MAX_VALUE; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public static final long UNKNOWN_LONG = Long.MAX_VALUE; |
| 44 |
|
| 45 |
public static final int NORMALIZED_MIN_SIGNAL_STRENGTH = 0; |
| 46 |
|
| 47 |
public static final int NORMALIZED_MAX_SIGNAL_STRENGTH = 99; |
| 48 |
|
| 49 |
public static final int NORMALIZED_SIGNAL_STRENGTH_RANGE = |
| 50 |
NORMALIZED_MAX_SIGNAL_STRENGTH - NORMALIZED_MIN_SIGNAL_STRENGTH + 1; |
| 51 |
|
| 52 |
|
| 53 |
private int mNetworkType = ConnectivityManager.TYPE_NONE; |
| 54 |
|
| 55 |
private int mNormalizedSignalStrength = UNKNOWN_INT; |
| 56 |
|
| 57 |
private long mPacketCount = UNKNOWN_LONG; |
| 58 |
private long mPacketErrorCount = UNKNOWN_LONG; |
| 59 |
private int mTheoreticalTxBandwidth = UNKNOWN_INT; |
| 60 |
private int mTheoreticalRxBandwidth = UNKNOWN_INT; |
| 61 |
private int mTheoreticalLatency = UNKNOWN_INT; |
| 62 |
|
| 63 |
|
| 64 |
private long mLastDataSampleTime = UNKNOWN_LONG; |
| 65 |
|
| 66 |
|
| 67 |
private int mDataSampleDuration = UNKNOWN_INT; |
| 68 |
|
| 69 |
public LinkQualityInfo() { |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
public int describeContents() { |
| 78 |
return 0; |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
protected static final int OBJECT_TYPE_LINK_QUALITY_INFO = 1; |
| 86 |
protected static final int OBJECT_TYPE_WIFI_LINK_QUALITY_INFO = 2; |
| 87 |
protected static final int OBJECT_TYPE_MOBILE_LINK_QUALITY_INFO = 3; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public void writeToParcel(Parcel dest, int flags) { |
| 93 |
writeToParcel(dest, flags, OBJECT_TYPE_LINK_QUALITY_INFO); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
public void writeToParcel(Parcel dest, int flags, int objectType) { |
| 100 |
dest.writeInt(objectType); |
| 101 |
dest.writeInt(mNetworkType); |
| 102 |
dest.writeInt(mNormalizedSignalStrength); |
| 103 |
dest.writeLong(mPacketCount); |
| 104 |
dest.writeLong(mPacketErrorCount); |
| 105 |
dest.writeInt(mTheoreticalTxBandwidth); |
| 106 |
dest.writeInt(mTheoreticalRxBandwidth); |
| 107 |
dest.writeInt(mTheoreticalLatency); |
| 108 |
dest.writeLong(mLastDataSampleTime); |
| 109 |
dest.writeInt(mDataSampleDuration); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
public static final @android.annotation.NonNull Creator<LinkQualityInfo> CREATOR = |
| 116 |
new Creator<LinkQualityInfo>() { |
| 117 |
public LinkQualityInfo createFromParcel(Parcel in) { |
| 118 |
int objectType = in.readInt(); |
| 119 |
if (objectType == OBJECT_TYPE_LINK_QUALITY_INFO) { |
| 120 |
LinkQualityInfo li = new LinkQualityInfo(); |
| 121 |
li.initializeFromParcel(in); |
| 122 |
return li; |
| 123 |
} else if (objectType == OBJECT_TYPE_WIFI_LINK_QUALITY_INFO) { |
| 124 |
return WifiLinkQualityInfo.createFromParcelBody(in); |
| 125 |
} else if (objectType == OBJECT_TYPE_MOBILE_LINK_QUALITY_INFO) { |
| 126 |
return MobileLinkQualityInfo.createFromParcelBody(in); |
| 127 |
} else { |
| 128 |
return null; |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
public LinkQualityInfo[] newArray(int size) { |
| 133 |
return new LinkQualityInfo[size]; |
| 134 |
} |
| 135 |
}; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
protected void initializeFromParcel(Parcel in) { |
| 141 |
mNetworkType = in.readInt(); |
| 142 |
mNormalizedSignalStrength = in.readInt(); |
| 143 |
mPacketCount = in.readLong(); |
| 144 |
mPacketErrorCount = in.readLong(); |
| 145 |
mTheoreticalTxBandwidth = in.readInt(); |
| 146 |
mTheoreticalRxBandwidth = in.readInt(); |
| 147 |
mTheoreticalLatency = in.readInt(); |
| 148 |
mLastDataSampleTime = in.readLong(); |
| 149 |
mDataSampleDuration = in.readInt(); |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
public int getNetworkType() { |
| 158 |
return mNetworkType; |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
public void setNetworkType(int networkType) { |
| 165 |
mNetworkType = networkType; |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
public int getNormalizedSignalStrength() { |
| 173 |
return mNormalizedSignalStrength; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
public void setNormalizedSignalStrength(int normalizedSignalStrength) { |
| 180 |
mNormalizedSignalStrength = normalizedSignalStrength; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
public long getPacketCount() { |
| 188 |
return mPacketCount; |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 195 |
public void setPacketCount(long packetCount) { |
| 196 |
mPacketCount = packetCount; |
| 197 |
} |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
public long getPacketErrorCount() { |
| 204 |
return mPacketErrorCount; |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 211 |
public void setPacketErrorCount(long packetErrorCount) { |
| 212 |
mPacketErrorCount = packetErrorCount; |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
public int getTheoreticalTxBandwidth() { |
| 220 |
return mTheoreticalTxBandwidth; |
| 221 |
} |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
public void setTheoreticalTxBandwidth(int theoreticalTxBandwidth) { |
| 227 |
mTheoreticalTxBandwidth = theoreticalTxBandwidth; |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
public int getTheoreticalRxBandwidth() { |
| 235 |
return mTheoreticalRxBandwidth; |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
public void setTheoreticalRxBandwidth(int theoreticalRxBandwidth) { |
| 242 |
mTheoreticalRxBandwidth = theoreticalRxBandwidth; |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
public int getTheoreticalLatency() { |
| 250 |
return mTheoreticalLatency; |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
public void setTheoreticalLatency(int theoreticalLatency) { |
| 257 |
mTheoreticalLatency = theoreticalLatency; |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
public long getLastDataSampleTime() { |
| 266 |
return mLastDataSampleTime; |
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 273 |
public void setLastDataSampleTime(long lastDataSampleTime) { |
| 274 |
mLastDataSampleTime = lastDataSampleTime; |
| 275 |
} |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
public int getDataSampleDuration() { |
| 282 |
return mDataSampleDuration; |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 289 |
public void setDataSampleDuration(int dataSampleDuration) { |
| 290 |
mDataSampleDuration = dataSampleDuration; |
| 291 |
} |
| 292 |
} |