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

Commit 4928bfd9 authored by Lais Andrade's avatar Lais Andrade
Browse files

Small rename on vibrator HAL wrapper method

Rename checkAndLogFailure to isFailedLogged, since the
boolean returned is counter-intuitive to the previous
method name.

Bug: 195595741
Test: VibratorTest
Change-Id: I3b8ec6545fa45eaf4e5942565ca84733ffa7934d
parent 567be130
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -402,12 +402,21 @@ HalResult<std::vector<milliseconds>> AidlHalWrapper::getPrimitiveDurationsIntern
        auto primitiveIdx = static_cast<size_t>(primitive);
        if (primitiveIdx >= durations.size()) {
            // Safety check, should not happen if enum_range is correct.
            ALOGE("Supported primitive %zu is outside range [0,%zu), skipping load duration",
                  primitiveIdx, durations.size());
            continue;
        }
        int32_t duration = 0;
        auto status = getHal()->getPrimitiveDuration(primitive, &duration);
        if (!status.isOk()) {
            return HalResult<std::vector<milliseconds>>::failed(status.toString8().c_str());
        auto result = getHal()->getPrimitiveDuration(primitive, &duration);
        auto halResult = HalResult<int32_t>::fromStatus(result, duration);
        if (halResult.isUnsupported()) {
            // Should not happen, supported primitives should always support requesting duration.
            ALOGE("Supported primitive %zu returned unsupported for getPrimitiveDuration",
                  primitiveIdx);
        }
        if (halResult.isFailed()) {
            // Fail entire request if one request has failed.
            return HalResult<std::vector<milliseconds>>::failed(result.toString8().c_str());
        }
        durations[primitiveIdx] = milliseconds(duration);
    }
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static constexpr int MAX_RETRIES = 1;
template <typename T>
HalResult<T> ManagerHalController::processHalResult(HalResult<T> result, const char* functionName) {
    if (result.isFailed()) {
        ALOGE("%s failed: %s", functionName, result.errorMessage());
        ALOGE("VibratorManager HAL %s failed: %s", functionName, result.errorMessage());
        std::lock_guard<std::mutex> lock(mConnectedHalMutex);
        mConnectedHal->tryReconnect();
    }
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ private:

        for (int i = 0; i < MAX_RETRIES; i++) {
            T result = halFn(hal.get());
            if (result.checkAndLogFailure(functionName)) {
            if (result.isFailedLogged(functionName)) {
                tryReconnect();
            } else {
                return result;
+19 −19
Original line number Diff line number Diff line
@@ -69,9 +69,9 @@ public:
    bool isFailed() const { return !mUnsupported && !mValue.has_value(); }
    bool isUnsupported() const { return mUnsupported; }
    const char* errorMessage() const { return mErrorMessage.c_str(); }
    bool checkAndLogFailure(const char* functionName) const {
    bool isFailedLogged(const char* functionNameForLogging) const {
        if (isFailed()) {
            ALOGE("%s failed: %s", functionName, errorMessage());
            ALOGE("Vibrator HAL %s failed: %s", functionNameForLogging, errorMessage());
            return true;
        }
        return false;
@@ -107,9 +107,9 @@ public:
    bool isFailed() const { return !mUnsupported && mFailed; }
    bool isUnsupported() const { return mUnsupported; }
    const char* errorMessage() const { return mErrorMessage.c_str(); }
    bool checkAndLogFailure(const char* functionName) const {
    bool isFailedLogged(const char* functionNameForLogging) const {
        if (isFailed()) {
            ALOGE("%s failed: %s", functionName, errorMessage());
            ALOGE("Vibrator HAL %s failed: %s", functionNameForLogging, errorMessage());
            return true;
        }
        return false;
@@ -192,21 +192,21 @@ public:
    const HalResult<float> qFactor;
    const HalResult<std::vector<float>> maxAmplitudes;

    bool checkAndLogFailure(const char*) const {
        return capabilities.checkAndLogFailure("getCapabilities") ||
                supportedEffects.checkAndLogFailure("getSupportedEffects") ||
                supportedBraking.checkAndLogFailure("getSupportedBraking") ||
                supportedPrimitives.checkAndLogFailure("getSupportedPrimitives") ||
                primitiveDurations.checkAndLogFailure("getPrimitiveDuration") ||
                primitiveDelayMax.checkAndLogFailure("getPrimitiveDelayMax") ||
                pwlePrimitiveDurationMax.checkAndLogFailure("getPwlePrimitiveDurationMax") ||
                compositionSizeMax.checkAndLogFailure("getCompositionSizeMax") ||
                pwleSizeMax.checkAndLogFailure("getPwleSizeMax") ||
                minFrequency.checkAndLogFailure("getMinFrequency") ||
                resonantFrequency.checkAndLogFailure("getResonantFrequency") ||
                frequencyResolution.checkAndLogFailure("getFrequencyResolution") ||
                qFactor.checkAndLogFailure("getQFactor") ||
                maxAmplitudes.checkAndLogFailure("getMaxAmplitudes");
    bool isFailedLogged(const char*) const {
        return capabilities.isFailedLogged("getCapabilities") ||
                supportedEffects.isFailedLogged("getSupportedEffects") ||
                supportedBraking.isFailedLogged("getSupportedBraking") ||
                supportedPrimitives.isFailedLogged("getSupportedPrimitives") ||
                primitiveDurations.isFailedLogged("getPrimitiveDuration") ||
                primitiveDelayMax.isFailedLogged("getPrimitiveDelayMax") ||
                pwlePrimitiveDurationMax.isFailedLogged("getPwlePrimitiveDurationMax") ||
                compositionSizeMax.isFailedLogged("getCompositionSizeMax") ||
                pwleSizeMax.isFailedLogged("getPwleSizeMax") ||
                minFrequency.isFailedLogged("getMinFrequency") ||
                resonantFrequency.isFailedLogged("getResonantFrequency") ||
                frequencyResolution.isFailedLogged("getFrequencyResolution") ||
                qFactor.isFailedLogged("getQFactor") ||
                maxAmplitudes.isFailedLogged("getMaxAmplitudes");
    }
};