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

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

Interpret STATUS_UNKNOWN_TRANSACTION as a unsupported vibrator result

The AIDL versioning documentation says this is the exception code
returned by older versions that do not implement the methods:
https://source.android.com/devices/architecture/aidl/stable-aidl#versioning-interfaces

Update the vibrator::HalResult for this exception code to be
unsupported, which will prevent the service from retrying this operation
on that device.

Bug: 190526054
Test: libvibratorservice_test
Change-Id: Ifdc9c02431ec7c3ad3fd54b62049e15766f6a5a1
parent c2baccc4
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -95,7 +95,10 @@ HalResult<void> HalResult<void>::fromStatus(status_t status) {
}

HalResult<void> HalResult<void>::fromStatus(binder::Status status) {
    if (status.exceptionCode() == binder::Status::EX_UNSUPPORTED_OPERATION) {
    if (status.exceptionCode() == binder::Status::EX_UNSUPPORTED_OPERATION ||
        status.transactionError() == android::UNKNOWN_TRANSACTION) {
        // UNKNOWN_TRANSACTION means the HAL implementation is an older version, so this is
        // the same as the operation being unsupported by this HAL. Should not retry.
        return HalResult<void>::unsupported();
    }
    if (status.isOk()) {
+4 −1
Original line number Diff line number Diff line
@@ -42,7 +42,10 @@ public:
    static HalResult<T> unsupported() { return HalResult("", /* unsupported= */ true); }

    static HalResult<T> fromStatus(binder::Status status, T data) {
        if (status.exceptionCode() == binder::Status::EX_UNSUPPORTED_OPERATION) {
        if (status.exceptionCode() == binder::Status::EX_UNSUPPORTED_OPERATION ||
            status.transactionError() == android::UNKNOWN_TRANSACTION) {
            // UNKNOWN_TRANSACTION means the HAL implementation is an older version, so this is
            // the same as the operation being unsupported by this HAL. Should not retry.
            return HalResult<T>::unsupported();
        }
        if (status.isOk()) {
+7 −14
Original line number Diff line number Diff line
@@ -189,8 +189,7 @@ TEST_F(VibratorHalWrapperAidlTest, TestOnWithoutCallbackSupport) {
                .WillRepeatedly(vibrator::TriggerSchedulerCallback());
        EXPECT_CALL(*mMockHal.get(), on(Eq(11), _))
                .Times(Exactly(1))
                .WillRepeatedly(Return(
                        Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
                .WillRepeatedly(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)));
        EXPECT_CALL(*mMockHal.get(), on(Eq(12), _))
                .Times(Exactly(1))
                .WillRepeatedly(Return(Status::fromExceptionCode(Status::Exception::EX_SECURITY)));
@@ -228,8 +227,7 @@ TEST_F(VibratorHalWrapperAidlTest, TestSetAmplitude) {
        EXPECT_CALL(*mMockHal.get(), setAmplitude(Eq(0.1f))).Times(Exactly(1));
        EXPECT_CALL(*mMockHal.get(), setAmplitude(Eq(0.2f)))
                .Times(Exactly(1))
                .WillRepeatedly(Return(
                        Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
                .WillRepeatedly(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)));
        EXPECT_CALL(*mMockHal.get(), setAmplitude(Eq(0.5f)))
                .Times(Exactly(1))
                .WillRepeatedly(Return(Status::fromExceptionCode(Status::Exception::EX_SECURITY)));
@@ -265,8 +263,7 @@ TEST_F(VibratorHalWrapperAidlTest, TestAlwaysOnEnable) {
        EXPECT_CALL(*mMockHal.get(),
                    alwaysOnEnable(Eq(2), Eq(Effect::TICK), Eq(EffectStrength::MEDIUM)))
                .Times(Exactly(1))
                .WillRepeatedly(Return(
                        Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
                .WillRepeatedly(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)));
        EXPECT_CALL(*mMockHal.get(),
                    alwaysOnEnable(Eq(3), Eq(Effect::POP), Eq(EffectStrength::STRONG)))
                .Times(Exactly(1))
@@ -397,8 +394,7 @@ TEST_F(VibratorHalWrapperAidlTest, TestGetInfoCachesResult) {
                    Return(Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
    EXPECT_CALL(*mMockHal.get(), getSupportedPrimitives(_))
            .Times(Exactly(1))
            .WillRepeatedly(
                    Return(Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
            .WillRepeatedly(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)));
    EXPECT_CALL(*mMockHal.get(), getFrequencyMinimum(_))
            .Times(Exactly(1))
            .WillRepeatedly(DoAll(SetArgPointee<0>(F_MIN), Return(Status())));
@@ -411,8 +407,7 @@ TEST_F(VibratorHalWrapperAidlTest, TestGetInfoCachesResult) {
                    Return(Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
    EXPECT_CALL(*mMockHal.get(), getBandwidthAmplitudeMap(_))
            .Times(Exactly(1))
            .WillRepeatedly(
                    Return(Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
            .WillRepeatedly(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)));
    EXPECT_CALL(*mMockHal.get(), getSupportedBraking(_))
            .Times(Exactly(1))
            .WillRepeatedly(
@@ -451,8 +446,7 @@ TEST_F(VibratorHalWrapperAidlTest, TestPerformEffectWithCallbackSupport) {
                        DoAll(SetArgPointee<3>(1000), TriggerCallbackInArg2(), Return(Status())));
        EXPECT_CALL(*mMockHal.get(), perform(Eq(Effect::POP), Eq(EffectStrength::MEDIUM), _, _))
                .Times(Exactly(1))
                .WillRepeatedly(Return(
                        Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
                .WillRepeatedly(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)));
        EXPECT_CALL(*mMockHal.get(), perform(Eq(Effect::THUD), Eq(EffectStrength::STRONG), _, _))
                .Times(Exactly(1))
                .WillRepeatedly(Return(Status::fromExceptionCode(Status::Exception::EX_SECURITY)));
@@ -549,8 +543,7 @@ TEST_F(VibratorHalWrapperAidlTest, TestPerformComposedEffect) {
                .WillRepeatedly(DoAll(TriggerCallbackInArg1(), Return(Status())));
        EXPECT_CALL(*mMockHal.get(), compose(Eq(singleEffect), _))
                .Times(Exactly(1))
                .WillRepeatedly(Return(
                        Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)));
                .WillRepeatedly(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)));
        EXPECT_CALL(*mMockHal.get(), compose(Eq(multipleEffects), _))
                .Times(Exactly(1))
                .WillRepeatedly(Return(Status::fromExceptionCode(Status::Exception::EX_SECURITY)));
+2 −4
Original line number Diff line number Diff line
@@ -308,8 +308,7 @@ TEST_F(VibratorManagerHalWrapperAidlTest, TestTriggerSyncedWithCallbackSupport)
                                      Return(Status())));
        EXPECT_CALL(*mMockHal.get(), triggerSynced(_))
                .Times(Exactly(3))
                .WillOnce(Return(
                        Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)))
                .WillOnce(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)))
                .WillOnce(Return(Status::fromExceptionCode(Status::Exception::EX_SECURITY)))
                .WillRepeatedly(DoAll(TriggerCallback(), Return(Status())));
    }
@@ -345,8 +344,7 @@ TEST_F(VibratorManagerHalWrapperAidlTest, TestTriggerSyncedWithoutCallbackSuppor
TEST_F(VibratorManagerHalWrapperAidlTest, TestCancelSynced) {
    EXPECT_CALL(*mMockHal.get(), cancelSynced())
            .Times(Exactly(3))
            .WillOnce(
                    Return(Status::fromExceptionCode(Status::Exception::EX_UNSUPPORTED_OPERATION)))
            .WillOnce(Return(Status::fromStatusT(UNKNOWN_TRANSACTION)))
            .WillOnce(Return(Status::fromExceptionCode(Status::Exception::EX_SECURITY)))
            .WillRepeatedly(Return(Status()));