Allow toggle of MTP debug

Via command line in TWRP:
twrp set tw_mtp_debug 1

This will enable debugging for MTP. You will need to disable and
re-enable MTP in order to see the debug logging.

Change-Id: Ia7bb0c584e10a4322b65ecf80a67ed7ee836b38e
This commit is contained in:
Ethan Yonker
2014-09-03 14:19:43 -05:00
parent 20fd25c231
commit 6d154c4fe2
5 changed files with 23 additions and 12 deletions
+14 -9
View File
@@ -21,20 +21,20 @@
#include <stdio.h>
#define MTP_DEBUG_BUFFER_SIZE 2048
//#define MTP_DEBUG 1
static int debug_enabled = 0;
extern "C" void mtpdebug(const char *fmt, ...)
{
#ifdef MTP_DEBUG
char buf[MTP_DEBUG_BUFFER_SIZE]; // We're going to limit a single request to 512 bytes
if (debug_enabled) {
char buf[MTP_DEBUG_BUFFER_SIZE]; // We're going to limit a single request to 512 bytes
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, MTP_DEBUG_BUFFER_SIZE, fmt, ap);
va_end(ap);
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, MTP_DEBUG_BUFFER_SIZE, fmt, ap);
va_end(ap);
fputs(buf, stdout);
#endif
fputs(buf, stdout);
}
}
struct CodeEntry {
@@ -417,3 +417,8 @@ const char* MtpDebug::getDevicePropCodeName(MtpPropertyCode code) {
return "NONE";
return getCodeName(code, sDevicePropCodes);
}
void MtpDebug::enableDebug(void) {
debug_enabled = 1;
MTPD("MTP debug logging enabled\n");
}