Skip to content
This repository was archived by the owner on Aug 27, 2024. It is now read-only.

Commit 4f6ab65

Browse files
authored
Merge pull request #16 from biskhand/master
Enable logging for Android, remove redundant \n
2 parents 8543db0 + 9fe8729 commit 4f6ab65

File tree

7 files changed

+92
-33
lines changed

7 files changed

+92
-33
lines changed

common/Android.mk

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ include $(CLEAR_VARS)
2626
LOCAL_CPPFLAGS := \
2727
-DANDROID \
2828
-DANDROID_VERSION=800 \
29-
-DHDCP_LOG_TAG="\"HDCPD\"" \
29+
-DLOG_TAG=\"HDCPCOMMON\"
3030

31+
# LOG_CONSOLE will print ALOGI, ALOGE, ALOGW in Android. Enable on debug build
32+
ifeq ($(TARGET_BUILD_VARIANT),userdebug)
33+
LOCAL_CPPFLAGS += -DLOG_CONSOLE
34+
endif
35+
36+
# For ALOGV and function enter/exit log, set ENABLE_DEBUG=1 during compilation e.g. mm ENABLE_DEBUG=1 -j32
3137
ifeq ($(ENABLE_DEBUG),1)
32-
LOCAL_CPPFLAG += \
33-
-DLOG_CONSOLE \
34-
-DHDCP_USE_VERBOSE_LOGGING \
35-
-DHDCP_USE_FUNCTION_LOGGING \
36-
-DHDCP_USE_LINK_FUNCTION_LOGGING
38+
LOCAL_CPPFLAG += \
39+
-DHDCP_USE_VERBOSE_LOGGING \
40+
-DHDCP_USE_FUNCTION_LOGGING \
41+
-DHDCP_USE_LINK_FUNCTION_LOGGING
3742
endif
3843

3944
#WA

daemon/Android.mk

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ include $(CLEAR_VARS)
2626
LOCAL_CPPFLAGS := \
2727
-DANDROID \
2828
-DANDROID_VERSION=800 \
29-
-DHDCP_LOG_TAG="\"HDCPD\""
29+
-DLOG_TAG=\"HDCPD\"
3030

31+
# LOG_CONSOLE will print ALOGI, ALOGE, ALOGW in Android. Enable on debug build
32+
ifeq ($(TARGET_BUILD_VARIANT),userdebug)
33+
LOCAL_CPPFLAGS += -DLOG_CONSOLE
34+
endif
35+
36+
# For ALOGV and function enter/exit log, set ENABLE_DEBUG=1 during compilation e.g. mm ENABLE_DEBUG=1 -j32
3137
ifeq ($(ENABLE_DEBUG),1)
32-
LOCAL_CPPFLAG += \
33-
-DLOG_CONSOLE \
34-
-DHDCP_USE_VERBOSE_LOGGING \
35-
-DHDCP_USE_FUNCTION_LOGGING \
36-
-DHDCP_USE_LINK_FUNCTION_LOGGING
38+
LOCAL_CPPFLAG += \
39+
-DHDCP_USE_VERBOSE_LOGGING \
40+
-DHDCP_USE_FUNCTION_LOGGING \
41+
-DHDCP_USE_LINK_FUNCTION_LOGGING
3742
endif
3843

3944
#WA

daemon/daemon.cpp

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ void HdcpDaemon::EnumeratePorts(SocketData& data)
314314
int32_t sts = PortManagerEnumeratePorts(data.Ports, data.PortCount);
315315
if (SUCCESS != sts)
316316
{
317-
HDCP_ASSERTMESSAGE("Enumerate failed\n");
317+
HDCP_ASSERTMESSAGE("Enumerate failed");
318318
data.Status = HDCP_STATUS_ERROR_INTERNAL;
319319
return;
320320
}
321321

322-
HDCP_NORMALMESSAGE("Enumerate successfully\n");
322+
HDCP_NORMALMESSAGE("Enumerate successfully");
323323
data.Status = HDCP_STATUS_SUCCESSFUL;
324324

325325
HDCP_FUNCTION_EXIT(SUCCESS);
@@ -354,7 +354,7 @@ void HdcpDaemon::SetProtectionLevel(SocketData& data, uint32_t appId)
354354
}
355355
else
356356
{
357-
HDCP_ASSERTMESSAGE("Invalid protection level!\n");
357+
HDCP_ASSERTMESSAGE("Invalid protection level!");
358358
data.Status = HDCP_STATUS_ERROR_INVALID_PARAMETER;
359359
return;
360360
}

daemon/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool AlreadyRunning()
5555
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
5656
if (fd < 0)
5757
{
58-
HDCP_ASSERTMESSAGE("Could not open pid file : %s\n", pidFile.c_str());
58+
HDCP_ASSERTMESSAGE("Could not open pid file : %s", pidFile.c_str());
5959
return true;
6060
}
6161

@@ -67,15 +67,15 @@ bool AlreadyRunning()
6767

6868
if (fcntl(fd, F_SETLK, &fl) < 0)
6969
{
70-
HDCP_ASSERTMESSAGE("Could not lock pid file\n");
70+
HDCP_ASSERTMESSAGE("Could not lock pid file");
7171
close(fd);
7272
return true;
7373
}
7474

7575
std::string pid = std::to_string(getpid());
7676
if (write(fd, pid.c_str(), pid.length()) < 0)
7777
{
78-
HDCP_ASSERTMESSAGE("Could not write pid file\n");
78+
HDCP_ASSERTMESSAGE("Could not write pid file");
7979
close(fd);
8080
return true;
8181
}
@@ -216,7 +216,7 @@ int32_t main(void)
216216

217217
if (AlreadyRunning())
218218
{
219-
HDCP_ASSERTMESSAGE("hdcp aleady already running\n");
219+
HDCP_ASSERTMESSAGE("hdcp aleady already running");
220220
return 1;
221221
}
222222

daemon/srm.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,12 @@ VectorRevocationList::VectorRevocationList(
336336
for (int32_t i = 0; i < m_NumberOfDevices; i++)
337337
{
338338
HDCP_VERBOSEMESSAGE(
339-
"Number of devices: %d, checking number of device %d \n",
339+
"Number of devices: %d, checking number of device %d",
340340
m_NumberOfDevices,
341341
i);
342342

343343
HDCP_VERBOSEMESSAGE(
344-
"RevokeList is %x, %x, %x, %x, %x \n",
344+
"RevokeList is %x, %x, %x, %x, %x",
345345
m_KsvArray[i * KSV_SIZE + 4],
346346
m_KsvArray[i * KSV_SIZE + 3],
347347
m_KsvArray[i * KSV_SIZE + 2],
@@ -398,25 +398,25 @@ bool VectorRevocationList::ContainsKsv(const uint8_t ksv[KSV_SIZE])
398398
"ERROR: KSV_SIZE doesn't match the explicit expectation"
399399
"of 5 in the loop below!");
400400

401-
HDCP_VERBOSEMESSAGE("Start to check RevokeList with BKSV \n");
401+
HDCP_VERBOSEMESSAGE("Start to check RevokeList with BKSV");
402402

403403
for (uint32_t i = 0; i < m_NumberOfDevices; i++)
404404
{
405405
HDCP_VERBOSEMESSAGE(
406-
"Number of devices: %d, checking number of device %d \n",
406+
"Number of devices: %d, checking number of device %d",
407407
m_NumberOfDevices,
408408
i);
409409

410410
HDCP_VERBOSEMESSAGE(
411-
"RevokeList is %x, %x, %x, %x, %x \n",
411+
"RevokeList is %x, %x, %x, %x, %x",
412412
m_KsvArray[i * KSV_SIZE + 4],
413413
m_KsvArray[i * KSV_SIZE + 3],
414414
m_KsvArray[i * KSV_SIZE + 2],
415415
m_KsvArray[i * KSV_SIZE + 1],
416416
m_KsvArray[i * KSV_SIZE + 0]);
417417

418418
HDCP_VERBOSEMESSAGE(
419-
"BKSV to check is %x, %x, %x, %x, %x \n",
419+
"BKSV to check is %x, %x, %x, %x, %x",
420420
ksv[0],
421421
ksv[1],
422422
ksv[2],

sdk/Android.mk

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,23 @@
2222
LOCAL_PATH:= $(call my-dir)
2323
include $(CLEAR_VARS)
2424

25+
# For ALOGV and enter/exit log, set ENABLE_DEBUG=1 during compilation e.g. mm ENABLE_DEBUG=1 -j32
2526
LOCAL_CPPFLAGS += \
26-
-DANDROID \
27-
-DANDROID_VERSION=800 \
28-
-DHDCP_LOG_TAG="\"HDCP_SDK\"" \
27+
-DANDROID \
28+
-DANDROID_VERSION=800 \
29+
-DLOG_TAG=\"HDCPSDK\"
2930

31+
# LOG_CONSOLE will print ALOGI, ALOGE, ALOGW in Android. Enable on debug build
32+
ifeq ($(TARGET_BUILD_VARIANT),userdebug)
33+
LOCAL_CPPFLAGS += -DLOG_CONSOLE
34+
endif
35+
36+
# For ALOGV and function enter/exit log, set ENABLE_DEBUG=1 during compilation e.g. mm ENABLE_DEBUG=1 -j32
3037
ifeq ($(ENABLE_DEBUG),1)
31-
LOCAL_CPPFLAG += \
32-
-DLOG_CONSOLE \
33-
-DHDCP_USE_VERBOSE_LOGGING \
34-
-DHDCP_USE_FUNCTION_LOGGING \
35-
-DHDCP_USE_LINK_FUNCTION_LOGGING
38+
LOCAL_CPPFLAGS += \
39+
-DHDCP_USE_VERBOSE_LOGGING \
40+
-DHDCP_USE_FUNCTION_LOGGING \
41+
-DHDCP_USE_LINK_FUNCTION_LOGGING
3642
endif
3743

3844
#WA

sdk/hdcpdef.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include <cerrno>
3333
#include <time.h>
3434

35+
#ifdef ANDROID
36+
#include <log/log.h>
37+
#endif
38+
3539
#define SRM_MIN_LENGTH 8
3640

3741
#ifdef SUCCESS
@@ -112,6 +116,7 @@ extern FILE* dmLog;
112116
///////////////////////////////////////////////////////////////////////////////
113117
#if defined(LOG_CONSOLE)
114118

119+
#ifndef ANDROID
115120
#define DAEMON_LOG(fmt, args...) \
116121
printf("%s:%d: " fmt "\n", __FUNCTION__, __LINE__, ##args)
117122

@@ -149,6 +154,44 @@ extern FILE* dmLog;
149154
#define HDCP_LINK_FUNCTION_EXIT(_r)
150155
#endif
151156

157+
#else // =========== ANDROID ===========
158+
159+
#define HDCP_ASSERTMESSAGE(_message, ...) \
160+
ALOGE("%s:%d:ERROR: " _message, __FUNCTION__, __LINE__, ##__VA_ARGS__);
161+
#define HDCP_WARNMESSAGE(_message, ...) \
162+
ALOGW("%s:%d:WARN: " _message, __FUNCTION__, __LINE__, ##__VA_ARGS__);
163+
#define HDCP_NORMALMESSAGE(_message, ...) \
164+
ALOGI("%s:%d:INFO: " _message, __FUNCTION__, __LINE__, ##__VA_ARGS__);
165+
166+
#ifdef HDCP_USE_VERBOSE_LOGGING
167+
// This is selectively enabled for debugging gmbus/dpaux failures which spit
168+
// out tons of generally useless information
169+
#define HDCP_VERBOSEMESSAGE(_message, ...) \
170+
ALOGV("%s:%d:VERBOSE: " _message, __FUNCTION__, __LINE__, ##__VA_ARGS__);
171+
#else
172+
#define HDCP_VERBOSEMESSAGE(_message, ...)
173+
#endif
174+
175+
#ifdef HDCP_USE_FUNCTION_LOGGING
176+
#define HDCP_FUNCTION_ENTER \
177+
ALOGV("ENTER - %s", __FUNCTION__);
178+
#define HDCP_FUNCTION_EXIT(_r) \
179+
ALOGV("EXIT - %s: ret = 0x%x", __FUNCTION__, _r);
180+
#else
181+
#define HDCP_FUNCTION_ENTER
182+
#define HDCP_FUNCTION_EXIT(_r)
183+
#endif
184+
185+
#ifdef HDCP_USE_LINK_FUNCTION_LOGGING
186+
#define HDCP_LINK_FUNCTION_ENTER HDCP_FUNCTION_ENTER
187+
#define HDCP_LINK_FUNCTION_EXIT(_r) HDCP_FUNCTION_EXIT(_r)
188+
#else
189+
#define HDCP_LINK_FUNCTION_ENTER
190+
#define HDCP_LINK_FUNCTION_EXIT(_r)
191+
#endif
192+
193+
#endif // =========== ANDROID ==========
194+
152195
///////////////////////////////////////////////////////////////////////////////
153196
/// \brief Empty macro definitions for release and non-logging builds
154197
///

0 commit comments

Comments
 (0)