diff options
author | Steven Moreland <smoreland@google.com> | 2021-04-07 22:13:13 +0000 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2021-04-07 22:13:13 +0000 |
commit | f47cdf7bbbd0efe82b0b855d47efb3ea95c2a2a6 (patch) | |
tree | 769a69fcd8a609c266da80b48d2de307c838b5cc | |
parent | 34fb6e12224989f8442699ec22d2fcbd5070a346 (diff) | |
download | libhidl-f47cdf7bbbd0efe82b0b855d47efb3ea95c2a2a6.tar.gz |
setTrebleTestingOverride: base on ro.debuggable
This was previously based on the build, but this causes hidl_test,
hidl_test_java, and fmq_test to fail on the GSI build. In order to avoid
this problem, checking this property at runtime.
Fixes: 184616522
Test: atest hidl_test hidl_test_java fmq_test
Change-Id: Ifff473fa9530557bbb3fabc3fda1b25a05249f05
-rw-r--r-- | transport/ServiceManagement.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp index c4e03c3..c638279 100644 --- a/transport/ServiceManagement.cpp +++ b/transport/ServiceManagement.cpp @@ -159,12 +159,6 @@ static constexpr bool kEnforceVintfManifest = true; static constexpr bool kEnforceVintfManifest = false; #endif -#ifdef LIBHIDL_TARGET_DEBUGGABLE -static constexpr bool kDebuggable = true; -#else -static constexpr bool kDebuggable = false; -#endif - static bool* getTrebleTestingOverridePtr() { static bool gTrebleTestingOverride = false; return &gTrebleTestingOverride; @@ -174,8 +168,13 @@ void setTrebleTestingOverride(bool testingOverride) { *getTrebleTestingOverridePtr() = testingOverride; } +static bool isDebuggable() { + static bool debuggable = base::GetBoolProperty("ro.debuggable", false); + return debuggable; +} + static inline bool isTrebleTestingOverride() { - if (kEnforceVintfManifest && !kDebuggable) { + if (kEnforceVintfManifest && !isDebuggable()) { // don't allow testing override in production return false; } @@ -766,7 +765,7 @@ sp<::android::hidl::base::V1_0::IBase> getRawServiceInternal(const std::string& const bool vintfHwbinder = (transport == Transport::HWBINDER); const bool vintfPassthru = (transport == Transport::PASSTHROUGH); const bool trebleTestingOverride = isTrebleTestingOverride(); - const bool allowLegacy = !kEnforceVintfManifest || (trebleTestingOverride && kDebuggable); + const bool allowLegacy = !kEnforceVintfManifest || (trebleTestingOverride && isDebuggable()); const bool vintfLegacy = (transport == Transport::EMPTY) && allowLegacy; if (!kEnforceVintfManifest) { |