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

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

Merge "Pass property set error to subscribed clients." into udc-qpr-dev

parents e958fdd5 fda1197d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1808,6 +1808,7 @@ void FakeVehicleHardware::registerOnPropertyChangeEvent(

void FakeVehicleHardware::registerOnPropertySetErrorEvent(
        std::unique_ptr<const PropertySetErrorCallback> callback) {
    // In FakeVehicleHardware, we will never use mOnPropertySetErrorCallback.
    if (mOnPropertySetErrorCallback != nullptr) {
        ALOGE("registerOnPropertySetErrorEvent must only be called once");
        return;
+7 −1
Original line number Diff line number Diff line
@@ -107,12 +107,18 @@ class SubscriptionClient final : public ConnectedClient {
    // Gets the callback to be called when the request for this client has finished.
    std::shared_ptr<const IVehicleHardware::GetValuesCallback> getResultCallback();

    // Marshals the updated values into largeParcelable and sents it through {@code onPropertyEvent}
    // Marshals the updated values into largeParcelable and sends it through {@code onPropertyEvent}
    // callback.
    static void sendUpdatedValues(
            CallbackType callback,
            std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropValue>&&
                    updatedValues);
    // Marshals the set property error events into largeParcelable and sends it through
    // {@code onPropertySetError} callback.
    static void sendPropertySetErrors(
            CallbackType callback,
            std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropError>&&
                    vehiclePropErrors);

  protected:
    // Gets the callback to be called when the request for this client has timeout.
+5 −1
Original line number Diff line number Diff line
@@ -249,10 +249,14 @@ class DefaultVehicleHal final : public aidl::android::hardware::automotive::vehi
            const CallbackType& callback, std::shared_ptr<PendingRequestPool> pendingRequestPool);

    static void onPropertyChangeEvent(
            std::weak_ptr<SubscriptionManager> subscriptionManager,
            const std::weak_ptr<SubscriptionManager>& subscriptionManager,
            const std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropValue>&
                    updatedValues);

    static void onPropertySetErrorEvent(
            const std::weak_ptr<SubscriptionManager>& subscriptionManager,
            const std::vector<SetValueErrorEvent>& errorEvents);

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

+6 −0
Original line number Diff line number Diff line
@@ -99,6 +99,12 @@ class SubscriptionManager final {
            const std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropValue>&
                    updatedValues);

    // For a list of set property error events, returns a map that maps clients subscribing to the
    // properties to a list of errors for each client.
    std::unordered_map<CallbackType,
                       std::vector<aidl::android::hardware::automotive::vehicle::VehiclePropError>>
    getSubscribedClientsForErrorEvents(const std::vector<SetValueErrorEvent>& errorEvents);

    // Checks whether the sample rate is valid.
    static bool checkSampleRateHz(float sampleRateHz);

+30 −1
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ using ::aidl::android::hardware::automotive::vehicle::IVehicleCallback;
using ::aidl::android::hardware::automotive::vehicle::SetValueResult;
using ::aidl::android::hardware::automotive::vehicle::SetValueResults;
using ::aidl::android::hardware::automotive::vehicle::StatusCode;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropError;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropErrors;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropValue;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropValues;
using ::android::base::Result;
@@ -300,7 +302,34 @@ void SubscriptionClient::sendUpdatedValues(std::shared_ptr<IVehicleCallback> cal
    if (ScopedAStatus callbackStatus =
                callback->onPropertyEvent(vehiclePropValues, sharedMemoryFileCount);
        !callbackStatus.isOk()) {
        ALOGE("subscribe: failed to call UpdateValues callback, client ID: %p, error: %s, "
        ALOGE("subscribe: failed to call onPropertyEvent callback, client ID: %p, error: %s, "
              "exception: %d, service specific error: %d",
              callback->asBinder().get(), callbackStatus.getMessage(),
              callbackStatus.getExceptionCode(), callbackStatus.getServiceSpecificError());
    }
}

void SubscriptionClient::sendPropertySetErrors(std::shared_ptr<IVehicleCallback> callback,
                                               std::vector<VehiclePropError>&& vehiclePropErrors) {
    if (vehiclePropErrors.empty()) {
        return;
    }

    VehiclePropErrors vehiclePropErrorsLargeParcelable;
    ScopedAStatus status = vectorToStableLargeParcelable(std::move(vehiclePropErrors),
                                                         &vehiclePropErrorsLargeParcelable);
    if (!status.isOk()) {
        int statusCode = status.getServiceSpecificError();
        ALOGE("subscribe: failed to marshal result into large parcelable, error: "
              "%s, code: %d",
              status.getMessage(), statusCode);
        return;
    }

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