| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.os; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.compat.annotation.UnsupportedAppUsage; |
| 21 |
|
| 22 |
import java.util.UUID; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public final class ParcelUuid implements Parcelable { |
| 30 |
|
| 31 |
private final UUID mUuid; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public ParcelUuid(UUID uuid) { |
| 40 |
mUuid = uuid; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public static ParcelUuid fromString(String uuid) { |
| 55 |
return new ParcelUuid(UUID.fromString(uuid)); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
public UUID getUuid() { |
| 64 |
return mUuid; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
@Override |
| 74 |
public String toString() { |
| 75 |
return mUuid.toString(); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
@Override |
| 80 |
public int hashCode() { |
| 81 |
return mUuid.hashCode(); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
@Override |
| 95 |
public boolean equals(@Nullable Object object) { |
| 96 |
if (object == null) { |
| 97 |
return false; |
| 98 |
} |
| 99 |
|
| 100 |
if (this == object) { |
| 101 |
return true; |
| 102 |
} |
| 103 |
|
| 104 |
if (!(object instanceof ParcelUuid)) { |
| 105 |
return false; |
| 106 |
} |
| 107 |
|
| 108 |
ParcelUuid that = (ParcelUuid) object; |
| 109 |
|
| 110 |
return (this.mUuid.equals(that.mUuid)); |
| 111 |
} |
| 112 |
|
| 113 |
public static final @android.annotation.NonNull Parcelable.Creator<ParcelUuid> CREATOR = |
| 114 |
new Parcelable.Creator<ParcelUuid>() { |
| 115 |
@UnsupportedAppUsage |
| 116 |
public ParcelUuid createFromParcel(Parcel source) { |
| 117 |
long mostSigBits = source.readLong(); |
| 118 |
long leastSigBits = source.readLong(); |
| 119 |
UUID uuid = new UUID(mostSigBits, leastSigBits); |
| 120 |
return new ParcelUuid(uuid); |
| 121 |
} |
| 122 |
|
| 123 |
public ParcelUuid[] newArray(int size) { |
| 124 |
return new ParcelUuid[size]; |
| 125 |
} |
| 126 |
}; |
| 127 |
|
| 128 |
public int describeContents() { |
| 129 |
return 0; |
| 130 |
} |
| 131 |
|
| 132 |
public void writeToParcel(Parcel dest, int flags) { |
| 133 |
dest.writeLong(mUuid.getMostSignificantBits()); |
| 134 |
dest.writeLong(mUuid.getLeastSignificantBits()); |
| 135 |
} |
| 136 |
} |