| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.net.metrics; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.SystemApi; |
| 22 |
import android.compat.annotation.UnsupportedAppUsage; |
| 23 |
import android.os.Build; |
| 24 |
import android.os.Parcel; |
| 25 |
import android.os.Parcelable; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
@Deprecated |
| 35 |
@SystemApi |
| 36 |
public final class ApfStats implements IpConnectivityLog.Event { |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 43 |
public final long durationMs; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 49 |
public final int receivedRas; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 55 |
public final int matchingRas; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 61 |
public final int droppedRas; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 67 |
public final int zeroLifetimeRas; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 73 |
public final int parseErrors; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 79 |
public final int programUpdates; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 85 |
public final int programUpdatesAll; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 91 |
public final int programUpdatesAllowingMulticast; |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 97 |
public final int maxProgramSize; |
| 98 |
|
| 99 |
private ApfStats(Parcel in) { |
| 100 |
this.durationMs = in.readLong(); |
| 101 |
this.receivedRas = in.readInt(); |
| 102 |
this.matchingRas = in.readInt(); |
| 103 |
this.droppedRas = in.readInt(); |
| 104 |
this.zeroLifetimeRas = in.readInt(); |
| 105 |
this.parseErrors = in.readInt(); |
| 106 |
this.programUpdates = in.readInt(); |
| 107 |
this.programUpdatesAll = in.readInt(); |
| 108 |
this.programUpdatesAllowingMulticast = in.readInt(); |
| 109 |
this.maxProgramSize = in.readInt(); |
| 110 |
} |
| 111 |
|
| 112 |
private ApfStats(long durationMs, int receivedRas, int matchingRas, int droppedRas, |
| 113 |
int zeroLifetimeRas, int parseErrors, int programUpdates, int programUpdatesAll, |
| 114 |
int programUpdatesAllowingMulticast, int maxProgramSize) { |
| 115 |
this.durationMs = durationMs; |
| 116 |
this.receivedRas = receivedRas; |
| 117 |
this.matchingRas = matchingRas; |
| 118 |
this.droppedRas = droppedRas; |
| 119 |
this.zeroLifetimeRas = zeroLifetimeRas; |
| 120 |
this.parseErrors = parseErrors; |
| 121 |
this.programUpdates = programUpdates; |
| 122 |
this.programUpdatesAll = programUpdatesAll; |
| 123 |
this.programUpdatesAllowingMulticast = programUpdatesAllowingMulticast; |
| 124 |
this.maxProgramSize = maxProgramSize; |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
@SystemApi |
| 132 |
public static final class Builder { |
| 133 |
private long mDurationMs; |
| 134 |
private int mReceivedRas; |
| 135 |
private int mMatchingRas; |
| 136 |
private int mDroppedRas; |
| 137 |
private int mZeroLifetimeRas; |
| 138 |
private int mParseErrors; |
| 139 |
private int mProgramUpdates; |
| 140 |
private int mProgramUpdatesAll; |
| 141 |
private int mProgramUpdatesAllowingMulticast; |
| 142 |
private int mMaxProgramSize; |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
@NonNull |
| 148 |
public Builder setDurationMs(long durationMs) { |
| 149 |
mDurationMs = durationMs; |
| 150 |
return this; |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
@NonNull |
| 157 |
public Builder setReceivedRas(int receivedRas) { |
| 158 |
mReceivedRas = receivedRas; |
| 159 |
return this; |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
@NonNull |
| 166 |
public Builder setMatchingRas(int matchingRas) { |
| 167 |
mMatchingRas = matchingRas; |
| 168 |
return this; |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
@NonNull |
| 175 |
public Builder setDroppedRas(int droppedRas) { |
| 176 |
mDroppedRas = droppedRas; |
| 177 |
return this; |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
@NonNull |
| 184 |
public Builder setZeroLifetimeRas(int zeroLifetimeRas) { |
| 185 |
mZeroLifetimeRas = zeroLifetimeRas; |
| 186 |
return this; |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
@NonNull |
| 193 |
public Builder setParseErrors(int parseErrors) { |
| 194 |
mParseErrors = parseErrors; |
| 195 |
return this; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
@NonNull |
| 202 |
public Builder setProgramUpdates(int programUpdates) { |
| 203 |
mProgramUpdates = programUpdates; |
| 204 |
return this; |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
@NonNull |
| 211 |
public Builder setProgramUpdatesAll(int programUpdatesAll) { |
| 212 |
mProgramUpdatesAll = programUpdatesAll; |
| 213 |
return this; |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
@NonNull |
| 220 |
public Builder setProgramUpdatesAllowingMulticast(int programUpdatesAllowingMulticast) { |
| 221 |
mProgramUpdatesAllowingMulticast = programUpdatesAllowingMulticast; |
| 222 |
return this; |
| 223 |
} |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
@NonNull |
| 229 |
public Builder setMaxProgramSize(int maxProgramSize) { |
| 230 |
mMaxProgramSize = maxProgramSize; |
| 231 |
return this; |
| 232 |
} |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
@NonNull |
| 238 |
public ApfStats build() { |
| 239 |
return new ApfStats(mDurationMs, mReceivedRas, mMatchingRas, mDroppedRas, |
| 240 |
mZeroLifetimeRas, mParseErrors, mProgramUpdates, mProgramUpdatesAll, |
| 241 |
mProgramUpdatesAllowingMulticast, mMaxProgramSize); |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
@Override |
| 247 |
public void writeToParcel(Parcel out, int flags) { |
| 248 |
out.writeLong(durationMs); |
| 249 |
out.writeInt(receivedRas); |
| 250 |
out.writeInt(matchingRas); |
| 251 |
out.writeInt(droppedRas); |
| 252 |
out.writeInt(zeroLifetimeRas); |
| 253 |
out.writeInt(parseErrors); |
| 254 |
out.writeInt(programUpdates); |
| 255 |
out.writeInt(programUpdatesAll); |
| 256 |
out.writeInt(programUpdatesAllowingMulticast); |
| 257 |
out.writeInt(maxProgramSize); |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
@Override |
| 262 |
public int describeContents() { |
| 263 |
return 0; |
| 264 |
} |
| 265 |
|
| 266 |
@NonNull |
| 267 |
@Override |
| 268 |
public String toString() { |
| 269 |
return new StringBuilder("ApfStats(") |
| 270 |
.append(String.format("%dms ", durationMs)) |
| 271 |
.append(String.format("%dB RA: {", maxProgramSize)) |
| 272 |
.append(String.format("%d received, ", receivedRas)) |
| 273 |
.append(String.format("%d matching, ", matchingRas)) |
| 274 |
.append(String.format("%d dropped, ", droppedRas)) |
| 275 |
.append(String.format("%d zero lifetime, ", zeroLifetimeRas)) |
| 276 |
.append(String.format("%d parse errors}, ", parseErrors)) |
| 277 |
.append(String.format("updates: {all: %d, RAs: %d, allow multicast: %d})", |
| 278 |
programUpdatesAll, programUpdates, programUpdatesAllowingMulticast)) |
| 279 |
.toString(); |
| 280 |
} |
| 281 |
|
| 282 |
@Override |
| 283 |
public boolean equals(@Nullable Object obj) { |
| 284 |
if (obj == null || !(obj.getClass().equals(ApfStats.class))) return false; |
| 285 |
final ApfStats other = (ApfStats) obj; |
| 286 |
return durationMs == other.durationMs |
| 287 |
&& receivedRas == other.receivedRas |
| 288 |
&& matchingRas == other.matchingRas |
| 289 |
&& droppedRas == other.droppedRas |
| 290 |
&& zeroLifetimeRas == other.zeroLifetimeRas |
| 291 |
&& parseErrors == other.parseErrors |
| 292 |
&& programUpdates == other.programUpdates |
| 293 |
&& programUpdatesAll == other.programUpdatesAll |
| 294 |
&& programUpdatesAllowingMulticast == other.programUpdatesAllowingMulticast |
| 295 |
&& maxProgramSize == other.maxProgramSize; |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
public static final @android.annotation.NonNull Parcelable.Creator<ApfStats> CREATOR = new Parcelable.Creator<ApfStats>() { |
| 300 |
public ApfStats createFromParcel(Parcel in) { |
| 301 |
return new ApfStats(in); |
| 302 |
} |
| 303 |
|
| 304 |
public ApfStats[] newArray(int size) { |
| 305 |
return new ApfStats[size]; |
| 306 |
} |
| 307 |
}; |
| 308 |
} |