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

Commit 652e175d authored by Sneha Patil's avatar Sneha Patil Committed by Shunkai Yao
Browse files

HapticGenerator: Update process of the effect

Add Vibrator Capabilities
Minor fix in the ToString implementation

Flag: EXEMPT bugfix
Bug: 337294664
Test: atest VtsHalHapticGeneratorTargetTest
Test: Haptic generator test APP on Pixel 9
Change-Id: If343b4700705d2544994e930712be596e7e1f377
parent 927a0dd3
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -55,6 +55,17 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip

namespace aidl::android::hardware::audio::effect {

const std::vector<Range::HapticGeneratorRange> kHapticRange = {
        MAKE_RANGE(HapticGenerator, vibratorInfo,
                   HapticGenerator::VibratorInformation(
                           {.resonantFrequencyHz = 1, .qFactor = 1, .maxAmplitude = -1}),
                   HapticGenerator::VibratorInformation(
                           {.resonantFrequencyHz = std::numeric_limits<float>::max(),
                            .qFactor = std::numeric_limits<float>::max(),
                            .maxAmplitude = 1}))};

static const Capability kHapticCap = {.range = kHapticRange};

const std::string HapticGeneratorImpl::kEffectName = "Haptic Generator";
const Descriptor HapticGeneratorImpl::kDescriptor = {
        .common = {.id = {.type = getEffectTypeUuidHapticGenerator(),
@@ -62,7 +73,8 @@ const Descriptor HapticGeneratorImpl::kDescriptor = {
                          .proxy = std::nullopt},
                   .flags = {.type = Flags::Type::INSERT, .insert = Flags::Insert::FIRST},
                   .name = HapticGeneratorImpl::kEffectName,
                   .implementor = "The Android Open Source Project"}};
                   .implementor = "The Android Open Source Project"},
        .capability = kHapticCap};

ndk::ScopedAStatus HapticGeneratorImpl::getDescriptor(Descriptor* _aidl_return) {
    RETURN_IF(!_aidl_return, EX_ILLEGAL_ARGUMENT, "Parameter:nullptr");
@@ -76,6 +88,8 @@ ndk::ScopedAStatus HapticGeneratorImpl::setParameterSpecific(const Parameter::Sp
    RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");

    auto& hgParam = specific.get<Parameter::Specific::hapticGenerator>();
    RETURN_IF(!inRange(hgParam, kHapticRange), EX_ILLEGAL_ARGUMENT, "outOfRange");

    auto tag = hgParam.getTag();

    switch (tag) {
+2 −2
Original line number Diff line number Diff line
@@ -353,7 +353,7 @@ float* HapticGeneratorContext::runProcessingChain(float* buf1, float* buf2, size

std::string HapticGeneratorContext::paramToString(const struct HapticGeneratorParam& param) const {
    std::stringstream ss;
    ss << "\t\ttHapticGenerator Parameters:\n";
    ss << "\t\tHapticGenerator Parameters:\n";
    ss << "\t\t- mHapticChannelCount: " << param.mHapticChannelCount << '\n';
    ss << "\t\t- mAudioChannelCount: " << param.mAudioChannelCount << '\n';
    ss << "\t\t- mHapticChannelSource: " << param.mHapticChannelSource[0] << ", "
@@ -378,7 +378,7 @@ std::string HapticGeneratorContext::contextToString() const {
    ss << "\t\t- distortion input gain: " << DEFAULT_DISTORTION_INPUT_GAIN << '\n';
    ss << "\t\t- distortion cube threshold: " << DEFAULT_DISTORTION_CUBE_THRESHOLD << '\n';
    ss << "\t\t- distortion output gain: " << getDistortionOutputGain() << '\n';
    ss << "\t\tHapticGenerator Parameters:\n" << paramToString(mParams) << "\n";
    ss << paramToString(mParams) << "\n";
    return ss.str();
}