The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2012 Broadcom Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
| 19 | /****************************************************************************** |
| 20 | * |
| 21 | * Override the ALOGD(), ALOGE(), and other logging macros from |
| 22 | * /system/core/include/cutils/log.h |
| 23 | * |
| 24 | ******************************************************************************/ |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 25 | #include <cutils/properties.h> |
Martijn Coenen | 8e290d3 | 2015-04-16 10:08:46 +0200 | [diff] [blame] | 26 | #include <string.h> |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 27 | #include "_OverrideLog.h" |
Evan Chu | a24be4f | 2013-11-13 15:30:16 -0500 | [diff] [blame] | 28 | #include "android_logmsg.h" |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 29 | #include "config.h" |
Jizhou Liao | 65ebec5 | 2016-04-05 17:09:24 -0700 | [diff] [blame] | 30 | |
| 31 | #undef LOG_TAG |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 32 | #define LOG_TAG "BrcmNfcJni" |
| 33 | |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 34 | /******************************************************************************* |
| 35 | ** |
| 36 | ** Function: initializeGlobalAppLogLevel |
| 37 | ** |
| 38 | ** Description: Initialize and get global logging level from .conf or |
| 39 | ** Android property nfc.app_log_level. The Android property |
| 40 | ** overrides .conf variable. |
| 41 | ** |
| 42 | ** Returns: Global log level: |
Ruchi Kandoi | 552f2b7 | 2017-01-28 16:22:55 -0800 | [diff] [blame] | 43 | ** BT_TRACE_LEVEL_NONE 0 * No trace messages to be generated |
| 44 | ** BT_TRACE_LEVEL_ERROR 1 * Error condition trace messages |
| 45 | ** BT_TRACE_LEVEL_WARNING 2 * Warning condition trace messages |
| 46 | ** BT_TRACE_LEVEL_API 3 * API traces |
| 47 | ** BT_TRACE_LEVEL_EVENT 4 * Debug messages for events |
| 48 | ** BT_TRACE_LEVEL_DEBUG 5 * Debug messages (general) |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 49 | ** |
| 50 | *******************************************************************************/ |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 51 | unsigned char initializeGlobalAppLogLevel() { |
| 52 | unsigned long num = 0; |
| 53 | char valueStr[PROPERTY_VALUE_MAX] = {0}; |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 54 | |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 55 | num = 1; |
| 56 | if (GetNumValue(NAME_APPL_TRACE_LEVEL, &num, sizeof(num))) |
| 57 | appl_trace_level = (unsigned char)num; |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 58 | |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 59 | int len = property_get("nfc.app_log_level", valueStr, ""); |
| 60 | if (len > 0) { |
| 61 | // let Android property override .conf variable |
| 62 | sscanf(valueStr, "%lu", &num); |
| 63 | appl_trace_level = (unsigned char)num; |
| 64 | } |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 65 | |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 66 | // 0xFF is a special value used by the stack to query the current |
| 67 | // trace level; it does not change any trace level |
| 68 | if (appl_trace_level == 0xFF) appl_trace_level = BT_TRACE_LEVEL_DEBUG; |
| 69 | ALOGD("%s: level=%u", __func__, appl_trace_level); |
Evan Chu | a24be4f | 2013-11-13 15:30:16 -0500 | [diff] [blame] | 70 | |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 71 | if (appl_trace_level < BT_TRACE_LEVEL_DEBUG) { |
| 72 | // display protocol traces in raw format |
| 73 | ProtoDispAdapterUseRawOutput(TRUE); |
| 74 | } |
| 75 | return appl_trace_level; |
The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame] | 76 | } |
Andres Morales | e4ecc7d | 2014-10-01 17:46:04 -0700 | [diff] [blame] | 77 | |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 78 | uint32_t initializeProtocolLogLevel() { |
| 79 | uint32_t num = 0; |
| 80 | char valueStr[PROPERTY_VALUE_MAX] = {0}; |
Andres Morales | e4ecc7d | 2014-10-01 17:46:04 -0700 | [diff] [blame] | 81 | |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 82 | if (GetNumValue(NAME_PROTOCOL_TRACE_LEVEL, &num, sizeof(num))) |
| 83 | ScrProtocolTraceFlag = num; |
Andres Morales | e4ecc7d | 2014-10-01 17:46:04 -0700 | [diff] [blame] | 84 | |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 85 | int len = property_get("nfc.enable_protocol_log", valueStr, ""); |
| 86 | if (len > 0) { |
| 87 | if (strncmp("0", valueStr, 1) == 0) { |
| 88 | ScrProtocolTraceFlag = 0; |
| 89 | } else { |
| 90 | ScrProtocolTraceFlag = ~0; |
Andres Morales | e4ecc7d | 2014-10-01 17:46:04 -0700 | [diff] [blame] | 91 | } |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 92 | } |
Andres Morales | e4ecc7d | 2014-10-01 17:46:04 -0700 | [diff] [blame] | 93 | |
Ruchi Kandoi | 6fca02d | 2017-01-30 14:28:16 -0800 | [diff] [blame] | 94 | return ScrProtocolTraceFlag; |
Andres Morales | e4ecc7d | 2014-10-01 17:46:04 -0700 | [diff] [blame] | 95 | } |
Love Khanna | a5eb6e8 | 2017-06-02 19:55:05 +0530 | [diff] [blame] | 96 | |
| 97 | void initializeGlobalAppDtaMode() { |
| 98 | appl_dta_mode_flag = 0x01; |
| 99 | ALOGD("%s: DTA Enabled", __func__); |
| 100 | } |