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

Commit 681846f0 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio VTS: Reset HAL after setConnectionState



There is no way of restoring the HAL state without restarting it.

Bug: 111681420
Test: atest VtsHalAudioV4_0TargetTest
      Check that the HAL is restarting after the test in the logcat
Change-Id: I9e3d9da08ed9e8dc25c7fc05c2bafa5455727508
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 575c63f7
Loading
Loading
Loading
Loading
+19 −9
Original line number Original line Diff line number Diff line
@@ -16,6 +16,17 @@


#include "AudioPrimaryHidlHalTest.h"
#include "AudioPrimaryHidlHalTest.h"


static void waitForDeviceDestruction() {
    // FIXME: there is no way to know when the remote IDevice is being destroyed
    //        Binder does not support testing if an object is alive, thus
    //        wait for 100ms to let the binder destruction propagates and
    //        the remote device has the time to be destroyed.
    //        flushCommand makes sure all local command are sent, thus should reduce
    //        the latency between local and remote destruction.
    IPCThreadState::self()->flushCommands();
    usleep(100);
}

TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
    doc::test("Calling openDevice(\"primary\") should return the primary device.");
    doc::test("Calling openDevice(\"primary\") should return the primary device.");
    {
    {
@@ -29,14 +40,7 @@ TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
        ASSERT_TRUE(primaryDevice.isOk());
        ASSERT_TRUE(primaryDevice.isOk());
        ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr);
        ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr);
    }  // Destroy local IDevice proxy
    }  // Destroy local IDevice proxy
    // FIXME: there is no way to know when the remote IDevice is being destroyed
    waitForDeviceDestruction();
    //        Binder does not support testing if an object is alive, thus
    //        wait for 100ms to let the binder destruction propagates and
    //        the remote device has the time to be destroyed.
    //        flushCommand makes sure all local command are sent, thus should reduce
    //        the latency between local and remote destruction.
    IPCThreadState::self()->flushCommands();
    usleep(100);
}
}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -133,11 +137,17 @@ TEST_F(AudioPrimaryHidlTest, SetConnectedState) {
            ASSERT_TRUE(ret.isOk());
            ASSERT_TRUE(ret.isOk());
            if (ret == Result::NOT_SUPPORTED) {
            if (ret == Result::NOT_SUPPORTED) {
                doc::partialTest("setConnectedState is not supported");
                doc::partialTest("setConnectedState is not supported");
                return;
                break;  // other deviceType might be supported
            }
            }
            ASSERT_OK(ret);
            ASSERT_OK(ret);
        }
        }
    }
    }

    // Because there is no way of knowing if the devices were connected before
    // calling setConnectedState, there is no way to restore the HAL to its
    // initial state. To workaround this, destroy the HAL at the end of this test.
    device.clear();
    waitForDeviceDestruction();
}
}


static void testGetDevices(IStream* stream, AudioDevice expectedDevice) {
static void testGetDevices(IStream* stream, AudioDevice expectedDevice) {