Skip to content

Commit d84ae7e

Browse files
committed
fix: android: do not initialize tracing if it is disabled
1 parent d6b2cee commit d84ae7e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/platform/android/AndroidChipPlatform-JNI.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@
3737

3838
#include <android/log.h>
3939

40+
#include <matter/tracing/build_config.h>
41+
4042
#include "AndroidChipPlatform-JNI.h"
4143
#include "BLEManagerImpl.h"
4244
#include "BleConnectCallback-JNI.h"
4345
#include "CommissionableDataProviderImpl.h"
4446
#include "DiagnosticDataProviderImpl.h"
4547
#include "DnssdImpl.h"
48+
49+
#if MATTER_TRACING_ENABLED
4650
#include "tracing.h"
51+
#endif // MATTER_TRACING_ENABLED
4752

4853
using namespace chip;
4954

@@ -97,7 +102,9 @@ CHIP_ERROR AndroidChipPlatformJNI_OnLoad(JavaVM * jvm, void * reserved)
97102
err = BleConnectCallbackJNI_OnLoad(jvm, reserved);
98103
SuccessOrExit(err);
99104

105+
#if MATTER_TRACING_ENABLED
100106
chip::Android::InitializeTracing();
107+
#endif // MATTER_TRACING_ENABLED
101108
exit:
102109
if (err != CHIP_NO_ERROR)
103110
{
@@ -110,7 +117,9 @@ CHIP_ERROR AndroidChipPlatformJNI_OnLoad(JavaVM * jvm, void * reserved)
110117

111118
void AndroidChipPlatformJNI_OnUnload(JavaVM * jvm, void * reserved)
112119
{
120+
#if MATTER_TRACING_ENABLED
113121
chip::Android::ShutdownTracing();
122+
#endif // MATTER_TRACING_ENABLED
114123

115124
ChipLogProgress(DeviceLayer, "AndroidChipPlatform JNI_OnUnload() called");
116125
BleConnectCallbackJNI_OnUnload(jvm, reserved);

src/platform/android/BUILD.gn

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import("${chip_root}/src/platform/device.gni")
1919

2020
import("${build_root}/config/android_abi.gni")
2121
import("${chip_root}/build/chip/java/rules.gni")
22+
import("${chip_root}/src/tracing/tracing_args.gni")
2223

2324
assert(chip_device_platform == "android")
2425

@@ -83,14 +84,20 @@ static_library("android") {
8384
]
8485

8586
deps = [
86-
":tracing",
8787
"${chip_root}/src/app:app_config",
8888
"${chip_root}/src/app/common:ids",
8989
"${chip_root}/src/lib/dnssd:platform_header",
9090
"${chip_root}/src/setup_payload",
9191
]
9292

93-
public_deps = [ "${chip_root}/src/platform:platform_base" ]
93+
if (matter_enable_tracing_support) {
94+
deps += [ ":tracing" ]
95+
}
96+
97+
public_deps = [
98+
"${chip_root}/src/platform:platform_base",
99+
"${chip_root}/src/tracing:tracing_buildconfig",
100+
]
94101

95102
public_configs = []
96103
}

0 commit comments

Comments
 (0)