From c2b71d5f12f82bbf8d9f08c2be4f54488f1fc5ca Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Mon, 6 Nov 2023 16:32:12 -0800 Subject: Don't use Android properties outside of Android Bug: 302723053 Test: mma Change-Id: I4c3e38a629ebc17495ac4d9b05360da5f5101dca --- libs/binder/tests/binderRpcTest.cpp | 9 ++++++--- libs/binder/tests/binderRpcTestCommon.h | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'libs') diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index 05b9b6ca65..b86eb94928 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -1358,7 +1358,11 @@ private: }; TEST(BinderRpc, Java) { -#if !defined(__ANDROID__) + bool expectDebuggable = false; +#if defined(__ANDROID__) + expectDebuggable = android::base::GetBoolProperty("ro.debuggable", false) && + android::base::GetProperty("ro.build.type", "") != "user"; +#else GTEST_SKIP() << "This test is only run on Android. Though it can technically run on host on" "createRpcDelegateServiceManager() with a device attached, such test belongs " "to binderHostDeviceTest. Hence, just disable this test on host."; @@ -1386,8 +1390,7 @@ TEST(BinderRpc, Java) { auto keepAlive = sp::make(); auto setRpcClientDebugStatus = binder->setRpcClientDebug(std::move(socket), keepAlive); - if (!android::base::GetBoolProperty("ro.debuggable", false) || - android::base::GetProperty("ro.build.type", "") == "user") { + if (!expectDebuggable) { ASSERT_EQ(INVALID_OPERATION, setRpcClientDebugStatus) << "setRpcClientDebug should return INVALID_OPERATION on non-debuggable or user " "builds, but get " diff --git a/libs/binder/tests/binderRpcTestCommon.h b/libs/binder/tests/binderRpcTestCommon.h index d0ec3fa576..b2b63e4bf3 100644 --- a/libs/binder/tests/binderRpcTestCommon.h +++ b/libs/binder/tests/binderRpcTestCommon.h @@ -36,9 +36,12 @@ #include #include +#ifdef __ANDROID__ +#include +#endif + #ifndef __TRUSTY__ #include -#include #include #include #include -- cgit v1.2.3-59-g8ed1b