Power: allow vts to pass with earlier version of server

Bug: 189976527
Test: Build
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I3e1ce05e62e9581c9a66f65e82e1599d77de7a85
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp
index 5bb088a..ffab66c 100644
--- a/power/aidl/vts/VtsHalPowerTargetTest.cpp
+++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp
@@ -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 @@
         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 @@
     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 @@
     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 @@
     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 @@
     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);