| 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.hardware.contexthub.V1_0.ContextHub; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
import android.util.proto.ProtoOutputStream; |
| 25 |
|
| 26 |
import java.util.Arrays; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
@SystemApi |
| 32 |
public class ContextHubInfo implements Parcelable { |
| 33 |
private int mId; |
| 34 |
private String mName; |
| 35 |
private String mVendor; |
| 36 |
private String mToolchain; |
| 37 |
private int mPlatformVersion; |
| 38 |
private int mToolchainVersion; |
| 39 |
private float mPeakMips; |
| 40 |
private float mStoppedPowerDrawMw; |
| 41 |
private float mSleepPowerDrawMw; |
| 42 |
private float mPeakPowerDrawMw; |
| 43 |
private int mMaxPacketLengthBytes; |
| 44 |
private byte mChreApiMajorVersion; |
| 45 |
private byte mChreApiMinorVersion; |
| 46 |
private short mChrePatchVersion; |
| 47 |
private long mChrePlatformId; |
| 48 |
|
| 49 |
private int[] mSupportedSensors; |
| 50 |
|
| 51 |
private MemoryRegion[] mMemoryRegions; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
public ContextHubInfo() { |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public ContextHubInfo(ContextHub contextHub) { |
| 63 |
mId = contextHub.hubId; |
| 64 |
mName = contextHub.name; |
| 65 |
mVendor = contextHub.vendor; |
| 66 |
mToolchain = contextHub.toolchain; |
| 67 |
mPlatformVersion = contextHub.platformVersion; |
| 68 |
mToolchainVersion = contextHub.toolchainVersion; |
| 69 |
mPeakMips = contextHub.peakMips; |
| 70 |
mStoppedPowerDrawMw = contextHub.stoppedPowerDrawMw; |
| 71 |
mSleepPowerDrawMw = contextHub.sleepPowerDrawMw; |
| 72 |
mPeakPowerDrawMw = contextHub.peakPowerDrawMw; |
| 73 |
mMaxPacketLengthBytes = contextHub.maxSupportedMsgLen; |
| 74 |
mChrePlatformId = contextHub.chrePlatformId; |
| 75 |
mChreApiMajorVersion = contextHub.chreApiMajorVersion; |
| 76 |
mChreApiMinorVersion = contextHub.chreApiMinorVersion; |
| 77 |
mChrePatchVersion = contextHub.chrePatchVersion; |
| 78 |
|
| 79 |
mSupportedSensors = new int[0]; |
| 80 |
mMemoryRegions = new MemoryRegion[0]; |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
public ContextHubInfo(android.hardware.contexthub.ContextHubInfo contextHub) { |
| 86 |
mId = contextHub.id; |
| 87 |
mName = contextHub.name; |
| 88 |
mVendor = contextHub.vendor; |
| 89 |
mToolchain = contextHub.toolchain; |
| 90 |
mPlatformVersion = 0; |
| 91 |
mToolchainVersion = 0; |
| 92 |
mPeakMips = contextHub.peakMips; |
| 93 |
mStoppedPowerDrawMw = 0; |
| 94 |
mSleepPowerDrawMw = 0; |
| 95 |
mPeakPowerDrawMw = 0; |
| 96 |
mMaxPacketLengthBytes = contextHub.maxSupportedMessageLengthBytes; |
| 97 |
mChrePlatformId = contextHub.chrePlatformId; |
| 98 |
mChreApiMajorVersion = contextHub.chreApiMajorVersion; |
| 99 |
mChreApiMinorVersion = contextHub.chreApiMinorVersion; |
| 100 |
mChrePatchVersion = (short) contextHub.chrePatchVersion; |
| 101 |
|
| 102 |
mSupportedSensors = new int[0]; |
| 103 |
mMemoryRegions = new MemoryRegion[0]; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
public int getMaxPacketLengthBytes() { |
| 113 |
return mMaxPacketLengthBytes; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
public int getId() { |
| 122 |
return mId; |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
public String getName() { |
| 131 |
return mName; |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
public String getVendor() { |
| 140 |
return mVendor; |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
public String getToolchain() { |
| 149 |
return mToolchain; |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
public int getPlatformVersion() { |
| 158 |
return mPlatformVersion; |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
public int getStaticSwVersion() { |
| 167 |
return (mChreApiMajorVersion << 24) | (mChreApiMinorVersion << 16) | (mChrePatchVersion); |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
public int getToolchainVersion() { |
| 176 |
return mToolchainVersion; |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
public float getPeakMips() { |
| 185 |
return mPeakMips; |
| 186 |
} |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
public float getStoppedPowerDrawMw() { |
| 198 |
return mStoppedPowerDrawMw; |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
public float getSleepPowerDrawMw() { |
| 213 |
return mSleepPowerDrawMw; |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
public float getPeakPowerDrawMw() { |
| 223 |
return mPeakPowerDrawMw; |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
public int[] getSupportedSensors() { |
| 234 |
return Arrays.copyOf(mSupportedSensors, mSupportedSensors.length); |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
public MemoryRegion[] getMemoryRegions() { |
| 245 |
return Arrays.copyOf(mMemoryRegions, mMemoryRegions.length); |
| 246 |
} |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
public long getChrePlatformId() { |
| 252 |
return mChrePlatformId; |
| 253 |
} |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
public byte getChreApiMajorVersion() { |
| 259 |
return mChreApiMajorVersion; |
| 260 |
} |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
public byte getChreApiMinorVersion() { |
| 266 |
return mChreApiMinorVersion; |
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
public short getChrePatchVersion() { |
| 273 |
return mChrePatchVersion; |
| 274 |
} |
| 275 |
|
| 276 |
@NonNull |
| 277 |
@Override |
| 278 |
public String toString() { |
| 279 |
String retVal = ""; |
| 280 |
retVal += "ID/handle : " + mId; |
| 281 |
retVal += ", Name : " + mName; |
| 282 |
retVal += "\n\tVendor : " + mVendor; |
| 283 |
retVal += ", Toolchain : " + mToolchain; |
| 284 |
retVal += ", Toolchain version: 0x" + Integer.toHexString(mToolchainVersion); |
| 285 |
retVal += "\n\tPlatformVersion : 0x" + Integer.toHexString(mPlatformVersion); |
| 286 |
retVal += ", SwVersion : " |
| 287 |
+ mChreApiMajorVersion + "." + mChreApiMinorVersion + "." + mChrePatchVersion; |
| 288 |
retVal += ", CHRE platform ID: 0x" + Long.toHexString(mChrePlatformId); |
| 289 |
retVal += "\n\tPeakMips : " + mPeakMips; |
| 290 |
retVal += ", StoppedPowerDraw : " + mStoppedPowerDrawMw + " mW"; |
| 291 |
retVal += ", PeakPowerDraw : " + mPeakPowerDrawMw + " mW"; |
| 292 |
retVal += ", MaxPacketLength : " + mMaxPacketLengthBytes + " Bytes"; |
| 293 |
|
| 294 |
return retVal; |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
public void dump(ProtoOutputStream proto) { |
| 306 |
proto.write(ContextHubInfoProto.ID, mId); |
| 307 |
proto.write(ContextHubInfoProto.NAME, mName); |
| 308 |
proto.write(ContextHubInfoProto.VENDOR, mVendor); |
| 309 |
proto.write(ContextHubInfoProto.TOOLCHAIN, mToolchain); |
| 310 |
proto.write(ContextHubInfoProto.PLATFORM_VERSION, mPlatformVersion); |
| 311 |
proto.write(ContextHubInfoProto.STATIC_SW_VERSION, getStaticSwVersion()); |
| 312 |
proto.write(ContextHubInfoProto.TOOLCHAIN_VERSION, mToolchainVersion); |
| 313 |
proto.write(ContextHubInfoProto.CHRE_PLATFORM_ID, mChrePlatformId); |
| 314 |
proto.write(ContextHubInfoProto.PEAK_MIPS, mPeakMips); |
| 315 |
proto.write(ContextHubInfoProto.STOPPED_POWER_DRAW_MW, mStoppedPowerDrawMw); |
| 316 |
proto.write(ContextHubInfoProto.SLEEP_POWER_DRAW_MW, mSleepPowerDrawMw); |
| 317 |
proto.write(ContextHubInfoProto.PEAK_POWER_DRAW_MW, mPeakPowerDrawMw); |
| 318 |
proto.write(ContextHubInfoProto.MAX_PACKET_LENGTH_BYTES, mMaxPacketLengthBytes); |
| 319 |
} |
| 320 |
|
| 321 |
@Override |
| 322 |
public boolean equals(@Nullable Object object) { |
| 323 |
if (object == this) { |
| 324 |
return true; |
| 325 |
} |
| 326 |
|
| 327 |
boolean isEqual = false; |
| 328 |
if (object instanceof ContextHubInfo) { |
| 329 |
ContextHubInfo other = (ContextHubInfo) object; |
| 330 |
isEqual = (other.getId() == mId) |
| 331 |
&& other.getName().equals(mName) |
| 332 |
&& other.getVendor().equals(mVendor) |
| 333 |
&& other.getToolchain().equals(mToolchain) |
| 334 |
&& (other.getToolchainVersion() == mToolchainVersion) |
| 335 |
&& (other.getStaticSwVersion() == getStaticSwVersion()) |
| 336 |
&& (other.getChrePlatformId() == mChrePlatformId) |
| 337 |
&& (other.getPeakMips() == mPeakMips) |
| 338 |
&& (other.getStoppedPowerDrawMw() == mStoppedPowerDrawMw) |
| 339 |
&& (other.getSleepPowerDrawMw() == mSleepPowerDrawMw) |
| 340 |
&& (other.getPeakPowerDrawMw() == mPeakPowerDrawMw) |
| 341 |
&& (other.getMaxPacketLengthBytes() == mMaxPacketLengthBytes) |
| 342 |
&& Arrays.equals(other.getSupportedSensors(), mSupportedSensors) |
| 343 |
&& Arrays.equals(other.getMemoryRegions(), mMemoryRegions); |
| 344 |
} |
| 345 |
|
| 346 |
return isEqual; |
| 347 |
} |
| 348 |
|
| 349 |
private ContextHubInfo(Parcel in) { |
| 350 |
mId = in.readInt(); |
| 351 |
mName = in.readString(); |
| 352 |
mVendor = in.readString(); |
| 353 |
mToolchain = in.readString(); |
| 354 |
mPlatformVersion = in.readInt(); |
| 355 |
mToolchainVersion = in.readInt(); |
| 356 |
mPeakMips = in.readFloat(); |
| 357 |
mStoppedPowerDrawMw = in.readFloat(); |
| 358 |
mSleepPowerDrawMw = in.readFloat(); |
| 359 |
mPeakPowerDrawMw = in.readFloat(); |
| 360 |
mMaxPacketLengthBytes = in.readInt(); |
| 361 |
mChrePlatformId = in.readLong(); |
| 362 |
mChreApiMajorVersion = in.readByte(); |
| 363 |
mChreApiMinorVersion = in.readByte(); |
| 364 |
mChrePatchVersion = (short) in.readInt(); |
| 365 |
|
| 366 |
int numSupportedSensors = in.readInt(); |
| 367 |
mSupportedSensors = new int[numSupportedSensors]; |
| 368 |
in.readIntArray(mSupportedSensors); |
| 369 |
mMemoryRegions = in.createTypedArray(MemoryRegion.CREATOR); |
| 370 |
} |
| 371 |
|
| 372 |
public int describeContents() { |
| 373 |
return 0; |
| 374 |
} |
| 375 |
|
| 376 |
public void writeToParcel(Parcel out, int flags) { |
| 377 |
out.writeInt(mId); |
| 378 |
out.writeString(mName); |
| 379 |
out.writeString(mVendor); |
| 380 |
out.writeString(mToolchain); |
| 381 |
out.writeInt(mPlatformVersion); |
| 382 |
out.writeInt(mToolchainVersion); |
| 383 |
out.writeFloat(mPeakMips); |
| 384 |
out.writeFloat(mStoppedPowerDrawMw); |
| 385 |
out.writeFloat(mSleepPowerDrawMw); |
| 386 |
out.writeFloat(mPeakPowerDrawMw); |
| 387 |
out.writeInt(mMaxPacketLengthBytes); |
| 388 |
out.writeLong(mChrePlatformId); |
| 389 |
out.writeByte(mChreApiMajorVersion); |
| 390 |
out.writeByte(mChreApiMinorVersion); |
| 391 |
out.writeInt(mChrePatchVersion); |
| 392 |
|
| 393 |
out.writeInt(mSupportedSensors.length); |
| 394 |
out.writeIntArray(mSupportedSensors); |
| 395 |
out.writeTypedArray(mMemoryRegions, flags); |
| 396 |
} |
| 397 |
|
| 398 |
public static final @android.annotation.NonNull Parcelable.Creator<ContextHubInfo> CREATOR |
| 399 |
= new Parcelable.Creator<ContextHubInfo>() { |
| 400 |
public ContextHubInfo createFromParcel(Parcel in) { |
| 401 |
return new ContextHubInfo(in); |
| 402 |
} |
| 403 |
|
| 404 |
public ContextHubInfo[] newArray(int size) { |
| 405 |
return new ContextHubInfo[size]; |
| 406 |
} |
| 407 |
}; |
| 408 |
} |