summaryrefslogtreecommitdiffstats
path: root/mtp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2014-09-03 21:19:43 +0200
committerEthan Yonker <dees_troy@teamw.in>2014-09-03 21:22:50 +0200
commit6d154c4fe25d1ae0b5dafaae5eff7c0102f3362e (patch)
tree0e655bbdc41f5f10474ddc9ebe4a77b8ea35c550 /mtp
parentImprove error handling during MTP startup (diff)
downloadandroid_bootable_recovery-6d154c4fe25d1ae0b5dafaae5eff7c0102f3362e.tar
android_bootable_recovery-6d154c4fe25d1ae0b5dafaae5eff7c0102f3362e.tar.gz
android_bootable_recovery-6d154c4fe25d1ae0b5dafaae5eff7c0102f3362e.tar.bz2
android_bootable_recovery-6d154c4fe25d1ae0b5dafaae5eff7c0102f3362e.tar.lz
android_bootable_recovery-6d154c4fe25d1ae0b5dafaae5eff7c0102f3362e.tar.xz
android_bootable_recovery-6d154c4fe25d1ae0b5dafaae5eff7c0102f3362e.tar.zst
android_bootable_recovery-6d154c4fe25d1ae0b5dafaae5eff7c0102f3362e.zip
Diffstat (limited to 'mtp')
-rwxr-xr-xmtp/MtpDebug.cpp23
-rwxr-xr-xmtp/MtpDebug.h1
-rwxr-xr-xmtp/twrpMtp.cpp4
-rwxr-xr-xmtp/twrpMtp.hpp2
4 files changed, 19 insertions, 11 deletions
diff --git a/mtp/MtpDebug.cpp b/mtp/MtpDebug.cpp
index c3a3d8a5a..47834ab26 100755
--- a/mtp/MtpDebug.cpp
+++ b/mtp/MtpDebug.cpp
@@ -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");
+}
diff --git a/mtp/MtpDebug.h b/mtp/MtpDebug.h
index 12a23ccc8..b572b3b96 100755
--- a/mtp/MtpDebug.h
+++ b/mtp/MtpDebug.h
@@ -43,6 +43,7 @@ public:
static const char* getFormatCodeName(MtpObjectFormat code);
static const char* getObjectPropCodeName(MtpPropertyCode code);
static const char* getDevicePropCodeName(MtpPropertyCode code);
+ static void enableDebug();
};
diff --git a/mtp/twrpMtp.cpp b/mtp/twrpMtp.cpp
index ff58f79a7..6fe0ee3e8 100755
--- a/mtp/twrpMtp.cpp
+++ b/mtp/twrpMtp.cpp
@@ -68,7 +68,9 @@ int main(int argc, char* argv[]) {
}
#endif //def TWRPMTP
-twrpMtp::twrpMtp() {
+twrpMtp::twrpMtp(int debug_enabled = 0) {
+ if (debug_enabled)
+ MtpDebug::enableDebug();
mtpstorages = new storages;
}
diff --git a/mtp/twrpMtp.hpp b/mtp/twrpMtp.hpp
index 2dd56a226..bed81c0e9 100755
--- a/mtp/twrpMtp.hpp
+++ b/mtp/twrpMtp.hpp
@@ -33,7 +33,7 @@
class twrpMtp {
public:
- twrpMtp();
+ twrpMtp(int debug_enabled /* = 0 */);
pthread_t runserver(void);
void addStorage(std::string display, std::string path, int mtpid);
private: