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

Commit f172ea15 authored by Lais Andrade's avatar Lais Andrade
Browse files

Add support for IVibration.performVendorEffect

Support new @SystemApi for vendor-specific vibration effects.

Fix: 345405987
Flag: android.os.vibrator.vendor_vibration_effects
Test: libvibratorservice_test
Change-Id: I53d8e7dfa5430d098037aa97c3e2de6c8c95861d
parent 2477c060
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ package {
cc_defaults {
    name: "idlcli-defaults",
    shared_libs: [
        "android.hardware.vibrator-V2-ndk",
        "android.hardware.vibrator-V3-ndk",
        "android.hardware.vibrator@1.0",
        "android.hardware.vibrator@1.1",
        "android.hardware.vibrator@1.2",
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ inline ndk::ScopedAStatus NullptrStatus() {
template <typename I>
inline auto getService(std::string name) {
    const auto instance = std::string() + I::descriptor + "/" + name;
    auto vibBinder = ndk::SpAIBinder(AServiceManager_getService(instance.c_str()));
    auto vibBinder = ndk::SpAIBinder(AServiceManager_checkService(instance.c_str()));
    return I::fromBinder(vibBinder);
}

+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ cc_library_shared {
        "libhidlbase",
        "liblog",
        "libutils",
        "android.hardware.vibrator-V2-ndk",
        "android.hardware.vibrator-V3-ndk",
        "android.hardware.vibrator@1.0",
        "android.hardware.vibrator@1.1",
        "android.hardware.vibrator@1.2",
+14 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ using aidl::android::hardware::vibrator::CompositePrimitive;
using aidl::android::hardware::vibrator::Effect;
using aidl::android::hardware::vibrator::EffectStrength;
using aidl::android::hardware::vibrator::PrimitivePwle;
using aidl::android::hardware::vibrator::VendorEffect;

using std::chrono::milliseconds;

@@ -96,6 +97,11 @@ Info HalWrapper::getInfo() {
    return mInfoCache.get();
}

HalResult<void> HalWrapper::performVendorEffect(const VendorEffect&, const std::function<void()>&) {
    ALOGV("Skipped performVendorEffect because it's not available in Vibrator HAL");
    return HalResult<void>::unsupported();
}

HalResult<milliseconds> HalWrapper::performComposedEffect(const std::vector<CompositeEffect>&,
                                                          const std::function<void()>&) {
    ALOGV("Skipped performComposedEffect because it's not available in Vibrator HAL");
@@ -271,6 +277,13 @@ HalResult<milliseconds> AidlHalWrapper::performEffect(
    return ret;
}

HalResult<void> AidlHalWrapper::performVendorEffect(
        const VendorEffect& effect, const std::function<void()>& completionCallback) {
    // This method should always support callbacks, so no need to double check.
    auto cb = ndk::SharedRefBase::make<HalCallbackWrapper>(completionCallback);
    return HalResultFactory::fromStatus(getHal()->performVendorEffect(effect, cb));
}

HalResult<milliseconds> AidlHalWrapper::performComposedEffect(
        const std::vector<CompositeEffect>& primitives,
        const std::function<void()>& completionCallback) {
@@ -351,7 +364,7 @@ HalResult<std::vector<milliseconds>> AidlHalWrapper::getPrimitiveDurationsIntern
        }
        if (halResult.isFailed()) {
            // Fail entire request if one request has failed.
            return HalResult<std::vector<milliseconds>>::failed(status.getMessage());
            return HalResult<std::vector<milliseconds>>::failed(halResult.errorMessage());
        }
        durations[primitiveIdx] = milliseconds(duration);
    }
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ cc_benchmark {
        "liblog",
        "libutils",
        "libvibratorservice",
        "android.hardware.vibrator-V2-ndk",
        "android.hardware.vibrator-V3-ndk",
        "android.hardware.vibrator@1.0",
        "android.hardware.vibrator@1.1",
        "android.hardware.vibrator@1.2",
Loading