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

Commit 9df909db authored by Wei Wang's avatar Wei Wang
Browse files

Power: allow vts to pass with earlier version of server



Bug: 189976527
Test: Build
Signed-off-by: default avatarWei Wang <wvw@google.com>
Change-Id: I3e1ce05e62e9581c9a66f65e82e1599d77de7a85
parent 5fe68156
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <android/binder_ibinder.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <android/binder_status.h>

#include <unistd.h>

@@ -82,6 +83,11 @@ const std::vector<WorkDuration> kDurations = {
        DurationWrapper(1000000000L, 4L),
};

inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) {
    return status.getStatus() == STATUS_UNKNOWN_TRANSACTION ||
           status.getExceptionCode() == EX_UNSUPPORTED_OPERATION;
}

class PowerAidl : public testing::TestWithParam<std::string> {
  public:
    virtual void SetUp() override {
@@ -147,7 +153,7 @@ TEST_P(PowerAidl, getHintSessionPreferredRate) {
    int64_t rate = -1;
    auto status = power->getHintSessionPreferredRate(&rate);
    if (!status.isOk()) {
        ASSERT_EQ(EX_UNSUPPORTED_OPERATION, status.getExceptionCode());
        EXPECT_TRUE(isUnknownOrUnsupported(status));
        return;
    }

@@ -159,7 +165,7 @@ TEST_P(PowerAidl, createAndCloseHintSession) {
    std::shared_ptr<IPowerHintSession> session;
    auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
    if (!status.isOk()) {
        ASSERT_EQ(EX_UNSUPPORTED_OPERATION, status.getExceptionCode());
        EXPECT_TRUE(isUnknownOrUnsupported(status));
        return;
    }
    ASSERT_NE(nullptr, session);
@@ -173,10 +179,9 @@ TEST_P(PowerAidl, createHintSessionFailed) {
    std::shared_ptr<IPowerHintSession> session;
    auto status = power->createHintSession(getpid(), getuid(), kEmptyTids, 16666666L, &session);
    ASSERT_FALSE(status.isOk());
    if (EX_UNSUPPORTED_OPERATION == status.getExceptionCode()) {
    if (isUnknownOrUnsupported(status)) {
        return;
    }
    // Test with empty tid list
    ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
}

@@ -184,7 +189,7 @@ TEST_P(PowerAidl, updateAndReportDurations) {
    std::shared_ptr<IPowerHintSession> session;
    auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
    if (!status.isOk()) {
        ASSERT_EQ(EX_UNSUPPORTED_OPERATION, status.getExceptionCode());
        EXPECT_TRUE(isUnknownOrUnsupported(status));
        return;
    }
    ASSERT_NE(nullptr, session);