Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe03a2ca authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I2e938c7a,I7271a609,I2330bb21 into main

* changes:
  Add toString method to VehicleProperty enum.
  Add binder lifecycle monitor.
  Implement supported value change callback.
parents 48572a98 4e18ede1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.hardware.automotive.vehicle;
/**
 * Test vendor properties used in reference VHAL implementation.
 */
@JavaDerive(toString=true)
@Backing(type="int")
enum TestVendorProperty {

+4 −0
Original line number Diff line number Diff line
@@ -116,6 +116,10 @@ class SubscriptionClient {
            CallbackType callback,
            std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropError>&&
                    vehiclePropErrors);

    // Invokes onSupportedValueChange callback.
    static void sendSupportedValueChangeEvents(CallbackType callback,
                                               std::vector<PropIdAreaId> propIdAreaIds);
};

}  // namespace vehicle
+4 −0
Original line number Diff line number Diff line
@@ -255,6 +255,10 @@ class DefaultVehicleHal final : public aidlvhal::BnVehicle {
            const std::weak_ptr<SubscriptionManager>& subscriptionManager,
            const std::vector<SetValueErrorEvent>& errorEvents);

    static void onSupportedValueChange(
            const std::weak_ptr<SubscriptionManager>& subscriptionManager,
            const std::vector<PropIdAreaId>& updatedPropIdAreaIds);

    static void checkHealth(IVehicleHardware* hardware,
                            std::weak_ptr<SubscriptionManager> subscriptionManager);

+5 −0
Original line number Diff line number Diff line
@@ -118,6 +118,11 @@ class SubscriptionManager final {
                       std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropError>>
    getSubscribedClientsForErrorEvents(const std::vector<SetValueErrorEvent>& errorEvents);

    // For a list of [propId, areaId]s that has updated supported value, returns a map that maps
    // subscribing clients to updated [propId, areaId]s.
    std::unordered_map<CallbackType, std::vector<PropIdAreaId>>
    getSubscribedClientsForSupportedValueChange(const std::vector<PropIdAreaId>& propIdAreaIds);

    // Subscribes to supported values change.
    VhalResult<void> subscribeSupportedValueChange(const CallbackType& callback,
                                                   const std::vector<PropIdAreaId>& propIdAreaIds);
+24 −0
Original line number Diff line number Diff line
@@ -306,6 +306,30 @@ void SubscriptionClient::sendPropertySetErrors(std::shared_ptr<IVehicleCallback>
    }
}

void SubscriptionClient::sendSupportedValueChangeEvents(std::shared_ptr<IVehicleCallback> callback,
                                                        std::vector<PropIdAreaId> propIdAreaIds) {
    if (propIdAreaIds.empty()) {
        return;
    }

    std::vector<aidl::android::hardware::automotive::vehicle::PropIdAreaId> vhalPropIdAreaIds;
    for (const auto& propIdAreaId : propIdAreaIds) {
        vhalPropIdAreaIds.push_back(aidl::android::hardware::automotive::vehicle::PropIdAreaId{
                .propId = propIdAreaId.propId,
                .areaId = propIdAreaId.areaId,
        });
    }

    if (ScopedAStatus callbackStatus = callback->onSupportedValueChange(vhalPropIdAreaIds);
        !callbackStatus.isOk()) {
        ALOGE("subscribe: failed to call onSupportedValueChange callback, client ID: %p, error: "
              "%s, "
              "exception: %d, service specific error: %d",
              callback->asBinder().get(), callbackStatus.getMessage(),
              callbackStatus.getExceptionCode(), callbackStatus.getServiceSpecificError());
    }
}

}  // namespace vehicle
}  // namespace automotive
}  // namespace hardware
Loading