summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
author Philip Chen <philipchen@google.com> 2025-03-19 18:28:30 +0000
committer Philip Chen <philipchen@google.com> 2025-03-19 21:01:26 +0000
commit1ada35c61bcc1ac0f19e035e07d6f8a02c1b6128 (patch)
treeec34f942c6b87dcf55f6a4eba80a8995177c3357 /system
parentb222cc48f25d3b010397548224baad7f7a5699fa (diff)
Enable/Disable debug features based on build type
Currently we use `ro.debuggable` sysprop to proxy the build type and enable the debug features only for userdebug & eng builds (i.e. non-user builds). Since some non-production devices (e.g. Cuttlefish) could set `ro.debuggable` even for user build, let's not rely on `ro.debuggable` but directly detect the build type via `ro.build.type`. Bug: 375056207 Test: m com.android.bt Change-Id: I9c6a2e41786863315bfb89617ec914e06de4bab5
Diffstat (limited to 'system')
-rw-r--r--system/gd/hal/snoop_logger.cc14
-rw-r--r--system/gd/hal/snoop_logger.h2
2 files changed, 8 insertions, 8 deletions
diff --git a/system/gd/hal/snoop_logger.cc b/system/gd/hal/snoop_logger.cc
index 538d13ec3e..2462834b53 100644
--- a/system/gd/hal/snoop_logger.cc
+++ b/system/gd/hal/snoop_logger.cc
@@ -55,7 +55,7 @@ static std::string GetBtSnoopMode() {
// Default mode is FILTERED on userdebug/eng build, DISABLED on user build.
// In userdebug/eng build, it can also be overwritten by modifying the global setting
std::string btsnoop_mode = SnoopLogger::kBtSnoopLogModeDisabled;
- if (os::GetSystemPropertyBool(SnoopLogger::kIsDebuggableProperty, false)) {
+ if (os::GetSystemProperty(SnoopLogger::kRoBuildType) != "user") {
btsnoop_mode = os::GetSystemProperty(SnoopLogger::kBtSnoopDefaultLogModeProperty)
.value_or(SnoopLogger::kBtSnoopLogModeFiltered);
}
@@ -471,7 +471,7 @@ size_t get_btsnooz_packet_length_to_write(const HciPacket& packet, SnoopLogger::
// system properties
const std::string SnoopLogger::kBtSnoopMaxPacketsPerFileProperty = "persist.bluetooth.btsnoopsize";
-const std::string SnoopLogger::kIsDebuggableProperty = "ro.debuggable";
+const std::string SnoopLogger::kRoBuildType = "ro.build.type";
const std::string SnoopLogger::kBtSnoopLogModeProperty = "persist.bluetooth.btsnooplogmode";
const std::string SnoopLogger::kBtSnoopDefaultLogModeProperty =
"persist.bluetooth.btsnoopdefaultmode";
@@ -1333,7 +1333,7 @@ void SnoopLogger::Start() {
EnableFilters();
}
- if (os::GetSystemPropertyBool(kIsDebuggableProperty, false)) {
+ if (os::GetSystemProperty(kRoBuildType) != "user") {
// Cf b/375056207: The implementation must pass a security review
// in order to enable the snoop logger socket in user builds.
auto snoop_logger_socket = std::make_unique<SnoopLoggerSocket>(&syscall_if);
@@ -1404,9 +1404,9 @@ size_t SnoopLogger::GetMaxPacketsPerFile() {
size_t SnoopLogger::GetMaxPacketsPerBuffer() {
// We want to use at most 256 KB memory for btsnooz log for release builds
// and 512 KB memory for userdebug/eng builds
- auto is_debuggable = os::GetSystemPropertyBool(kIsDebuggableProperty, false);
+ auto is_debug_build = (os::GetSystemProperty(kRoBuildType) != "user");
- size_t btsnooz_max_memory_usage_bytes = (is_debuggable ? 1024 : 256) * 1024;
+ size_t btsnooz_max_memory_usage_bytes = (is_debug_build ? 1024 : 256) * 1024;
// Calculate max number of packets based on max memory usage and max packet size
return btsnooz_max_memory_usage_bytes / kDefaultBtSnoozMaxBytesPerPacket;
}
@@ -1419,8 +1419,8 @@ void SnoopLogger::RegisterSocket(SnoopLoggerSocketInterface* socket) {
}
bool SnoopLogger::IsBtSnoopLogPersisted() {
- auto is_debuggable = os::GetSystemPropertyBool(kIsDebuggableProperty, false);
- return is_debuggable && os::GetSystemPropertyBool(kBtSnoopLogPersists, false);
+ auto is_debug_build = (os::GetSystemProperty(kRoBuildType) != "user");
+ return is_debug_build && os::GetSystemPropertyBool(kBtSnoopLogPersists, false);
}
bool SnoopLogger::IsQualcommDebugLogEnabled() {
diff --git a/system/gd/hal/snoop_logger.h b/system/gd/hal/snoop_logger.h
index b0783442b3..5f45e8a0b2 100644
--- a/system/gd/hal/snoop_logger.h
+++ b/system/gd/hal/snoop_logger.h
@@ -146,7 +146,7 @@ public:
static const ModuleFactory Factory;
static const std::string kBtSnoopMaxPacketsPerFileProperty;
- static const std::string kIsDebuggableProperty;
+ static const std::string kRoBuildType;
static const std::string kBtSnoopLogModeProperty;
static const std::string kBtSnoopLogPersists;
static const std::string kBtSnoopDefaultLogModeProperty;