summaryrefslogtreecommitdiffstats
path: root/media/mtp/MtpPacket.cpp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-06-29 18:11:52 -0400
committerMike Lockwood <lockwood@android.com>2010-06-30 13:59:32 -0400
commitb14e588bec4d5e39e61b020b5b575f2ce555d316 (patch)
treef4d08eaa3bd5832b3bfebbdb9d19c8fcde45b54e /media/mtp/MtpPacket.cpp
parent703f87c890591e3a20ba0da237233c36a7c47bc7 (diff)
downloadframeworks_av-b14e588bec4d5e39e61b020b5b575f2ce555d316.zip
frameworks_av-b14e588bec4d5e39e61b020b5b575f2ce555d316.tar.gz
frameworks_av-b14e588bec4d5e39e61b020b5b575f2ce555d316.tar.bz2
MTP: replace printfs with logcat
Change-Id: I2c30921098e2dc049dc5fc1e0a548ead33c363e0 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp/MtpPacket.cpp')
-rw-r--r--media/mtp/MtpPacket.cpp38
1 files changed, 26 insertions, 12 deletions
diff --git a/media/mtp/MtpPacket.cpp b/media/mtp/MtpPacket.cpp
index 3db6abb..42bf8ba 100644
--- a/media/mtp/MtpPacket.cpp
+++ b/media/mtp/MtpPacket.cpp
@@ -14,15 +14,18 @@
* limitations under the License.
*/
+#define LOG_TAG "MtpPacket"
+
+#include "MtpDebug.h"
+#include "MtpPacket.h"
+#include "mtp.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <usbhost/usbhost.h>
-#include "MtpPacket.h"
-#include "mtp.h"
-
namespace android {
MtpPacket::MtpPacket(int bufferSize)
@@ -33,7 +36,7 @@ MtpPacket::MtpPacket(int bufferSize)
{
mBuffer = (uint8_t *)malloc(bufferSize);
if (!mBuffer) {
- fprintf(stderr, "out of memory!\n");
+ LOGE("out of memory!");
abort();
}
}
@@ -54,7 +57,7 @@ void MtpPacket::allocate(int length) {
int newLength = length + mAllocationIncrement;
mBuffer = (uint8_t *)realloc(mBuffer, newLength);
if (!mBuffer) {
- fprintf(stderr, "out of memory!\n");
+ LOGE("out of memory!");
abort();
}
mBufferSize = newLength;
@@ -62,12 +65,23 @@ void MtpPacket::allocate(int length) {
}
void MtpPacket::dump() {
+#define DUMP_BYTES_PER_ROW 16
+ char buffer[500];
+ char* bufptr = buffer;
+
for (int i = 0; i < mPacketSize; i++) {
- printf("%02X ", mBuffer[i]);
- if (i % 16 == 15)
- printf("\n");
+ sprintf(bufptr, "%02X ", mBuffer[i]);
+ bufptr += strlen(bufptr);
+ if (i % DUMP_BYTES_PER_ROW == (DUMP_BYTES_PER_ROW - 1)) {
+ LOGV("%s", buffer);
+ bufptr = buffer;
+ }
+ }
+ if (bufptr != buffer) {
+ // print last line
+ LOGV("%s", buffer);
}
- printf("\n\n");
+ LOGV("\n");
}
uint16_t MtpPacket::getUInt16(int offset) const {
@@ -109,7 +123,7 @@ void MtpPacket::setTransactionID(MtpTransactionID id) {
uint32_t MtpPacket::getParameter(int index) const {
if (index < 1 || index > 5) {
- fprintf(stderr, "index %d out of range in MtpRequestPacket::getParameter\n", index);
+ LOGE("index %d out of range in MtpRequestPacket::getParameter", index);
return 0;
}
return getUInt32(MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t));
@@ -117,7 +131,7 @@ uint32_t MtpPacket::getParameter(int index) const {
void MtpPacket::setParameter(int index, uint32_t value) {
if (index < 1 || index > 5) {
- fprintf(stderr, "index %d out of range in MtpResponsePacket::setParameter\n", index);
+ LOGE("index %d out of range in MtpResponsePacket::setParameter", index);
return;
}
int offset = MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t);
@@ -129,7 +143,7 @@ void MtpPacket::setParameter(int index, uint32_t value) {
#ifdef MTP_HOST
int MtpPacket::transfer(struct usb_endpoint *ep, void* buffer, int length) {
if (usb_endpoint_queue(ep, buffer, length)) {
- printf("usb_endpoint_queue failed, errno: %d\n", errno);
+ LOGE("usb_endpoint_queue failed, errno: %d", errno);
return -1;
}
int ep_num;