• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define LOG_TAG "NfcNciHal"
20 
21 /******************************************************************************
22  *
23  *  Override the ALOGD(), ALOGE(), and other logging macros from
24  *  /system/core/include/cutils/log.h
25  *
26  ******************************************************************************/
27 #include "_OverrideLog.h"
28 #include <cutils/properties.h>
29 #include <string.h>
30 #include "android_logmsg.h"
31 #include "config.h"
32 
33 unsigned char appl_trace_level = BT_TRACE_LEVEL_DEBUG;
34 
35 /*******************************************************************************
36 **
37 ** Function:        InitializeGlobalAppLogLevel
38 **
39 ** Description:     Initialize and get global logging level from
40 **                  Android property nfc.app_log_level.
41 **
42 ** Returns:         Global log level:
43 **                  BT_TRACE_LEVEL_NONE    0        * No trace messages to be
44 *generated
45 **                  BT_TRACE_LEVEL_ERROR   1        * Error condition trace
46 *messages
47 **                  BT_TRACE_LEVEL_WARNING 2        * Warning condition trace
48 *messages
49 **                  BT_TRACE_LEVEL_API     3        * API traces
50 **                  BT_TRACE_LEVEL_EVENT   4        * Debug messages for events
51 **                  BT_TRACE_LEVEL_DEBUG   5        * Debug messages (general)
52 **
53 *******************************************************************************/
InitializeGlobalAppLogLevel()54 unsigned char InitializeGlobalAppLogLevel() {
55   unsigned long num = 0;
56   char valueStr[PROPERTY_VALUE_MAX] = {0};
57 
58   num = 1;
59   if (GetNumValue(NAME_APPL_TRACE_LEVEL, &num, sizeof(num)))
60     appl_trace_level = (unsigned char)num;
61 
62   int len = property_get("nfc.app_log_level", valueStr, "");
63   if (len > 0) {
64     // let Android property override default value
65     sscanf(valueStr, "%lu", &num);
66     appl_trace_level = (unsigned char)num;
67   }
68 
69   // 0xFF is a special value used by the stack to query the current
70   // trace level; it does not change any trace level
71   if (appl_trace_level == 0xFF) appl_trace_level = BT_TRACE_LEVEL_DEBUG;
72   ALOGD("%s: level=%u", __func__, appl_trace_level);
73 
74   if (appl_trace_level < BT_TRACE_LEVEL_DEBUG) {
75     // display protocol traces in raw format
76     ProtoDispAdapterUseRawOutput(TRUE);
77   }
78   return appl_trace_level;
79 }
80 
InitializeProtocolLogLevel()81 uint32_t InitializeProtocolLogLevel() {
82   uint32_t num = 0;
83   char valueStr[PROPERTY_VALUE_MAX] = {0};
84 
85   if (GetNumValue(NAME_PROTOCOL_TRACE_LEVEL, &num, sizeof(num)))
86     ScrProtocolTraceFlag = num;
87 
88   int len = property_get("nfc.enable_protocol_log", valueStr, "");
89   if (len > 0) {
90     if (strncmp("0", valueStr, 1) == 0) {
91       ScrProtocolTraceFlag = 0;
92     } else {
93       ScrProtocolTraceFlag = ~0;
94     }
95   }
96 
97   return ScrProtocolTraceFlag;
98 }
99