Stop using deprecated __system_property_get()
If android API >= 26 (i.e. in android in-tree builds),
__system_property_read_callback() can be used instead.
Bug: 154844297
Change-Id: I9ec3d49c5e4c35281bf8405b4ae1453cd13f3179
diff --git a/test/android_test_utils.cc b/test/android_test_utils.cc
index 8c6081a..bfb1e1c 100644
--- a/test/android_test_utils.cc
+++ b/test/android_test_utils.cc
@@ -17,9 +17,9 @@
#include "test/android_test_utils.h"
#include <stdlib.h>
-#include <sys/system_properties.h>
#include "perfetto/base/logging.h"
+#include "perfetto/ext/base/android_utils.h"
#include "perfetto/ext/base/file_utils.h"
namespace perfetto {
@@ -45,17 +45,13 @@
} // namespace
bool IsDebuggableBuild() {
- char buf[PROP_VALUE_MAX + 1] = {};
- int ret = __system_property_get("ro.debuggable", buf);
- PERFETTO_CHECK(ret >= 0);
- return std::string(buf) == "1";
+ std::string debuggable = base::GetAndroidProp("ro.debuggable");
+ return debuggable == "1";
}
bool IsUserBuild() {
- char buf[PROP_VALUE_MAX + 1] = {};
- int ret = __system_property_get("ro.build.type", buf);
- PERFETTO_CHECK(ret >= 0);
- return std::string(buf) == "user";
+ std::string build_type = base::GetAndroidProp("ro.build.type");
+ return build_type == "user";
}
// note: cannot use gtest macros due to return type