| 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.IntDef; |
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.Nullable; |
| 22 |
import android.annotation.SystemApi; |
| 23 |
import android.os.Parcel; |
| 24 |
import android.os.Parcelable; |
| 25 |
import android.util.SparseArray; |
| 26 |
|
| 27 |
import com.android.internal.util.MessageUtils; |
| 28 |
|
| 29 |
import java.lang.annotation.Retention; |
| 30 |
import java.lang.annotation.RetentionPolicy; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
@Deprecated |
| 41 |
@SystemApi |
| 42 |
public final class IpManagerEvent implements IpConnectivityLog.Event { |
| 43 |
|
| 44 |
public static final int PROVISIONING_OK = 1; |
| 45 |
public static final int PROVISIONING_FAIL = 2; |
| 46 |
public static final int COMPLETE_LIFECYCLE = 3; |
| 47 |
public static final int ERROR_STARTING_IPV4 = 4; |
| 48 |
public static final int ERROR_STARTING_IPV6 = 5; |
| 49 |
public static final int ERROR_STARTING_IPREACHABILITYMONITOR = 6; |
| 50 |
public static final int ERROR_INVALID_PROVISIONING = 7; |
| 51 |
public static final int ERROR_INTERFACE_NOT_FOUND = 8; |
| 52 |
|
| 53 |
|
| 54 |
@IntDef(value = { |
| 55 |
PROVISIONING_OK, PROVISIONING_FAIL, COMPLETE_LIFECYCLE, |
| 56 |
ERROR_STARTING_IPV4, ERROR_STARTING_IPV6, ERROR_STARTING_IPREACHABILITYMONITOR, |
| 57 |
ERROR_INVALID_PROVISIONING, ERROR_INTERFACE_NOT_FOUND, |
| 58 |
}) |
| 59 |
@Retention(RetentionPolicy.SOURCE) |
| 60 |
public @interface EventType {} |
| 61 |
|
| 62 |
|
| 63 |
public final @EventType int eventType; |
| 64 |
|
| 65 |
public final long durationMs; |
| 66 |
|
| 67 |
public IpManagerEvent(@EventType int eventType, long duration) { |
| 68 |
this.eventType = eventType; |
| 69 |
this.durationMs = duration; |
| 70 |
} |
| 71 |
|
| 72 |
private IpManagerEvent(Parcel in) { |
| 73 |
this.eventType = in.readInt(); |
| 74 |
this.durationMs = in.readLong(); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
@Override |
| 79 |
public void writeToParcel(Parcel out, int flags) { |
| 80 |
out.writeInt(eventType); |
| 81 |
out.writeLong(durationMs); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
@Override |
| 86 |
public int describeContents() { |
| 87 |
return 0; |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
public static final @android.annotation.NonNull Parcelable.Creator<IpManagerEvent> CREATOR |
| 92 |
= new Parcelable.Creator<IpManagerEvent>() { |
| 93 |
public IpManagerEvent createFromParcel(Parcel in) { |
| 94 |
return new IpManagerEvent(in); |
| 95 |
} |
| 96 |
|
| 97 |
public IpManagerEvent[] newArray(int size) { |
| 98 |
return new IpManagerEvent[size]; |
| 99 |
} |
| 100 |
}; |
| 101 |
|
| 102 |
@NonNull |
| 103 |
@Override |
| 104 |
public String toString() { |
| 105 |
return String.format("IpManagerEvent(%s, %dms)", |
| 106 |
Decoder.constants.get(eventType), durationMs); |
| 107 |
} |
| 108 |
|
| 109 |
@Override |
| 110 |
public boolean equals(@Nullable Object obj) { |
| 111 |
if (obj == null || !(obj.getClass().equals(IpManagerEvent.class))) return false; |
| 112 |
final IpManagerEvent other = (IpManagerEvent) obj; |
| 113 |
return eventType == other.eventType |
| 114 |
&& durationMs == other.durationMs; |
| 115 |
} |
| 116 |
|
| 117 |
final static class Decoder { |
| 118 |
static final SparseArray<String> constants = MessageUtils.findMessageNames( |
| 119 |
new Class[]{IpManagerEvent.class}, |
| 120 |
new String[]{"PROVISIONING_", "COMPLETE_", "ERROR_"}); |
| 121 |
} |
| 122 |
} |