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

Commit 90a2fc46 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12253386 from 905efed0 to 24Q4-release

Change-Id: I798889b49edafccb4c587197287005dbdca969fa
parents a2594335 905efed0
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#include <camera/CameraUtils.h>
#include <camera/StringUtils.h>

#include <com_android_graphics_libgui_flags.h>
#include <gui/BufferItemConsumer.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/Surface.h>
@@ -518,6 +519,23 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {

        // Setup a buffer queue; I'm just using the vendor opaque format here as that is
        // guaranteed to be present
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
        sp<BufferItemConsumer> opaqueConsumer = new BufferItemConsumer(
                GRALLOC_USAGE_SW_READ_NEVER, /*maxImages*/ 2, /*controlledByApp*/ true);
        EXPECT_TRUE(opaqueConsumer.get() != nullptr);
        opaqueConsumer->setName(String8("nom nom nom"));

        // Set to VGA dimens for default, as that is guaranteed to be present
        EXPECT_EQ(OK, opaqueConsumer->setDefaultBufferSize(640, 480));
        EXPECT_EQ(OK,
                  opaqueConsumer->setDefaultBufferFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED));

        sp<Surface> surface = opaqueConsumer->getSurface();

        sp<IGraphicBufferProducer> producer = surface->getIGraphicBufferProducer();
        std::string noPhysicalId;
        OutputConfiguration output(producer, /*rotation*/ 0, noPhysicalId);
#else
        sp<IGraphicBufferProducer> gbProducer;
        sp<IGraphicBufferConsumer> gbConsumer;
        BufferQueue::createBufferQueue(&gbProducer, &gbConsumer);
@@ -534,6 +552,7 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {

        std::string noPhysicalId;
        OutputConfiguration output(gbProducer, /*rotation*/0, noPhysicalId);
#endif  // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)

        // Can we configure?
        res = device->beginConfigure();
+8 −3
Original line number Diff line number Diff line
@@ -52,12 +52,17 @@ status_t AidlConversionHapticGenerator::setParameter(EffectParamReader& param) {
    switch (type) {
        case HG_PARAM_HAPTIC_INTENSITY: {
            int32_t id = 0, scale;
            if (OK != param.readFromValue(&id) || OK != param.readFromValue(&scale)) {
            float scaleFactor, adaptiveScaleFactor;
            if (OK != param.readFromValue(&id) || OK != param.readFromValue(&scale) ||
                OK != param.readFromValue(&scaleFactor) ||
                OK != param.readFromValue(&adaptiveScaleFactor)) {
                ALOGE("%s invalid intensity %s", __func__, param.toString().c_str());
                return BAD_VALUE;
            }
            HapticGenerator::HapticScale hpScale(
                    {.id = id, .scale = (HapticGenerator::VibratorScale)(scale)});
            HapticGenerator::HapticScale hpScale({.id = id,
                                                  .scale = (HapticGenerator::VibratorScale)(scale),
                                                  .scaleFactor = scaleFactor,
                                                  .adaptiveScaleFactor = adaptiveScaleFactor});
            aidlParam = MAKE_SPECIFIC_PARAMETER(HapticGenerator, hapticGenerator, hapticScales,
                                                {hpScale});
            break;
+11 −6
Original line number Diff line number Diff line
@@ -325,20 +325,25 @@ int HapticGenerator_SetParameter(struct HapticGeneratorContext *context, effect_
            ALOGE("%s invalid haptic intensity param size %s", __func__, reader.toString().c_str());
            return -EINVAL;
        }
        int32_t paramId;
        os::HapticScale hapticScale;
        if (reader.readFromValue(&paramId) != OK || reader.readFromValue(&hapticScale) != OK) {
        int32_t id, scaleLevel;
        float scaleFactor, adaptiveScaleFactor;
        if (reader.readFromValue(&id) != OK || reader.readFromValue(&scaleLevel) != OK ||
            reader.readFromValue(&scaleFactor) != OK ||
            reader.readFromValue(&adaptiveScaleFactor) != OK) {
            ALOGE("%s error reading haptic intensity %s", __func__, reader.toString().c_str());
            return -EINVAL;
        }
        os::HapticScale hapticScale(static_cast<os::HapticLevel>(scaleLevel), scaleFactor,
                                    adaptiveScaleFactor);
        ALOGD("Updating haptic scale, %s", hapticScale.toString().c_str());
        if (hapticScale.isScaleMute()) {
            context->param.id2HapticScale.erase(paramId);
            context->param.id2HapticScale.erase(id);
        } else {
            context->param.id2HapticScale.emplace(paramId, hapticScale);
            context->param.id2HapticScale.emplace(id, hapticScale);
        }
        context->param.maxHapticScale = hapticScale;
        for (const auto&[id, scale] : context->param.id2HapticScale) {
        for (const auto&[_, scale] : context->param.id2HapticScale) {
            // TODO(b/360314386): update to use new scale factors
            if (scale.getLevel() > context->param.maxHapticScale.getLevel()) {
                context->param.maxHapticScale = scale;
            }
+19 −13
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ HapticGeneratorContext::HapticGeneratorContext(int statusDepth, const Parameter:
    : EffectContext(statusDepth, common) {
    mState = HAPTIC_GENERATOR_STATE_UNINITIALIZED;

    mParams.mMaxVibratorScale = HapticGenerator::VibratorScale::MUTE;
    mParams.mMaxHapticScale = {.scale = HapticGenerator::VibratorScale::MUTE};
    mParams.mVibratorInfo.resonantFrequencyHz = DEFAULT_RESONANT_FREQUENCY;
    mParams.mVibratorInfo.qFactor = DEFAULT_BSF_ZERO_Q;
    mParams.mVibratorInfo.maxAmplitude = 0.f;
@@ -87,13 +87,17 @@ RetCode HapticGeneratorContext::reset() {
RetCode HapticGeneratorContext::setHgHapticScales(
        const std::vector<HapticGenerator::HapticScale>& hapticScales) {
    for (auto hapticScale : hapticScales) {
        mParams.mHapticScales.insert_or_assign(hapticScale.id, hapticScale.scale);
        mParams.mHapticScales.insert_or_assign(hapticScale.id, hapticScale);
    }
    mParams.mMaxVibratorScale = HapticGenerator::VibratorScale::MUTE;
    mParams.mMaxHapticScale = {.scale = HapticGenerator::VibratorScale::MUTE};
    for (const auto& [id, vibratorScale] : mParams.mHapticScales) {
        mParams.mMaxVibratorScale = std::max(mParams.mMaxVibratorScale, vibratorScale);
        // TODO(b/360314386): update to use new scale factors
        if (vibratorScale.scale > mParams.mMaxHapticScale.scale) {
            mParams.mMaxHapticScale = vibratorScale;
        }
    LOG(INFO) << " HapticGenerator VibratorScale set to " << toString(mParams.mMaxVibratorScale);
    }
    LOG(INFO) << " HapticGenerator VibratorScale set to "
              << toString(mParams.mMaxHapticScale.scale);
    return RetCode::SUCCESS;
}

@@ -103,8 +107,8 @@ HapticGenerator::VibratorInformation HapticGeneratorContext::getHgVibratorInform

std::vector<HapticGenerator::HapticScale> HapticGeneratorContext::getHgHapticScales() const {
    std::vector<HapticGenerator::HapticScale> result;
    for (const auto& [id, vibratorScale] : mParams.mHapticScales) {
        result.push_back({id, vibratorScale});
    for (const auto& [_, hapticScale] : mParams.mHapticScales) {
        result.push_back(hapticScale);
    }
    return result;
}
@@ -150,7 +154,7 @@ IEffect::Status HapticGeneratorContext::process(float* in, float* out, int sampl
        return status;
    }

    if (mParams.mMaxVibratorScale == HapticGenerator::VibratorScale::MUTE) {
    if (mParams.mMaxHapticScale.scale == HapticGenerator::VibratorScale::MUTE) {
        // Haptic channels are muted, not need to generate haptic data.
        return {STATUS_OK, samples, samples};
    }
@@ -177,9 +181,10 @@ IEffect::Status HapticGeneratorContext::process(float* in, float* out, int sampl
            runProcessingChain(mInputBuffer.data(), mOutputBuffer.data(), mFrameCount);
    ::android::os::scaleHapticData(
            hapticOutBuffer, hapticSampleCount,
            // TODO(b/356406686): add the new HapticScale fields to the AIDL interface.
            ::android::os::HapticScale(
                    static_cast<::android::os::HapticLevel>(mParams.mMaxVibratorScale)),
                    static_cast<::android::os::HapticLevel>(mParams.mMaxHapticScale.scale),
                    mParams.mMaxHapticScale.scaleFactor,
                    mParams.mMaxHapticScale.adaptiveScaleFactor),
            mParams.mVibratorInfo.maxAmplitude /* limit */);

    // For haptic data, the haptic playback thread will copy the data from effect input
@@ -353,11 +358,12 @@ std::string HapticGeneratorContext::paramToString(const struct HapticGeneratorPa
    ss << "\t\t- mAudioChannelCount: " << param.mAudioChannelCount << '\n';
    ss << "\t\t- mHapticChannelSource: " << param.mHapticChannelSource[0] << ", "
       << param.mHapticChannelSource[1] << '\n';
    ss << "\t\t- mMaxVibratorScale: " << ::android::internal::ToString(param.mMaxVibratorScale)
       << '\n';
    ss << "\t\t- mMaxHapticScale: " << ::android::internal::ToString(param.mMaxHapticScale.scale)
       << ", scaleFactor=" << param.mMaxHapticScale.scaleFactor
       << ", adaptiveScaleFactor=" << param.mMaxHapticScale.adaptiveScaleFactor << '\n';
    ss << "\t\t- mVibratorInfo: " << param.mVibratorInfo.toString() << '\n';
    for (const auto& it : param.mHapticScales)
        ss << "\t\t\t" << it.first << ": " << toString(it.second) << '\n';
        ss << "\t\t\t" << it.first << ": " << toString(it.second.scale) << '\n';

    return ss.str();
}
+2 −2
Original line number Diff line number Diff line
@@ -41,9 +41,9 @@ struct HapticGeneratorParam {
    int mHapticChannelCount;
    int mAudioChannelCount;

    std::map<int, HapticGenerator::VibratorScale> mHapticScales;
    std::map<int, HapticGenerator::HapticScale> mHapticScales;
    // max intensity will be used to scale haptic data.
    HapticGenerator::VibratorScale mMaxVibratorScale;
    HapticGenerator::HapticScale mMaxHapticScale;

    HapticGenerator::VibratorInformation mVibratorInfo;
};
Loading