|
28 | 28 | #include <lib/support/CodeUtils.h>
|
29 | 29 | #include <lib/support/JniReferences.h>
|
30 | 30 | #include <lib/support/JniTypeWrappers.h>
|
| 31 | +#include <lib/support/logging/CHIPLogging.h> |
31 | 32 | #include <platform/CHIPDeviceConfig.h>
|
32 | 33 | #include <platform/ConfigurationManager.h>
|
33 | 34 | #include <platform/ConnectivityManager.h>
|
34 | 35 | #include <platform/KeyValueStoreManager.h>
|
35 | 36 | #include <platform/internal/BLEManager.h>
|
36 | 37 |
|
| 38 | +#include <android/log.h> |
| 39 | + |
37 | 40 | #include "AndroidChipPlatform-JNI.h"
|
38 | 41 | #include "BLEManagerImpl.h"
|
39 | 42 | #include "BleConnectCallback-JNI.h"
|
|
45 | 48 | using namespace chip;
|
46 | 49 |
|
47 | 50 | #define JNI_METHOD(RETURN, METHOD_NAME) extern "C" JNIEXPORT RETURN JNICALL Java_chip_platform_AndroidChipPlatform_##METHOD_NAME
|
| 51 | +#define JNI_LOGGING_METHOD(RETURN, METHOD_NAME) \ |
| 52 | + extern "C" JNIEXPORT RETURN JNICALL Java_chip_platform_AndroidChipLogging_##METHOD_NAME |
48 | 53 | #define JNI_MDNSCALLBACK_METHOD(RETURN, METHOD_NAME) \
|
49 | 54 | extern "C" JNIEXPORT RETURN JNICALL Java_chip_platform_ChipMdnsCallbackImpl_##METHOD_NAME
|
50 | 55 |
|
@@ -245,6 +250,30 @@ JNI_METHOD(void, nativeSetDnssdDelegates)(JNIEnv * env, jclass self, jobject res
|
245 | 250 | chip::Dnssd::InitializeWithObjects(resolver, browser, chipMdnsCallback);
|
246 | 251 | }
|
247 | 252 |
|
| 253 | +JNI_LOGGING_METHOD(void, setLogFilter)(JNIEnv * env, jclass clazz, jint level) |
| 254 | +{ |
| 255 | + using namespace chip::Logging; |
| 256 | + |
| 257 | + uint8_t category = kLogCategory_Detail; |
| 258 | + switch (level) |
| 259 | + { |
| 260 | + case ANDROID_LOG_VERBOSE: |
| 261 | + case ANDROID_LOG_DEBUG: |
| 262 | + category = kLogCategory_Detail; |
| 263 | + break; |
| 264 | + case ANDROID_LOG_INFO: |
| 265 | + category = kLogCategory_Progress; |
| 266 | + break; |
| 267 | + case ANDROID_LOG_WARN: |
| 268 | + case ANDROID_LOG_ERROR: |
| 269 | + category = kLogCategory_Error; |
| 270 | + break; |
| 271 | + default: |
| 272 | + break; |
| 273 | + } |
| 274 | + SetLogFilter(category); |
| 275 | +} |
| 276 | + |
248 | 277 | JNI_MDNSCALLBACK_METHOD(void, handleServiceResolve)
|
249 | 278 | (JNIEnv * env, jclass self, jstring instanceName, jstring serviceType, jstring hostName, jstring address, jint port,
|
250 | 279 | jobject attributes, jlong callbackHandle, jlong contextHandle)
|
|
0 commit comments