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

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

Snap for 12265118 from 697bd220 to 24Q4-release

Change-Id: I9e2ebb6297d542657f567b4cd327f527371b3690
parents 868b5e80 697bd220
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <com_android_graphics_libgui_flags.h>
#include <gui/SurfaceComposerClient.h>
#include <ui/DisplayMode.h>

@@ -202,6 +203,14 @@ bool GLHelper::getShaderProgram(const char* name, GLuint* outPgm) {

bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
        sp<GLConsumer>* glConsumer, EGLSurface* surface) {
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
    sp<GLConsumer> glc = new GLConsumer(name, GL_TEXTURE_EXTERNAL_OES, false, true);
    glc->setDefaultBufferSize(w, h);
    glc->getSurface()->setMaxDequeuedBufferCount(2);
    glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);

    sp<ANativeWindow> anw = glc->getSurface();
#else
    sp<IGraphicBufferProducer> producer;
    sp<IGraphicBufferConsumer> consumer;
    BufferQueue::createBufferQueue(&producer, &consumer);
@@ -212,6 +221,7 @@ bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
    glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);

    sp<ANativeWindow> anw = new Surface(producer);
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
    EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), nullptr);
    if (s == EGL_NO_SURFACE) {
        fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError());
+1 −1
Original line number Diff line number Diff line
@@ -771,7 +771,7 @@ const char* AIBinder_Class_getDescriptor(const AIBinder_Class* clazz) __INTRODUC
 * This provides a per-process-unique total ordering of binders where a null
 * AIBinder* object is considered to be before all other binder objects.
 * For instance, two binders refer to the same object in a local or remote
 * process when both AIBinder_lt(a, b) and AIBinder(b, a) are false. This API
 * process when both AIBinder_lt(a, b) and AIBinder_lt(b, a) are false. This API
 * might be used to insert and lookup binders in binary search trees.
 *
 * AIBinder* pointers themselves actually also create a per-process-unique total
+15 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ 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::PwleV2OutputMapEntry;
using aidl::android::hardware::vibrator::PwleV2Primitive;
using aidl::android::hardware::vibrator::VendorEffect;

using std::chrono::milliseconds;
@@ -114,6 +116,12 @@ HalResult<void> HalWrapper::performPwleEffect(const std::vector<PrimitivePwle>&,
    return HalResult<void>::unsupported();
}

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

HalResult<Capabilities> HalWrapper::getCapabilities() {
    std::lock_guard<std::mutex> lock(mInfoMutex);
    if (mInfoCache.mCapabilities.isFailed()) {
@@ -313,6 +321,13 @@ HalResult<void> AidlHalWrapper::performPwleEffect(const std::vector<PrimitivePwl
    return HalResultFactory::fromStatus(getHal()->composePwle(primitives, cb));
}

HalResult<void> AidlHalWrapper::composePwleV2(const std::vector<PwleV2Primitive>& composite,
                                              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()->composePwleV2(composite, cb));
}

HalResult<Capabilities> AidlHalWrapper::getCapabilitiesInternal() {
    int32_t cap = 0;
    auto status = getHal()->getCapabilities(&cap);
+8 −0
Original line number Diff line number Diff line
@@ -354,6 +354,8 @@ public:
    using CompositeEffect = aidl::android::hardware::vibrator::CompositeEffect;
    using Braking = aidl::android::hardware::vibrator::Braking;
    using PrimitivePwle = aidl::android::hardware::vibrator::PrimitivePwle;
    using PwleV2Primitive = aidl::android::hardware::vibrator::PwleV2Primitive;
    using PwleV2OutputMapEntry = aidl::android::hardware::vibrator::PwleV2OutputMapEntry;

    explicit HalWrapper(std::shared_ptr<CallbackScheduler> scheduler)
          : mCallbackScheduler(std::move(scheduler)) {}
@@ -391,6 +393,9 @@ public:
    virtual HalResult<void> performPwleEffect(const std::vector<PrimitivePwle>& primitives,
                                              const std::function<void()>& completionCallback);

    virtual HalResult<void> composePwleV2(const std::vector<PwleV2Primitive>& composite,
                                          const std::function<void()>& completionCallback);

protected:
    // Shared pointer to allow CallbackScheduler to outlive this wrapper.
    const std::shared_ptr<CallbackScheduler> mCallbackScheduler;
@@ -471,6 +476,9 @@ public:
            const std::vector<PrimitivePwle>& primitives,
            const std::function<void()>& completionCallback) override final;

    HalResult<void> composePwleV2(const std::vector<PwleV2Primitive>& composite,
                                  const std::function<void()>& completionCallback) override final;

protected:
    HalResult<Capabilities> getCapabilitiesInternal() override final;
    HalResult<std::vector<Effect>> getSupportedEffectsInternal() override final;
+36 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ using aidl::android::hardware::vibrator::EffectStrength;
using aidl::android::hardware::vibrator::IVibrator;
using aidl::android::hardware::vibrator::IVibratorCallback;
using aidl::android::hardware::vibrator::PrimitivePwle;
using aidl::android::hardware::vibrator::PwleV2Primitive;
using aidl::android::hardware::vibrator::VendorEffect;
using aidl::android::os::PersistableBundle;

@@ -681,3 +682,38 @@ TEST_F(VibratorHalWrapperAidlTest, TestPerformPwleEffect) {
    ASSERT_TRUE(result.isOk());
    ASSERT_EQ(1, *callbackCounter.get());
}

TEST_F(VibratorHalWrapperAidlTest, TestComposePwleV2) {
    auto pwleEffect = {
            PwleV2Primitive(/*amplitude=*/0.2, /*frequency=*/50, /*time=*/100),
            PwleV2Primitive(/*amplitude=*/0.5, /*frequency=*/150, /*time=*/100),
            PwleV2Primitive(/*amplitude=*/0.8, /*frequency=*/250, /*time=*/100),
    };

    {
        InSequence seq;
        EXPECT_CALL(*mMockHal.get(), composePwleV2(_, _))
                .Times(Exactly(3))
                .WillOnce(Return(ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION)))
                .WillOnce(Return(ndk::ScopedAStatus::fromExceptionCode(EX_SECURITY)))
                .WillOnce(DoAll(WithArg<1>(vibrator::TriggerCallback()),
                                Return(ndk::ScopedAStatus::ok())));
    }

    std::unique_ptr<int32_t> callbackCounter = std::make_unique<int32_t>();
    auto callback = vibrator::TestFactory::createCountingCallback(callbackCounter.get());

    auto result = mWrapper->composePwleV2(pwleEffect, callback);
    ASSERT_TRUE(result.isUnsupported());
    // Callback not triggered on failure
    ASSERT_EQ(0, *callbackCounter.get());

    result = mWrapper->composePwleV2(pwleEffect, callback);
    ASSERT_TRUE(result.isFailed());
    // Callback not triggered for unsupported
    ASSERT_EQ(0, *callbackCounter.get());

    result = mWrapper->composePwleV2(pwleEffect, callback);
    ASSERT_TRUE(result.isOk());
    ASSERT_EQ(1, *callbackCounter.get());
}
Loading