diff options
author | Kai Wang | 2019-06-07 13:37:04 -0500 |
---|---|---|
committer | Gerrit Code Review | 2019-06-07 13:37:04 -0500 |
commit | 6facd41120ff82679878a5c09b8a3378251a8731 (patch) | |
tree | d619b36805c18f33483078b6b16135198809a27a | |
parent | dbd4eea7e65c1854a5ec3cb3491c51f1abc0ce1e (diff) | |
parent | a33b5850494b9fc97dd300450d3f7244b57b9950 (diff) | |
download | platform-packages-services-car-6facd41120ff82679878a5c09b8a3378251a8731.tar.gz platform-packages-services-car-6facd41120ff82679878a5c09b8a3378251a8731.tar.xz platform-packages-services-car-6facd41120ff82679878a5c09b8a3378251a8731.zip |
Merge "Create fake CarPropertyValue for an error event"android-o-mr1-iot-release-1.0.14android-o-mr1-iot-release-1.0.13
4 files changed, 54 insertions, 10 deletions
diff --git a/car-lib/src/android/car/hardware/property/CarPropertyEvent.java b/car-lib/src/android/car/hardware/property/CarPropertyEvent.java index 638fbf2e..258403a4 100644 --- a/car-lib/src/android/car/hardware/property/CarPropertyEvent.java +++ b/car-lib/src/android/car/hardware/property/CarPropertyEvent.java | |||
@@ -31,7 +31,8 @@ public class CarPropertyEvent implements Parcelable { | |||
31 | private final int mEventType; | 31 | private final int mEventType; |
32 | private final CarPropertyValue<?> mCarPropertyValue; | 32 | private final CarPropertyValue<?> mCarPropertyValue; |
33 | 33 | ||
34 | // Getters. | 34 | // Use it as default value for error events. |
35 | private static final int ERROR_EVENT_VALUE = -1; | ||
35 | 36 | ||
36 | /** | 37 | /** |
37 | * @return EventType field | 38 | * @return EventType field |
@@ -73,6 +74,19 @@ public class CarPropertyEvent implements Parcelable { | |||
73 | mCarPropertyValue = carPropertyValue; | 74 | mCarPropertyValue = carPropertyValue; |
74 | } | 75 | } |
75 | 76 | ||
77 | /** | ||
78 | * Constructor for {@link CarPropertyEvent} when it is an error event. | ||
79 | * | ||
80 | * The status of {@link CarPropertyValue} should be {@link CarPropertyValue#STATUS_ERROR}. | ||
81 | * In {@link CarPropertyManager}, the value of {@link CarPropertyValue} will be dropped. | ||
82 | */ | ||
83 | public static CarPropertyEvent createErrorEvent(int propertyId, int areaId) { | ||
84 | // valueWithErrorCode will not be propagated to listeners | ||
85 | CarPropertyValue<Integer> valueWithErrorCode = new CarPropertyValue<>(propertyId, areaId, | ||
86 | CarPropertyValue.STATUS_ERROR, 0, ERROR_EVENT_VALUE); | ||
87 | return new CarPropertyEvent(PROPERTY_EVENT_ERROR, valueWithErrorCode); | ||
88 | } | ||
89 | |||
76 | private CarPropertyEvent(Parcel in) { | 90 | private CarPropertyEvent(Parcel in) { |
77 | mEventType = in.readInt(); | 91 | mEventType = in.readInt(); |
78 | mCarPropertyValue = in.readParcelable(CarPropertyValue.class.getClassLoader()); | 92 | mCarPropertyValue = in.readParcelable(CarPropertyValue.class.getClassLoader()); |
diff --git a/service/src/com/android/car/CarPropertyService.java b/service/src/com/android/car/CarPropertyService.java index a01d4b87..fa086883 100644 --- a/service/src/com/android/car/CarPropertyService.java +++ b/service/src/com/android/car/CarPropertyService.java | |||
@@ -372,7 +372,7 @@ public class CarPropertyService extends ICarProperty.Stub | |||
372 | List<Client> clients = mPropIdClientMap.get(property); | 372 | List<Client> clients = mPropIdClientMap.get(property); |
373 | if (clients != null) { | 373 | if (clients != null) { |
374 | List<CarPropertyEvent> eventList = new LinkedList<>(); | 374 | List<CarPropertyEvent> eventList = new LinkedList<>(); |
375 | eventList.add(createErrorEvent(property, area)); | 375 | eventList.add(CarPropertyEvent.createErrorEvent(property, area)); |
376 | for (Client c : clients) { | 376 | for (Client c : clients) { |
377 | try { | 377 | try { |
378 | c.getListener().onEvent(eventList); | 378 | c.getListener().onEvent(eventList); |
@@ -387,9 +387,4 @@ public class CarPropertyService extends ICarProperty.Stub | |||
387 | + toHexString(property)); | 387 | + toHexString(property)); |
388 | } | 388 | } |
389 | } | 389 | } |
390 | |||
391 | private static CarPropertyEvent createErrorEvent(int property, int area) { | ||
392 | return new CarPropertyEvent(CarPropertyEvent.PROPERTY_EVENT_ERROR, | ||
393 | new CarPropertyValue<>(property, area, null)); | ||
394 | } | ||
395 | } | 390 | } |
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java index 67c50a75..8d4212a6 100644 --- a/service/src/com/android/car/ICarImpl.java +++ b/service/src/com/android/car/ICarImpl.java | |||
@@ -427,6 +427,7 @@ public class ICarImpl extends ICar.Stub { | |||
427 | private static final String COMMAND_HELP = "-h"; | 427 | private static final String COMMAND_HELP = "-h"; |
428 | private static final String COMMAND_DAY_NIGHT_MODE = "day-night-mode"; | 428 | private static final String COMMAND_DAY_NIGHT_MODE = "day-night-mode"; |
429 | private static final String COMMAND_INJECT_VHAL_EVENT = "inject-vhal-event"; | 429 | private static final String COMMAND_INJECT_VHAL_EVENT = "inject-vhal-event"; |
430 | private static final String COMMAND_INJECT_ERROR_EVENT = "inject-error-event"; | ||
430 | private static final String COMMAND_ENABLE_UXR = "enable-uxr"; | 431 | private static final String COMMAND_ENABLE_UXR = "enable-uxr"; |
431 | private static final String COMMAND_GARAGE_MODE = "garage-mode"; | 432 | private static final String COMMAND_GARAGE_MODE = "garage-mode"; |
432 | private static final String COMMAND_GET_DO_ACTIVITIES = "get-do-activities"; | 433 | private static final String COMMAND_GET_DO_ACTIVITIES = "get-do-activities"; |
@@ -448,6 +449,8 @@ public class ICarImpl extends ICar.Stub { | |||
448 | pw.println("\t Force into day/night mode or restore to auto."); | 449 | pw.println("\t Force into day/night mode or restore to auto."); |
449 | pw.println("\tinject-vhal-event property [zone] data(can be comma separated list)"); | 450 | pw.println("\tinject-vhal-event property [zone] data(can be comma separated list)"); |
450 | pw.println("\t Inject a vehicle property for testing"); | 451 | pw.println("\t Inject a vehicle property for testing"); |
452 | pw.println("\tinject-error-event property zone errorCode"); | ||
453 | pw.println("\t Inject an error event from VHAL for testing."); | ||
451 | pw.println("\tdisable-uxr true|false"); | 454 | pw.println("\tdisable-uxr true|false"); |
452 | pw.println("\t Disable UX restrictions and App blocking."); | 455 | pw.println("\t Disable UX restrictions and App blocking."); |
453 | pw.println("\tgarage-mode [on|off|query]"); | 456 | pw.println("\tgarage-mode [on|off|query]"); |
@@ -487,7 +490,17 @@ public class ICarImpl extends ICar.Stub { | |||
487 | // Global | 490 | // Global |
488 | data = args[2]; | 491 | data = args[2]; |
489 | } | 492 | } |
490 | injectVhalEvent(args[1], zone, data, writer); | 493 | injectVhalEvent(args[1], zone, data, false, writer); |
494 | break; | ||
495 | case COMMAND_INJECT_ERROR_EVENT: | ||
496 | if (args.length != 4) { | ||
497 | writer.println("Incorrect number of arguments"); | ||
498 | dumpHelp(writer); | ||
499 | break; | ||
500 | } | ||
501 | String errorAreaId = args[2]; | ||
502 | String errorCode = args[3]; | ||
503 | injectVhalEvent(args[1], errorAreaId, errorCode, true, writer); | ||
491 | break; | 504 | break; |
492 | case COMMAND_ENABLE_UXR: | 505 | case COMMAND_ENABLE_UXR: |
493 | if (args.length < 2) { | 506 | if (args.length < 2) { |
@@ -584,11 +597,12 @@ public class ICarImpl extends ICar.Stub { | |||
584 | * | 597 | * |
585 | * @param property the Vehicle property Id as defined in the HAL | 598 | * @param property the Vehicle property Id as defined in the HAL |
586 | * @param zone Zone that this event services | 599 | * @param zone Zone that this event services |
600 | * @param isErrorEvent indicates the type of event | ||
587 | * @param value Data value of the event | 601 | * @param value Data value of the event |
588 | * @param writer PrintWriter | 602 | * @param writer PrintWriter |
589 | */ | 603 | */ |
590 | private void injectVhalEvent(String property, String zone, String value, | 604 | private void injectVhalEvent(String property, String zone, String value, |
591 | PrintWriter writer) { | 605 | boolean isErrorEvent, PrintWriter writer) { |
592 | if (zone != null && (zone.equalsIgnoreCase(PARAM_VEHICLE_PROPERTY_AREA_GLOBAL))) { | 606 | if (zone != null && (zone.equalsIgnoreCase(PARAM_VEHICLE_PROPERTY_AREA_GLOBAL))) { |
593 | if (!isPropertyAreaTypeGlobal(property)) { | 607 | if (!isPropertyAreaTypeGlobal(property)) { |
594 | writer.println("Property area type inconsistent with given zone"); | 608 | writer.println("Property area type inconsistent with given zone"); |
@@ -596,7 +610,11 @@ public class ICarImpl extends ICar.Stub { | |||
596 | } | 610 | } |
597 | } | 611 | } |
598 | try { | 612 | try { |
599 | mHal.injectVhalEvent(property, zone, value); | 613 | if (isErrorEvent) { |
614 | mHal.injectOnPropertySetError(property, zone, value); | ||
615 | } else { | ||
616 | mHal.injectVhalEvent(property, zone, value); | ||
617 | } | ||
600 | } catch (NumberFormatException e) { | 618 | } catch (NumberFormatException e) { |
601 | writer.println("Invalid property Id zone Id or value" + e); | 619 | writer.println("Invalid property Id zone Id or value" + e); |
602 | dumpHelp(writer); | 620 | dumpHelp(writer); |
diff --git a/service/src/com/android/car/hal/VehicleHal.java b/service/src/com/android/car/hal/VehicleHal.java index f73d07c0..70953b63 100644 --- a/service/src/com/android/car/hal/VehicleHal.java +++ b/service/src/com/android/car/hal/VehicleHal.java | |||
@@ -552,6 +552,23 @@ public class VehicleHal extends IVehicleCallback.Stub { | |||
552 | onPropertyEvent(Lists.newArrayList(v)); | 552 | onPropertyEvent(Lists.newArrayList(v)); |
553 | } | 553 | } |
554 | 554 | ||
555 | /** | ||
556 | * Inject an error event. | ||
557 | * | ||
558 | * @param property the Vehicle property Id as defined in the HAL | ||
559 | * @param zone Zone for the event to inject | ||
560 | * @param errorCode Error code return from HAL | ||
561 | */ | ||
562 | public void injectOnPropertySetError(String property, String zone, String errorCode) { | ||
563 | if (zone == null || property == null || errorCode == null) { | ||
564 | return; | ||
565 | } | ||
566 | int propId = Integer.decode(property); | ||
567 | int zoneId = Integer.decode(zone); | ||
568 | int errorId = Integer.decode(errorCode); | ||
569 | onPropertySetError(errorId, propId, zoneId); | ||
570 | } | ||
571 | |||
555 | private static class VehiclePropertyEventInfo { | 572 | private static class VehiclePropertyEventInfo { |
556 | private int eventCount; | 573 | private int eventCount; |
557 | private VehiclePropValue lastEvent; | 574 | private VehiclePropValue lastEvent; |