1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.car.hal; 18 19 import static com.android.car.internal.common.CommonConstants.EMPTY_BYTE_ARRAY; 20 import static com.android.car.internal.common.CommonConstants.EMPTY_FLOAT_ARRAY; 21 import static com.android.car.internal.common.CommonConstants.EMPTY_INT_ARRAY; 22 import static com.android.car.internal.common.CommonConstants.EMPTY_LONG_ARRAY; 23 import static com.android.car.CarServiceUtils.toByteArray; 24 import static com.android.car.CarServiceUtils.toFloatArray; 25 import static com.android.car.CarServiceUtils.toIntArray; 26 import static com.android.car.CarServiceUtils.toLongArray; 27 28 import android.car.hardware.CarPropertyValue; 29 import android.hardware.automotive.vehicle.RawPropValues; 30 import android.hardware.automotive.vehicle.VehiclePropertyStatus; 31 32 import java.util.ArrayList; 33 import java.util.Arrays; 34 import java.util.Collections; 35 import java.util.Objects; 36 37 /** 38 * HalPropValueBuilder is a factory class used to build a HalPropValue. 39 */ 40 public final class HalPropValueBuilder { 41 // configArray[0], 1 indicates the property has a String value. 42 private static final int CONFIG_ARRAY_INDEX_STRING = 0; 43 // configArray[1], 1 indicates the property has a Boolean value. 44 private static final int CONFIG_ARRAY_INDEX_BOOLEAN = 1; 45 // configArray[2], 1 indicates the property has a Integer value. 46 private static final int CONFIG_ARRAY_INDEX_INT = 2; 47 // configArray[3], 1 indicates the property has a Integer[] value. 48 private static final int CONFIG_ARRAY_INDEX_INT_ARRAY = 3; 49 // configArray[4], 1 indicates the property has a Long value. 50 private static final int CONFIG_ARRAY_INDEX_LONG = 4; 51 // configArray[5], the number indicates the size of Long[] in the property. 52 private static final int CONFIG_ARRAY_INDEX_LONG_ARRAY = 5; 53 // configArray[6], 1 indicates the property has a Float value. 54 private static final int CONFIG_ARRAY_INDEX_FLOAT = 6; 55 // configArray[7], the number indicates the size of Float[] in the property. 56 private static final int CONFIG_ARRAY_INDEX_FLOAT_ARRAY = 7; 57 // configArray[8], the number indicates the size of byte[] in the property. 58 private static final int CONFIG_ARRAY_INDEX_BYTES = 8; 59 // Length of mixed type properties' configArray should always be 9. 60 private static final int CONFIG_ARRAY_LENGTH = 9; 61 62 private boolean mIsAidl; 63 HalPropValueBuilder(boolean isAidl)64 public HalPropValueBuilder(boolean isAidl) { 65 mIsAidl = isAidl; 66 } 67 68 /** 69 * Creates a HalPropValue with no value. 70 * 71 * @param prop The property ID. 72 * @param areaId The area ID. 73 * @return a HalPropValue. 74 */ build(int prop, int areaId)75 public HalPropValue build(int prop, int areaId) { 76 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE); 77 } 78 79 /** 80 * Creates a HalPropValue with no value. 81 * 82 * @param prop The property ID. 83 * @param areaId The area ID. 84 * @param timestamp The timestamp for the property. 85 * @param status The status for the property. 86 * @return a HalPropValue. 87 */ build(int prop, int areaId, long timestamp, int status)88 public HalPropValue build(int prop, int areaId, long timestamp, int status) { 89 if (mIsAidl) { 90 return new AidlHalPropValue(prop, areaId, timestamp, status); 91 } 92 return new HidlHalPropValue(prop, areaId, timestamp, status); 93 } 94 95 /** 96 * Creates an INT32 type HalPropValue. 97 * 98 * @param prop The property ID. 99 * @param value The property value. 100 * @return a HalPropValue. 101 */ build(int prop, int areaId, int value)102 public HalPropValue build(int prop, int areaId, int value) { 103 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE, value); 104 } 105 106 /** 107 * Creates an INT32 type HalPropValue. 108 * 109 * @param prop The property ID. 110 * @param areaId The area ID. 111 * @param timestamp The timestamp for the property. 112 * @param status The status for the property. 113 * @param value The property value. 114 * @return a HalPropValue. 115 */ build(int prop, int areaId, long timestamp, int status, int value)116 public HalPropValue build(int prop, int areaId, long timestamp, int status, int value) { 117 if (mIsAidl) { 118 return new AidlHalPropValue(prop, areaId, timestamp, status, value); 119 } 120 return new HidlHalPropValue(prop, areaId, timestamp, status, value); 121 } 122 123 /** 124 * Creates an INT32_VEC type HalPropValue. 125 * 126 * @param prop The property ID. 127 * @param values The property values. 128 * @return a HalPropValue. 129 */ build(int prop, int areaId, int[] values)130 public HalPropValue build(int prop, int areaId, int[] values) { 131 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE, values); 132 } 133 134 /** 135 * Creates an INT32_VEC type HalPropValue. 136 * 137 * @param prop The property ID. 138 * @param areaId The area ID. 139 * @param timestamp The timestamp for the property. 140 * @param status The status for the property. 141 * @param values The property values. 142 * @return a HalPropValue. 143 */ build(int prop, int areaId, long timestamp, int status, int[] values)144 public HalPropValue build(int prop, int areaId, long timestamp, int status, int[] values) { 145 if (mIsAidl) { 146 return new AidlHalPropValue(prop, areaId, timestamp, status, values); 147 } 148 return new HidlHalPropValue(prop, areaId, timestamp, status, values); 149 } 150 151 /** 152 * Creates a FLOAT type HalPropValue. 153 * 154 * @param prop The property ID. 155 * @param value The property value. 156 * @return a HalPropValue. 157 */ build(int prop, int areaId, float value)158 public HalPropValue build(int prop, int areaId, float value) { 159 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE, value); 160 } 161 162 /** 163 * Creates a FLOAT type HalPropValue. 164 * 165 * @param prop The property ID. 166 * @param areaId The area ID. 167 * @param timestamp The timestamp for the property. 168 * @param status The status for the property. 169 * @param value The property value. 170 * @return a HalPropValue. 171 */ build(int prop, int areaId, long timestamp, int status, float value)172 public HalPropValue build(int prop, int areaId, long timestamp, int status, float value) { 173 if (mIsAidl) { 174 return new AidlHalPropValue(prop, areaId, timestamp, status, value); 175 } 176 return new HidlHalPropValue(prop, areaId, timestamp, status, value); 177 } 178 179 /** 180 * Creates a FLOAT_VEC type HalPropValue. 181 * 182 * @param prop The property ID. 183 * @param values The property values. 184 * @return a HalPropValue. 185 */ build(int prop, int areaId, float[] values)186 public HalPropValue build(int prop, int areaId, float[] values) { 187 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE, values); 188 } 189 190 /** 191 * Creates a FLOAT_VEC type HalPropValue. 192 * 193 * @param prop The property ID. 194 * @param areaId The area ID. 195 * @param timestamp The timestamp for the property. 196 * @param status The status for the property. 197 * @param values The property values. 198 * @return a HalPropValue. 199 */ build(int prop, int areaId, long timestamp, int status, float[] values)200 public HalPropValue build(int prop, int areaId, long timestamp, int status, float[] values) { 201 if (mIsAidl) { 202 return new AidlHalPropValue(prop, areaId, timestamp, status, values); 203 } 204 return new HidlHalPropValue(prop, areaId, timestamp, status, values); 205 } 206 207 /** 208 * Creates an INT64 type HalPropValue. 209 * 210 * @param prop The property ID. 211 * @param value The property value. 212 * @return a HalPropValue. 213 */ build(int prop, int areaId, long value)214 public HalPropValue build(int prop, int areaId, long value) { 215 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE, value); 216 } 217 218 /** 219 * Creates an INT64 type HalPropValue. 220 * 221 * @param prop The property ID. 222 * @param areaId The area ID. 223 * @param timestamp The timestamp for the property. 224 * @param status The status for the property. 225 * @param value The property value. 226 * @return a HalPropValue. 227 */ build(int prop, int areaId, long timestamp, int status, long value)228 public HalPropValue build(int prop, int areaId, long timestamp, int status, long value) { 229 if (mIsAidl) { 230 return new AidlHalPropValue(prop, areaId, timestamp, status, value); 231 } 232 return new HidlHalPropValue(prop, areaId, timestamp, status, value); 233 } 234 235 /** 236 * Creates an INT64_VEC type HalPropValue. 237 * 238 * @param prop The property ID. 239 * @param values The property values. 240 * @return a HalPropValue. 241 */ build(int prop, int areaId, long[] values)242 public HalPropValue build(int prop, int areaId, long[] values) { 243 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE, values); 244 } 245 246 /** 247 * Creates an INT64_VEC type HalPropValue. 248 * 249 * @param prop The property ID. 250 * @param areaId The area ID. 251 * @param timestamp The timestamp for the property. 252 * @param status The status for the property. 253 * @param values The property values. 254 * @return a HalPropValue. 255 */ build(int prop, int areaId, long timestamp, int status, long[] values)256 public HalPropValue build(int prop, int areaId, long timestamp, int status, long[] values) { 257 if (mIsAidl) { 258 return new AidlHalPropValue(prop, areaId, timestamp, status, values); 259 } 260 return new HidlHalPropValue(prop, areaId, timestamp, status, values); 261 } 262 263 /** 264 * Creates a STRING type HalPropValue. 265 * 266 * @param prop The property ID. 267 * @param value The property value. 268 * @return a HalPropValue. 269 */ build(int prop, int areaId, String value)270 public HalPropValue build(int prop, int areaId, String value) { 271 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE, value); 272 } 273 274 /** 275 * Creates a STRING type HalPropValue. 276 * 277 * @param prop The property ID. 278 * @param areaId The area ID. 279 * @param timestamp The timestamp for the property. 280 * @param status The status for the property. 281 * @param value The property value. 282 * @return a HalPropValue. 283 */ build(int prop, int areaId, long timestamp, int status, String value)284 public HalPropValue build(int prop, int areaId, long timestamp, int status, String value) { 285 if (mIsAidl) { 286 return new AidlHalPropValue(prop, areaId, timestamp, status, value); 287 } 288 return new HidlHalPropValue(prop, areaId, timestamp, status, value); 289 } 290 291 /** 292 * Creates a BYTES type HalPropValue. 293 * 294 * @param prop The property ID. 295 * @param values The property values. 296 * @return a HalPropValue. 297 */ build(int prop, int areaId, byte[] values)298 public HalPropValue build(int prop, int areaId, byte[] values) { 299 return build(prop, areaId, /*timestamp=*/0, VehiclePropertyStatus.AVAILABLE, values); 300 } 301 302 /** 303 * Creates a BYTES type HalPropValue. 304 * 305 * @param prop The property ID. 306 * @param areaId The area ID. 307 * @param timestamp The timestamp for the property. 308 * @param status The status for the property. 309 * @param values The property values. 310 * @return a HalPropValue. 311 */ build(int prop, int areaId, long timestamp, int status, byte[] values)312 public HalPropValue build(int prop, int areaId, long timestamp, int status, byte[] values) { 313 if (mIsAidl) { 314 return new AidlHalPropValue(prop, areaId, timestamp, status, values); 315 } 316 return new HidlHalPropValue(prop, areaId, timestamp, status, values); 317 } 318 319 /** 320 * Creates a MIXED type HalPropValue. 321 * 322 * @param prop The property ID. 323 * @param areaId The area ID. 324 * @param timestamp The timestamp for the property. 325 * @param status The status for the property. 326 * @param int32Values The int values. 327 * @param floatValues The float values. 328 * @param int64Values The long values. 329 * @param stringValue The string value. 330 * @param byteValues The byte values. 331 * @return a HalPropValue. 332 */ build(int prop, int areaId, long timestamp, int status, int[] int32Values, float[] floatValues, long[] int64Values, String stringValue, byte[] byteValues)333 public HalPropValue build(int prop, int areaId, long timestamp, int status, int[] int32Values, 334 float[] floatValues, long[] int64Values, String stringValue, byte[] byteValues) { 335 Objects.requireNonNull(int32Values, "Use empty value, not null for empty values"); 336 Objects.requireNonNull(floatValues, "Use empty value, not null for empty values"); 337 Objects.requireNonNull(int64Values, "Use empty value, not null for empty values"); 338 Objects.requireNonNull(stringValue, "Use empty value, not null for empty values"); 339 Objects.requireNonNull(byteValues, "Use empty value, not null for empty values"); 340 if (mIsAidl) { 341 return new AidlHalPropValue(prop, areaId, timestamp, status, int32Values, floatValues, 342 int64Values, stringValue, byteValues); 343 } 344 return new HidlHalPropValue(prop, areaId, timestamp, status, int32Values, floatValues, 345 int64Values, stringValue, byteValues); 346 } 347 348 /** 349 * Creates a HalPropValue based on a {@link CarPropretyValue}. 350 * 351 * @param carPropertyValue The car property value to convert from. 352 * @param halPropId The property ID used in vehicle HAL. 353 * @param config The property config. 354 * @return a HalPropValue. 355 */ build(CarPropertyValue carPropertyValue, int halPropId, HalPropConfig config)356 public HalPropValue build(CarPropertyValue carPropertyValue, int halPropId, 357 HalPropConfig config) { 358 if (mIsAidl) { 359 return new AidlHalPropValue(carPropertyValue, halPropId, config); 360 } 361 return new HidlHalPropValue(carPropertyValue, halPropId, config); 362 } 363 364 /** 365 * Creates a HalPropValue based on an 366 * {@link android.hardware.automotive.vehicle.V2_0.VehiclePropValue}. 367 * 368 * @param value The HIDL VehiclePropValue to convert from. 369 * @return a HalPropValue. 370 */ build(android.hardware.automotive.vehicle.V2_0.VehiclePropValue value)371 public HalPropValue build(android.hardware.automotive.vehicle.V2_0.VehiclePropValue value) { 372 mIsAidl = false; 373 return new HidlHalPropValue(value); 374 } 375 376 /** 377 * Creates a HalPropValue based on an 378 * {@link android.hardware.automotive.vehicle.VehiclePropValue}. 379 * 380 * @param value The AIDL VehiclePropValue to convert from. 381 * @return a HalPropValue. 382 */ build(android.hardware.automotive.vehicle.VehiclePropValue value)383 public HalPropValue build(android.hardware.automotive.vehicle.VehiclePropValue value) { 384 mIsAidl = true; 385 return new AidlHalPropValue(value); 386 } 387 388 private static class AidlHalPropValue extends HalPropValue { 389 private android.hardware.automotive.vehicle.VehiclePropValue mVehiclePropValue; 390 AidlHalPropValue(int prop, int areaId, long timestamp, int status)391 AidlHalPropValue(int prop, int areaId, long timestamp, int status) { 392 init(prop, areaId, timestamp, status); 393 } 394 AidlHalPropValue(int prop, int areaId, long timestamp, int status, int value)395 AidlHalPropValue(int prop, int areaId, long timestamp, int status, int value) { 396 init(prop, areaId, timestamp, status); 397 mVehiclePropValue.value.int32Values = new int[]{value}; 398 } 399 AidlHalPropValue(int prop, int areaId, long timestamp, int status, int[] values)400 AidlHalPropValue(int prop, int areaId, long timestamp, int status, int[] values) { 401 init(prop, areaId, timestamp, status); 402 mVehiclePropValue.value.int32Values = values; 403 } 404 AidlHalPropValue(int prop, int areaId, long timestamp, int status, float value)405 AidlHalPropValue(int prop, int areaId, long timestamp, int status, float value) { 406 init(prop, areaId, timestamp, status); 407 mVehiclePropValue.value.floatValues = new float[]{value}; 408 } 409 AidlHalPropValue(int prop, int areaId, long timestamp, int status, float[] values)410 AidlHalPropValue(int prop, int areaId, long timestamp, int status, float[] values) { 411 init(prop, areaId, timestamp, status); 412 mVehiclePropValue.value.floatValues = values; 413 } 414 AidlHalPropValue(int prop, int areaId, long timestamp, int status, long value)415 AidlHalPropValue(int prop, int areaId, long timestamp, int status, long value) { 416 init(prop, areaId, timestamp, status); 417 mVehiclePropValue.value.int64Values = new long[]{value}; 418 } 419 AidlHalPropValue(int prop, int areaId, long timestamp, int status, long[] values)420 AidlHalPropValue(int prop, int areaId, long timestamp, int status, long[] values) { 421 init(prop, areaId, timestamp, status); 422 mVehiclePropValue.value.int64Values = values; 423 } 424 AidlHalPropValue(int prop, int areaId, long timestamp, int status, byte[] values)425 AidlHalPropValue(int prop, int areaId, long timestamp, int status, byte[] values) { 426 init(prop, areaId, timestamp, status); 427 mVehiclePropValue.value.byteValues = values; 428 } 429 AidlHalPropValue(int prop, int areaId, long timestamp, int status, String value)430 AidlHalPropValue(int prop, int areaId, long timestamp, int status, String value) { 431 init(prop, areaId, timestamp, status); 432 mVehiclePropValue.value.stringValue = value; 433 } 434 AidlHalPropValue(int prop, int areaId, long timestamp, int status, int[] int32Values, float[] floatValues, long[] int64Values, String stringValue, byte[] byteValues)435 AidlHalPropValue(int prop, int areaId, long timestamp, int status, int[] int32Values, 436 float[] floatValues, long[] int64Values, String stringValue, byte[] byteValues) { 437 init(prop, areaId, timestamp, status); 438 mVehiclePropValue.value.int32Values = int32Values; 439 mVehiclePropValue.value.floatValues = floatValues; 440 mVehiclePropValue.value.int64Values = int64Values; 441 mVehiclePropValue.value.stringValue = stringValue; 442 mVehiclePropValue.value.byteValues = byteValues; 443 } 444 AidlHalPropValue(CarPropertyValue value, int halPropId, HalPropConfig config)445 AidlHalPropValue(CarPropertyValue value, int halPropId, HalPropConfig config) { 446 init(halPropId, value.getAreaId(), 0, VehiclePropertyStatus.AVAILABLE); 447 448 if (HalPropValue.isMixedTypeProperty(halPropId)) { 449 setMixedCarProperty(value, config.getConfigArray()); 450 } else { 451 setCarProperty(value); 452 } 453 } 454 AidlHalPropValue(android.hardware.automotive.vehicle.VehiclePropValue value)455 AidlHalPropValue(android.hardware.automotive.vehicle.VehiclePropValue value) { 456 mVehiclePropValue = value; 457 458 // Make sure the stored VehiclePropValue does not contain any null values. 459 if (mVehiclePropValue.value == null) { 460 mVehiclePropValue.value = emptyRawPropValues(); 461 return; 462 } 463 if (mVehiclePropValue.value.int32Values == null) { 464 mVehiclePropValue.value.int32Values = EMPTY_INT_ARRAY; 465 } 466 if (mVehiclePropValue.value.floatValues == null) { 467 mVehiclePropValue.value.floatValues = EMPTY_FLOAT_ARRAY; 468 } 469 if (mVehiclePropValue.value.int64Values == null) { 470 mVehiclePropValue.value.int64Values = EMPTY_LONG_ARRAY; 471 } 472 if (mVehiclePropValue.value.byteValues == null) { 473 mVehiclePropValue.value.byteValues = EMPTY_BYTE_ARRAY; 474 } 475 if (mVehiclePropValue.value.stringValue == null) { 476 mVehiclePropValue.value.stringValue = ""; 477 } 478 } 479 toVehiclePropValue()480 public Object toVehiclePropValue() { 481 return mVehiclePropValue; 482 } 483 484 /** 485 * Get the timestamp. 486 * 487 * @return The timestamp. 488 */ getTimestamp()489 public long getTimestamp() { 490 return mVehiclePropValue.timestamp; 491 } 492 493 /** 494 * Get the area ID. 495 * 496 * @return The area ID. 497 */ getAreaId()498 public int getAreaId() { 499 return mVehiclePropValue.areaId; 500 } 501 502 /** 503 * Get the property ID. 504 * 505 * @return The property ID. 506 */ getPropId()507 public int getPropId() { 508 return mVehiclePropValue.prop; 509 } 510 511 /** 512 * Get the property status. 513 * 514 * @return The property status. 515 */ getStatus()516 public int getStatus() { 517 return mVehiclePropValue.status; 518 } 519 520 /** 521 * Get stored int32 values size. 522 * 523 * @return The size for the stored int32 values. 524 */ getInt32ValuesSize()525 public int getInt32ValuesSize() { 526 return mVehiclePropValue.value.int32Values.length; 527 } 528 529 /** 530 * Get the int32 value at index. 531 * 532 * @param index The index. 533 * @return The int32 value at index. 534 */ getInt32Value(int index)535 public int getInt32Value(int index) { 536 return mVehiclePropValue.value.int32Values[index]; 537 } 538 539 /** 540 * Dump all int32 values as a string. Used for debugging. 541 * 542 * @return A String representation of all int32 values. 543 */ dumpInt32Values()544 public String dumpInt32Values() { 545 return Arrays.toString(mVehiclePropValue.value.int32Values); 546 } 547 548 /** 549 * Get stored float values size. 550 * 551 * @return The size for the stored float values. 552 */ getFloatValuesSize()553 public int getFloatValuesSize() { 554 return mVehiclePropValue.value.floatValues.length; 555 } 556 557 /** 558 * Get the float value at index. 559 * 560 * @param index The index. 561 * @return The float value at index. 562 */ getFloatValue(int index)563 public float getFloatValue(int index) { 564 return mVehiclePropValue.value.floatValues[index]; 565 } 566 567 /** 568 * Dump all float values as a string. Used for debugging. 569 * 570 * @return A String representation of all float values. 571 */ dumpFloatValues()572 public String dumpFloatValues() { 573 return Arrays.toString(mVehiclePropValue.value.floatValues); 574 } 575 576 /** 577 * Get stored inn64 values size. 578 * 579 * @return The size for the stored inn64 values. 580 */ getInt64ValuesSize()581 public int getInt64ValuesSize() { 582 return mVehiclePropValue.value.int64Values.length; 583 } 584 585 /** 586 * Dump all int64 values as a string. Used for debugging. 587 * 588 * @return A String representation of all int64 values. 589 */ dumpInt64Values()590 public String dumpInt64Values() { 591 return Arrays.toString(mVehiclePropValue.value.int64Values); 592 } 593 594 /** 595 * Get the int64 value at index. 596 * 597 * @param index The index. 598 * @return The int64 value at index. 599 */ getInt64Value(int index)600 public long getInt64Value(int index) { 601 return mVehiclePropValue.value.int64Values[index]; 602 } 603 604 /** 605 * Get stored byte values size. 606 * 607 * @return The size for the stored byte values. 608 */ getByteValuesSize()609 public int getByteValuesSize() { 610 return mVehiclePropValue.value.byteValues.length; 611 } 612 613 /** 614 * Get the byte value at index. 615 * 616 * @param index The index. 617 * @return The byte value at index. 618 */ getByteValue(int index)619 public byte getByteValue(int index) { 620 return mVehiclePropValue.value.byteValues[index]; 621 } 622 623 /** 624 * Gets the byte values. 625 * 626 * @return The byte values. 627 */ getByteArray()628 public byte[] getByteArray() { 629 return mVehiclePropValue.value.byteValues; 630 } 631 632 /** 633 * Get the string value. 634 * 635 * @return The stored string value. 636 */ getStringValue()637 public String getStringValue() { 638 return mVehiclePropValue.value.stringValue; 639 } 640 641 @Override hashCode()642 public int hashCode() { 643 return Objects.hash( 644 getPropId(), 645 getAreaId(), 646 getStatus(), 647 getTimestamp(), 648 Arrays.hashCode(mVehiclePropValue.value.int32Values), 649 Arrays.hashCode(mVehiclePropValue.value.floatValues), 650 Arrays.hashCode(mVehiclePropValue.value.int64Values), 651 mVehiclePropValue.value.stringValue.hashCode(), 652 Arrays.hashCode(mVehiclePropValue.value.byteValues)); 653 } 654 655 @Override equals(Object o)656 public boolean equals(Object o) { 657 if (this == o) return true; 658 if (!(o instanceof AidlHalPropValue)) return false; 659 if (!super.equals(o)) return false; 660 AidlHalPropValue that = (AidlHalPropValue) o; 661 return mVehiclePropValue.equals(that.mVehiclePropValue); 662 } 663 getFloatContainerArray()664 protected Float[] getFloatContainerArray() { 665 int size = getFloatValuesSize(); 666 Float[] array = new Float[size]; 667 for (int i = 0; i < size; i++) { 668 array[i] = mVehiclePropValue.value.floatValues[i]; 669 } 670 return array; 671 } 672 getInt32ContainerArray()673 protected Integer[] getInt32ContainerArray() { 674 int size = getInt32ValuesSize(); 675 Integer[] array = new Integer[size]; 676 for (int i = 0; i < size; i++) { 677 array[i] = mVehiclePropValue.value.int32Values[i]; 678 } 679 return array; 680 } 681 getInt64ContainerArray()682 protected Long[] getInt64ContainerArray() { 683 int size = getInt64ValuesSize(); 684 Long[] array = new Long[size]; 685 for (int i = 0; i < size; i++) { 686 array[i] = mVehiclePropValue.value.int64Values[i]; 687 } 688 return array; 689 } 690 init(int prop, int areaId, long timestamp, int status)691 private void init(int prop, int areaId, long timestamp, int status) { 692 mVehiclePropValue = new android.hardware.automotive.vehicle.VehiclePropValue(); 693 mVehiclePropValue.areaId = areaId; 694 mVehiclePropValue.timestamp = timestamp; 695 mVehiclePropValue.prop = prop; 696 mVehiclePropValue.status = status; 697 mVehiclePropValue.value = emptyRawPropValues(); 698 } 699 setCarProperty(CarPropertyValue carProp)700 private void setCarProperty(CarPropertyValue carProp) { 701 Object o = carProp.getValue(); 702 703 if (o instanceof Boolean) { 704 mVehiclePropValue.value.int32Values = new int[]{((Boolean) o) ? 1 : 0}; 705 } else if (o instanceof Integer) { 706 mVehiclePropValue.value.int32Values = new int[]{((Integer) o)}; 707 } else if (o instanceof Integer[]) { 708 Integer[] array = (Integer[]) o; 709 mVehiclePropValue.value.int32Values = new int[array.length]; 710 for (int i = 0; i < array.length; i++) { 711 mVehiclePropValue.value.int32Values[i] = array[i]; 712 } 713 } else if (o instanceof Float) { 714 mVehiclePropValue.value.floatValues = new float[]{((Float) o)}; 715 } else if (o instanceof Float[]) { 716 Float[] array = (Float[]) o; 717 mVehiclePropValue.value.floatValues = new float[array.length]; 718 for (int i = 0; i < array.length; i++) { 719 mVehiclePropValue.value.floatValues[i] = array[i]; 720 } 721 } else if (o instanceof Long) { 722 mVehiclePropValue.value.int64Values = new long[]{((Long) o)}; 723 } else if (o instanceof Long[]) { 724 Long[] array = (Long[]) o; 725 mVehiclePropValue.value.int64Values = new long[array.length]; 726 for (int i = 0; i < array.length; i++) { 727 mVehiclePropValue.value.int64Values[i] = array[i]; 728 } 729 } else if (o instanceof String) { 730 mVehiclePropValue.value.stringValue = (String) o; 731 } else if (o instanceof byte[]) { 732 byte[] array = (byte[]) o; 733 mVehiclePropValue.value.byteValues = array; 734 } else { 735 throw new IllegalArgumentException("Unexpected type in: " + carProp); 736 } 737 } 738 739 /** 740 * Set the vehicle property value for MIXED type properties according to configArray. 741 * configArray[0], 1 indicates the property has a String value. 742 * configArray[1], 1 indicates the property has a Boolean value. 743 * configArray[2], 1 indicates the property has a Integer value. 744 * configArray[3], the number indicates the size of Integer[] in the property. 745 * configArray[4], 1 indicates the property has a Long value. 746 * configArray[5], the number indicates the size of Long[] in the property. 747 * configArray[6], 1 indicates the property has a Float value. 748 * configArray[7], the number indicates the size of Float[] in the property. 749 * configArray[8], the number indicates the size of byte[] in the property. 750 * 751 * <p>For example: configArray = {1, 1, 1, 3, 0, 0, 0, 0, 0} indicates the property has a 752 * String value, a Boolean value, an Integer value, an Integer array with 3 enums. 753 */ setMixedCarProperty(CarPropertyValue carProp, int[] configArray)754 private void setMixedCarProperty(CarPropertyValue carProp, int[] configArray) { 755 if (configArray.length != CONFIG_ARRAY_LENGTH) { 756 throw new IllegalArgumentException("Unexpected configArray in:" + carProp); 757 } 758 759 Object[] values = (Object[]) carProp.getValue(); 760 int indexOfValues = 0; 761 if (configArray[CONFIG_ARRAY_INDEX_STRING] != 0) { 762 // Add a string value 763 mVehiclePropValue.value.stringValue = (String) values[indexOfValues]; 764 indexOfValues++; 765 } 766 767 ArrayList<Integer> int32Values = new ArrayList<Integer>(); 768 ArrayList<Long> int64Values = new ArrayList<Long>(); 769 ArrayList<Byte> byteValues = new ArrayList<Byte>(); 770 ArrayList<Float> floatValues = new ArrayList<Float>(); 771 772 setMixedTypeValues(indexOfValues, values, configArray, int32Values, floatValues, 773 int64Values, byteValues); 774 775 mVehiclePropValue.value.int32Values = toIntArray(int32Values); 776 mVehiclePropValue.value.floatValues = toFloatArray(floatValues); 777 mVehiclePropValue.value.int64Values = toLongArray(int64Values); 778 mVehiclePropValue.value.byteValues = toByteArray(byteValues); 779 } 780 } 781 782 private static class HidlHalPropValue extends HalPropValue { 783 private android.hardware.automotive.vehicle.V2_0.VehiclePropValue mVehiclePropValue; 784 HidlHalPropValue(int prop, int areaId, long timestamp, int status)785 HidlHalPropValue(int prop, int areaId, long timestamp, int status) { 786 init(prop, areaId, timestamp, status); 787 } 788 HidlHalPropValue(int prop, int areaId, long timestamp, int status, int value)789 HidlHalPropValue(int prop, int areaId, long timestamp, int status, int value) { 790 init(prop, areaId, timestamp, status); 791 mVehiclePropValue.value.int32Values = new ArrayList<Integer>(Arrays.asList(value)); 792 } 793 HidlHalPropValue(int prop, int areaId, long timestamp, int status, int[] values)794 HidlHalPropValue(int prop, int areaId, long timestamp, int status, int[] values) { 795 init(prop, areaId, timestamp, status); 796 mVehiclePropValue.value.int32Values = int32ArrayToList(values); 797 } 798 HidlHalPropValue(int prop, int areaId, long timestamp, int status, float value)799 HidlHalPropValue(int prop, int areaId, long timestamp, int status, float value) { 800 init(prop, areaId, timestamp, status); 801 mVehiclePropValue.value.floatValues = new ArrayList<Float>(Arrays.asList(value)); 802 } 803 HidlHalPropValue(int prop, int areaId, long timestamp, int status, float[] values)804 HidlHalPropValue(int prop, int areaId, long timestamp, int status, float[] values) { 805 init(prop, areaId, timestamp, status); 806 mVehiclePropValue.value.floatValues = floatArrayToList(values); 807 } 808 HidlHalPropValue(int prop, int areaId, long timestamp, int status, long value)809 HidlHalPropValue(int prop, int areaId, long timestamp, int status, long value) { 810 init(prop, areaId, timestamp, status); 811 mVehiclePropValue.value.int64Values = new ArrayList<Long>(Arrays.asList(value)); 812 } 813 HidlHalPropValue(int prop, int areaId, long timestamp, int status, long[] values)814 HidlHalPropValue(int prop, int areaId, long timestamp, int status, long[] values) { 815 init(prop, areaId, timestamp, status); 816 mVehiclePropValue.value.int64Values = int64ArrayToList(values); 817 } 818 HidlHalPropValue(int prop, int areaId, long timestamp, int status, byte[] values)819 HidlHalPropValue(int prop, int areaId, long timestamp, int status, byte[] values) { 820 init(prop, areaId, timestamp, status); 821 mVehiclePropValue.value.bytes = byteArrayToList(values); 822 } 823 HidlHalPropValue(int prop, int areaId, long timestamp, int status, String value)824 HidlHalPropValue(int prop, int areaId, long timestamp, int status, String value) { 825 init(prop, areaId, timestamp, status); 826 mVehiclePropValue.value.stringValue = value; 827 } 828 HidlHalPropValue(int prop, int areaId, long timestamp, int status, int[] int32Values, float[] floatValues, long[] int64Values, String stringValue, byte[] byteValues)829 HidlHalPropValue(int prop, int areaId, long timestamp, int status, int[] int32Values, 830 float[] floatValues, long[] int64Values, String stringValue, byte[] byteValues) { 831 init(prop, areaId, timestamp, status); 832 mVehiclePropValue.value.int32Values = int32ArrayToList(int32Values); 833 mVehiclePropValue.value.floatValues = floatArrayToList(floatValues); 834 mVehiclePropValue.value.int64Values = int64ArrayToList(int64Values); 835 mVehiclePropValue.value.stringValue = stringValue; 836 mVehiclePropValue.value.bytes = byteArrayToList(byteValues); 837 } 838 HidlHalPropValue(CarPropertyValue value, int halPropId, HalPropConfig config)839 HidlHalPropValue(CarPropertyValue value, int halPropId, HalPropConfig config) { 840 init(halPropId, value.getAreaId(), 0, VehiclePropertyStatus.AVAILABLE); 841 842 if (HalPropValue.isMixedTypeProperty(halPropId)) { 843 setMixedCarProperty(value, config.getConfigArray()); 844 } else { 845 setCarProperty(value); 846 } 847 } 848 HidlHalPropValue(android.hardware.automotive.vehicle.V2_0.VehiclePropValue value)849 HidlHalPropValue(android.hardware.automotive.vehicle.V2_0.VehiclePropValue value) { 850 mVehiclePropValue = value; 851 852 // Make sure the stored VehiclePropValue does not contain any null values. 853 if (mVehiclePropValue.value == null) { 854 mVehiclePropValue.value = 855 new android.hardware.automotive.vehicle.V2_0.VehiclePropValue.RawValue(); 856 return; 857 } 858 if (mVehiclePropValue.value.int32Values == null) { 859 mVehiclePropValue.value.int32Values = new ArrayList<Integer>(); 860 } 861 if (mVehiclePropValue.value.floatValues == null) { 862 mVehiclePropValue.value.floatValues = new ArrayList<Float>(); 863 } 864 if (mVehiclePropValue.value.int64Values == null) { 865 mVehiclePropValue.value.int64Values = new ArrayList<Long>(); 866 } 867 if (mVehiclePropValue.value.bytes == null) { 868 mVehiclePropValue.value.bytes = new ArrayList<Byte>(); 869 } 870 if (mVehiclePropValue.value.stringValue == null) { 871 mVehiclePropValue.value.stringValue = ""; 872 } 873 } 874 toVehiclePropValue()875 public Object toVehiclePropValue() { 876 return mVehiclePropValue; 877 } 878 879 /** 880 * Get the timestamp. 881 * 882 * @return The timestamp. 883 */ getTimestamp()884 public long getTimestamp() { 885 return mVehiclePropValue.timestamp; 886 } 887 888 /** 889 * Get the area ID. 890 * 891 * @return The area ID. 892 */ getAreaId()893 public int getAreaId() { 894 return mVehiclePropValue.areaId; 895 } 896 897 /** 898 * Get the property ID. 899 * 900 * @return The property ID. 901 */ getPropId()902 public int getPropId() { 903 return mVehiclePropValue.prop; 904 } 905 906 /** 907 * Get the property status. 908 * 909 * @return The property status. 910 */ getStatus()911 public int getStatus() { 912 return mVehiclePropValue.status; 913 } 914 915 /** 916 * Get stored int32 values size. 917 * 918 * @return The size for the stored int32 values. 919 */ getInt32ValuesSize()920 public int getInt32ValuesSize() { 921 return mVehiclePropValue.value.int32Values.size(); 922 } 923 924 /** 925 * Get the int32 value at index. 926 * 927 * @param index The index. 928 * @return The int32 value at index. 929 */ getInt32Value(int index)930 public int getInt32Value(int index) { 931 return mVehiclePropValue.value.int32Values.get(index); 932 } 933 934 /** 935 * Dump all int32 values as a string. Used for debugging. 936 * 937 * @return A String representation of all int32 values. 938 */ dumpInt32Values()939 public String dumpInt32Values() { 940 return Arrays.toString(mVehiclePropValue.value.int32Values.toArray()); 941 } 942 943 /** 944 * Get stored float values size. 945 * 946 * @return The size for the stored float values. 947 */ getFloatValuesSize()948 public int getFloatValuesSize() { 949 return mVehiclePropValue.value.floatValues.size(); 950 } 951 952 /** 953 * Get the float value at index. 954 * 955 * @param index The index. 956 * @return The float value at index. 957 */ getFloatValue(int index)958 public float getFloatValue(int index) { 959 return mVehiclePropValue.value.floatValues.get(index); 960 } 961 962 /** 963 * Dump all float values as a string. Used for debugging. 964 * 965 * @return A String representation of all float values. 966 */ dumpFloatValues()967 public String dumpFloatValues() { 968 return Arrays.toString(mVehiclePropValue.value.floatValues.toArray()); 969 } 970 971 /** 972 * Get stored inn64 values size. 973 * 974 * @return The size for the stored inn64 values. 975 */ getInt64ValuesSize()976 public int getInt64ValuesSize() { 977 return mVehiclePropValue.value.int64Values.size(); 978 } 979 980 /** 981 * Get the int64 value at index. 982 * 983 * @param index The index. 984 * @return The int64 value at index. 985 */ getInt64Value(int index)986 public long getInt64Value(int index) { 987 return mVehiclePropValue.value.int64Values.get(index); 988 } 989 990 /** 991 * Dump all int64 values as a string. Used for debugging. 992 * 993 * @return A String representation of all int64 values. 994 */ dumpInt64Values()995 public String dumpInt64Values() { 996 return Arrays.toString(mVehiclePropValue.value.int64Values.toArray()); 997 } 998 999 /** 1000 * Get stored byte values size. 1001 * 1002 * @return The size for the stored byte values. 1003 */ getByteValuesSize()1004 public int getByteValuesSize() { 1005 return mVehiclePropValue.value.bytes.size(); 1006 } 1007 1008 /** 1009 * Get the byte value at index. 1010 * 1011 * @param index The index. 1012 * @return The byte value at index. 1013 */ getByteValue(int index)1014 public byte getByteValue(int index) { 1015 return mVehiclePropValue.value.bytes.get(index); 1016 } 1017 1018 /** 1019 * Gets the byte values. 1020 * 1021 * @return The byte values. 1022 */ getByteArray()1023 public byte[] getByteArray() { 1024 return toByteArray(mVehiclePropValue.value.bytes); 1025 } 1026 1027 /** 1028 * Get the string value. 1029 * 1030 * @return The stored string value. 1031 */ getStringValue()1032 public String getStringValue() { 1033 return mVehiclePropValue.value.stringValue; 1034 } 1035 1036 @Override hashCode()1037 public int hashCode() { 1038 return Objects.hash( 1039 getPropId(), 1040 getAreaId(), 1041 getStatus(), 1042 getTimestamp(), 1043 mVehiclePropValue.value.int32Values.hashCode(), 1044 mVehiclePropValue.value.floatValues.hashCode(), 1045 mVehiclePropValue.value.int64Values.hashCode(), 1046 mVehiclePropValue.value.stringValue.hashCode(), 1047 mVehiclePropValue.value.bytes.hashCode()); 1048 } 1049 1050 @Override equals(Object o)1051 public boolean equals(Object o) { 1052 if (this == o) return true; 1053 if (!(o instanceof HidlHalPropValue)) return false; 1054 if (!super.equals(o)) return false; 1055 HidlHalPropValue that = (HidlHalPropValue) o; 1056 return mVehiclePropValue.equals(that.mVehiclePropValue); 1057 } 1058 getFloatContainerArray()1059 protected Float[] getFloatContainerArray() { 1060 return mVehiclePropValue.value.floatValues.toArray(new Float[getFloatValuesSize()]); 1061 } 1062 getInt32ContainerArray()1063 protected Integer[] getInt32ContainerArray() { 1064 return mVehiclePropValue.value.int32Values.toArray(new Integer[getInt32ValuesSize()]); 1065 } 1066 getInt64ContainerArray()1067 protected Long[] getInt64ContainerArray() { 1068 return mVehiclePropValue.value.int64Values.toArray(new Long[getInt64ValuesSize()]); 1069 } 1070 init(int prop, int areaId, long timestamp, int status)1071 private void init(int prop, int areaId, long timestamp, int status) { 1072 mVehiclePropValue = new android.hardware.automotive.vehicle.V2_0.VehiclePropValue(); 1073 mVehiclePropValue.areaId = areaId; 1074 mVehiclePropValue.timestamp = timestamp; 1075 mVehiclePropValue.prop = prop; 1076 mVehiclePropValue.status = status; 1077 // The default initializer would fill in empty array for the values. 1078 mVehiclePropValue.value = 1079 new android.hardware.automotive.vehicle.V2_0.VehiclePropValue.RawValue(); 1080 } 1081 setCarProperty(CarPropertyValue carProp)1082 private void setCarProperty(CarPropertyValue carProp) { 1083 Object o = carProp.getValue(); 1084 1085 if (o instanceof Boolean) { 1086 mVehiclePropValue.value.int32Values.add(((Boolean) o) ? 1 : 0); 1087 } else if (o instanceof Integer) { 1088 mVehiclePropValue.value.int32Values.add((Integer) o); 1089 } else if (o instanceof Integer[]) { 1090 Collections.addAll(mVehiclePropValue.value.int32Values, (Integer[]) o); 1091 } else if (o instanceof Float) { 1092 mVehiclePropValue.value.floatValues.add((Float) o); 1093 } else if (o instanceof Float[]) { 1094 Collections.addAll(mVehiclePropValue.value.floatValues, (Float[]) o); 1095 } else if (o instanceof Long) { 1096 mVehiclePropValue.value.int64Values.add((Long) o); 1097 } else if (o instanceof Long[]) { 1098 Collections.addAll(mVehiclePropValue.value.int64Values, (Long[]) o); 1099 } else if (o instanceof String) { 1100 mVehiclePropValue.value.stringValue = (String) o; 1101 } else if (o instanceof byte[]) { 1102 for (byte b : (byte[]) o) { 1103 mVehiclePropValue.value.bytes.add(b); 1104 } 1105 } else { 1106 throw new IllegalArgumentException("Unexpected type in: " + carProp); 1107 } 1108 } 1109 1110 /** 1111 * Set the vehicle property value for MIXED type properties according to configArray. 1112 * configArray[0], 1 indicates the property has a String value. 1113 * configArray[1], 1 indicates the property has a Boolean value. 1114 * configArray[2], 1 indicates the property has a Integer value. 1115 * configArray[3], the number indicates the size of Integer[] in the property. 1116 * configArray[4], 1 indicates the property has a Long value. 1117 * configArray[5], the number indicates the size of Long[] in the property. 1118 * configArray[6], 1 indicates the property has a Float value. 1119 * configArray[7], the number indicates the size of Float[] in the property. 1120 * configArray[8], the number indicates the size of byte[] in the property. 1121 * 1122 * <p>For example: configArray = {1, 1, 1, 3, 0, 0, 0, 0, 0} indicates the property has a 1123 * String value, a Boolean value, an Integer value, an Integer array with 3 enums. 1124 */ setMixedCarProperty(CarPropertyValue carProp, int[] configArray)1125 private void setMixedCarProperty(CarPropertyValue carProp, int[] configArray) { 1126 if (configArray.length != CONFIG_ARRAY_LENGTH) { 1127 throw new IllegalArgumentException("Unexpected configArray in:" + carProp); 1128 } 1129 1130 Object[] values = (Object[]) carProp.getValue(); 1131 int indexOfValues = 0; 1132 if (configArray[CONFIG_ARRAY_INDEX_STRING] != 0) { 1133 // Add a string value 1134 mVehiclePropValue.value.stringValue = (String) values[indexOfValues]; 1135 indexOfValues++; 1136 } 1137 1138 ArrayList<Integer> int32Values = new ArrayList<Integer>(); 1139 ArrayList<Long> int64Values = new ArrayList<Long>(); 1140 ArrayList<Byte> byteValues = new ArrayList<Byte>(); 1141 ArrayList<Float> floatValues = new ArrayList<Float>(); 1142 1143 setMixedTypeValues(indexOfValues, values, configArray, int32Values, floatValues, 1144 int64Values, byteValues); 1145 1146 mVehiclePropValue.value.int32Values = int32Values; 1147 mVehiclePropValue.value.floatValues = floatValues; 1148 mVehiclePropValue.value.int64Values = int64Values; 1149 mVehiclePropValue.value.bytes = byteValues; 1150 } 1151 } 1152 int32ArrayToList(int[] int32Array)1153 private static ArrayList<Integer> int32ArrayToList(int[] int32Array) { 1154 ArrayList<Integer> int32Values = new ArrayList<Integer>(int32Array.length); 1155 for (int v : int32Array) { 1156 int32Values.add(v); 1157 } 1158 return int32Values; 1159 } 1160 floatArrayToList(float[] floatArray)1161 private static ArrayList<Float> floatArrayToList(float[] floatArray) { 1162 ArrayList<Float> floatValues = new ArrayList<Float>(floatArray.length); 1163 for (float v : floatArray) { 1164 floatValues.add(v); 1165 } 1166 return floatValues; 1167 } 1168 int64ArrayToList(long[] int64Array)1169 private static ArrayList<Long> int64ArrayToList(long[] int64Array) { 1170 ArrayList<Long> int64Values = new ArrayList<Long>(int64Array.length); 1171 for (long v : int64Array) { 1172 int64Values.add(v); 1173 } 1174 return int64Values; 1175 } 1176 byteArrayToList(byte[] byteArray)1177 private static ArrayList<Byte> byteArrayToList(byte[] byteArray) { 1178 ArrayList<Byte> byteValues = new ArrayList<Byte>(byteArray.length); 1179 for (byte v : byteArray) { 1180 byteValues.add(v); 1181 } 1182 return byteValues; 1183 } 1184 setMixedTypeValues(int indexOfValues, Object[]values, int[] configArray, ArrayList<Integer> int32Values, ArrayList<Float> floatValues, ArrayList<Long> int64Values, ArrayList<Byte> byteValues)1185 private static void setMixedTypeValues(int indexOfValues, Object[]values, 1186 int[] configArray, ArrayList<Integer> int32Values, ArrayList<Float> floatValues, 1187 ArrayList<Long> int64Values, ArrayList<Byte> byteValues) { 1188 1189 int index = indexOfValues; 1190 if (configArray[CONFIG_ARRAY_INDEX_BOOLEAN] != 0) { 1191 // Add a boolean value 1192 int32Values.add((Boolean) values[index] ? 1 : 0); // in HAL, 1 indicates true 1193 index++; 1194 } 1195 1196 /* 1197 * configArray[2], 1 indicates the property has a Integer value. 1198 * configArray[3], the number indicates the size of Integer[] in the property. 1199 */ 1200 int integerSize = 1201 configArray[CONFIG_ARRAY_INDEX_INT] + configArray[CONFIG_ARRAY_INDEX_INT_ARRAY]; 1202 while (integerSize != 0) { 1203 int32Values.add((Integer) values[index]); 1204 index++; 1205 integerSize--; 1206 } 1207 /* configArray[4], 1 indicates the property has a Long value . 1208 * configArray[5], the number indicates the size of Long[] in the property. 1209 */ 1210 int longSize = 1211 configArray[CONFIG_ARRAY_INDEX_LONG] + configArray[CONFIG_ARRAY_INDEX_LONG_ARRAY]; 1212 while (longSize != 0) { 1213 int64Values.add((Long) values[index]); 1214 index++; 1215 longSize--; 1216 } 1217 /* configArray[6], 1 indicates the property has a Float value . 1218 * configArray[7], the number indicates the size of Float[] in the property. 1219 */ 1220 int floatSize = 1221 configArray[CONFIG_ARRAY_INDEX_FLOAT] + configArray[CONFIG_ARRAY_INDEX_FLOAT_ARRAY]; 1222 while (floatSize != 0) { 1223 floatValues.add((Float) values[index]); 1224 index++; 1225 floatSize--; 1226 } 1227 1228 /* configArray[8], the number indicates the size of byte[] in the property. */ 1229 int byteSize = configArray[CONFIG_ARRAY_INDEX_BYTES]; 1230 while (byteSize != 0) { 1231 byteValues.add((Byte) values[index]); 1232 index++; 1233 byteSize--; 1234 } 1235 } 1236 emptyRawPropValues()1237 private static RawPropValues emptyRawPropValues() { 1238 RawPropValues values = new RawPropValues(); 1239 values.int32Values = EMPTY_INT_ARRAY; 1240 values.floatValues = EMPTY_FLOAT_ARRAY; 1241 values.int64Values = EMPTY_LONG_ARRAY; 1242 values.byteValues = EMPTY_BYTE_ARRAY; 1243 values.stringValue = ""; 1244 return values; 1245 } 1246 } 1247