| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.hardware.location; |
| 17 |
|
| 18 |
import android.annotation.NonNull; |
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.annotation.SystemApi; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
@SystemApi |
| 40 |
public final class NanoAppRpcService implements Parcelable { |
| 41 |
private long mServiceId; |
| 42 |
|
| 43 |
private int mServiceVersion; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public NanoAppRpcService(long serviceId, int serviceVersion) { |
| 50 |
mServiceId = serviceId; |
| 51 |
mServiceVersion = serviceVersion; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public long getId() { |
| 65 |
return mServiceId; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public int getVersion() { |
| 79 |
return mServiceVersion; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
private int getMajorVersion() { |
| 86 |
return (mServiceVersion & 0xFF000000) >>> 24; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
private int getMinorVersion() { |
| 93 |
return (mServiceVersion & 0x00FF0000) >>> 16; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
private int getPatchVersion() { |
| 100 |
return mServiceVersion & 0x0000FFFF; |
| 101 |
} |
| 102 |
|
| 103 |
private NanoAppRpcService(Parcel in) { |
| 104 |
mServiceId = in.readLong(); |
| 105 |
mServiceVersion = in.readInt(); |
| 106 |
} |
| 107 |
|
| 108 |
@Override |
| 109 |
public int describeContents() { |
| 110 |
return 0; |
| 111 |
} |
| 112 |
|
| 113 |
@Override |
| 114 |
public void writeToParcel(@NonNull Parcel out, int flags) { |
| 115 |
out.writeLong(mServiceId); |
| 116 |
out.writeInt(mServiceVersion); |
| 117 |
} |
| 118 |
|
| 119 |
public static final @NonNull Creator<NanoAppRpcService> CREATOR = |
| 120 |
new Creator<NanoAppRpcService>() { |
| 121 |
@Override |
| 122 |
public NanoAppRpcService createFromParcel(Parcel in) { |
| 123 |
return new NanoAppRpcService(in); |
| 124 |
} |
| 125 |
|
| 126 |
@Override |
| 127 |
public NanoAppRpcService[] newArray(int size) { |
| 128 |
return new NanoAppRpcService[size]; |
| 129 |
} |
| 130 |
}; |
| 131 |
|
| 132 |
@NonNull |
| 133 |
@Override |
| 134 |
public String toString() { |
| 135 |
return "NanoAppRpcService[Id = " + Long.toHexString(mServiceId) + ", version = v" |
| 136 |
+ getMajorVersion() + "." + getMinorVersion() + "." + getPatchVersion() + "]"; |
| 137 |
} |
| 138 |
|
| 139 |
@Override |
| 140 |
public boolean equals(@Nullable Object object) { |
| 141 |
if (object == this) { |
| 142 |
return true; |
| 143 |
} |
| 144 |
|
| 145 |
boolean isEqual = false; |
| 146 |
if (object instanceof NanoAppRpcService) { |
| 147 |
NanoAppRpcService other = (NanoAppRpcService) object; |
| 148 |
isEqual = (other.getId() == mServiceId) |
| 149 |
&& (other.getVersion() == mServiceVersion); |
| 150 |
} |
| 151 |
|
| 152 |
return isEqual; |
| 153 |
} |
| 154 |
|
| 155 |
@Override |
| 156 |
public int hashCode() { |
| 157 |
return (int) getId(); |
| 158 |
} |
| 159 |
} |