diff options
author | Ashwini Munigala <AshwiniM@codeaurora.org> | 2015-08-14 17:05:27 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:27:43 -0600 |
commit | 76f9fb7a231da44b65e7448e70b200b456910f91 (patch) | |
tree | 1e43714b72f0b2d2e611a24679fdda13a257ed3c /obex | |
parent | a6942694bfe2a4291777e33efad0255f98e9b869 (diff) | |
download | frameworks_base-76f9fb7a231da44b65e7448e70b200b456910f91.zip frameworks_base-76f9fb7a231da44b65e7448e70b200b456910f91.tar.gz frameworks_base-76f9fb7a231da44b65e7448e70b200b456910f91.tar.bz2 |
OBEX: Dynamic VERBOSE level logging for OBEX.
- Support runtime VERBOSE level logging control
for OBEX lib.
- Added extra informative logs useful to
debug issues from obex layer.
Change-Id: If94c88b438b3c283aca0ba4cc46f42bb1d8c37eb
Diffstat (limited to 'obex')
-rw-r--r-- | obex/javax/obex/ClientOperation.java | 2 | ||||
-rw-r--r-- | obex/javax/obex/ClientSession.java | 3 | ||||
-rw-r--r-- | obex/javax/obex/ObexHelper.java | 28 | ||||
-rw-r--r-- | obex/javax/obex/ObexSession.java | 2 | ||||
-rw-r--r-- | obex/javax/obex/ServerOperation.java | 9 | ||||
-rw-r--r-- | obex/javax/obex/ServerSession.java | 12 |
6 files changed, 45 insertions, 11 deletions
diff --git a/obex/javax/obex/ClientOperation.java b/obex/javax/obex/ClientOperation.java index eb7e280..afa9dab 100644 --- a/obex/javax/obex/ClientOperation.java +++ b/obex/javax/obex/ClientOperation.java @@ -52,7 +52,7 @@ public final class ClientOperation implements Operation, BaseStream { private static final String TAG = "ClientOperation"; - private static final boolean V = ObexHelper.VDBG; + private static final boolean V = Log.isLoggable(ObexHelper.LOG_TAG, Log.VERBOSE); private ClientSession mParent; diff --git a/obex/javax/obex/ClientSession.java b/obex/javax/obex/ClientSession.java index 8f7a680..f360944 100644 --- a/obex/javax/obex/ClientSession.java +++ b/obex/javax/obex/ClientSession.java @@ -48,6 +48,7 @@ import android.util.Log; public final class ClientSession extends ObexSession { private static final String TAG = "ClientSession"; + private static final boolean V = Log.isLoggable(ObexHelper.LOG_TAG, Log.VERBOSE); private boolean mOpen; @@ -616,6 +617,6 @@ public final class ClientSession extends ObexSession { public void setLocalSrmStatus(boolean SrmEnabled) { mLocalSrmSupported = SrmEnabled; - Log.v(TAG, "setLocalSrmStatus: " + mLocalSrmSupported); + if (V) Log.v(TAG, "setLocalSrmStatus: " + mLocalSrmSupported); } } diff --git a/obex/javax/obex/ObexHelper.java b/obex/javax/obex/ObexHelper.java index fa50943..431525e 100644 --- a/obex/javax/obex/ObexHelper.java +++ b/obex/javax/obex/ObexHelper.java @@ -52,7 +52,8 @@ import android.util.Log; public final class ObexHelper { private static final String TAG = "ObexHelper"; - public static final boolean VDBG = false; + public static final String LOG_TAG = "BluetoothObex"; + public static final boolean VDBG = Log.isLoggable(LOG_TAG, Log.VERBOSE); /** * Defines the basic packet length used by OBEX. Every OBEX packet has the * same basic format:<BR> @@ -190,6 +191,7 @@ public final class ObexHelper { try { while (index < headerArray.length) { headerID = 0xFF & headerArray[index]; + if (VDBG) Log.v(TAG,"updateHeaderSet headerID = " + headerID); switch (headerID & (0xC0)) { /* @@ -375,8 +377,9 @@ public final class ObexHelper { * Determine if there is a connection ID to send. If there is, * then it should be the first header in the packet. */ + if (VDBG) Log.v(TAG,"createHeader = " + head); if ((headImpl.mConnectionID != null) && (headImpl.getHeader(HeaderSet.TARGET) == null)) { - + if (VDBG) Log.v(TAG," Add Header = " + HeaderSet.CONNECTION_ID); out.write((byte)HeaderSet.CONNECTION_ID); out.write(headImpl.mConnectionID); } @@ -384,6 +387,7 @@ public final class ObexHelper { // Count Header intHeader = (Long)headImpl.getHeader(HeaderSet.COUNT); if (intHeader != null) { + if (VDBG) Log.v(TAG," Add Header = " + HeaderSet.COUNT); out.write((byte)HeaderSet.COUNT); value = ObexHelper.convertToByteArray(intHeader.longValue()); out.write(value); @@ -395,6 +399,7 @@ public final class ObexHelper { // Name Header stringHeader = (String)headImpl.getHeader(HeaderSet.NAME); if (stringHeader != null) { + if (VDBG) Log.v(TAG," Add Header = " + HeaderSet.NAME); out.write((byte)HeaderSet.NAME); value = ObexHelper.convertToUnicodeByteArray(stringHeader); length = value.length + 3; @@ -415,6 +420,7 @@ public final class ObexHelper { // Type Header stringHeader = (String)headImpl.getHeader(HeaderSet.TYPE); if (stringHeader != null) { + if (VDBG) Log.v(TAG," Add Header = " + HeaderSet.TYPE); out.write((byte)HeaderSet.TYPE); try { value = stringHeader.getBytes("ISO8859_1"); @@ -436,6 +442,7 @@ public final class ObexHelper { // Length Header intHeader = (Long)headImpl.getHeader(HeaderSet.LENGTH); if (intHeader != null) { + if (VDBG) Log.v(TAG," Add Header = " + HeaderSet.LENGTH); out.write((byte)HeaderSet.LENGTH); value = ObexHelper.convertToByteArray(intHeader.longValue()); out.write(value); @@ -447,7 +454,7 @@ public final class ObexHelper { // Time ISO Header dateHeader = (Calendar)headImpl.getHeader(HeaderSet.TIME_ISO_8601); if (dateHeader != null) { - + if (VDBG) Log.v(TAG," Add dateHeader = " + HeaderSet.TIME_ISO_8601); /* * The ISO Header should take the form YYYYMMDDTHHMMSSZ. The * 'Z' will only be included if it is a UTC time. @@ -509,6 +516,7 @@ public final class ObexHelper { // Time 4 Byte Header dateHeader = (Calendar)headImpl.getHeader(HeaderSet.TIME_4_BYTE); if (dateHeader != null) { + if (VDBG) Log.v(TAG," Add dateHeader = " + HeaderSet.TIME_4_BYTE); out.write(HeaderSet.TIME_4_BYTE); /* @@ -543,6 +551,7 @@ public final class ObexHelper { // Target Header value = (byte[])headImpl.getHeader(HeaderSet.TARGET); if (value != null) { + if (VDBG) Log.v(TAG," Add Header = " + HeaderSet.TARGET); out.write((byte)HeaderSet.TARGET); length = value.length + 3; lengthArray[0] = (byte)(255 & (length >> 8)); @@ -571,6 +580,7 @@ public final class ObexHelper { // Who Header value = (byte[])headImpl.getHeader(HeaderSet.WHO); if (value != null) { + if (VDBG) Log.v(TAG," Add Header = " + HeaderSet.WHO); out.write((byte)HeaderSet.WHO); length = value.length + 3; lengthArray[0] = (byte)(255 & (length >> 8)); @@ -582,9 +592,10 @@ public final class ObexHelper { } } - // Connection ID Header + // Application Parameter Header value = (byte[])headImpl.getHeader(HeaderSet.APPLICATION_PARAMETER); if (value != null) { + if (VDBG) Log.v(TAG," Add APP PARAM Header = " + HeaderSet.APPLICATION_PARAMETER); out.write((byte)HeaderSet.APPLICATION_PARAMETER); length = value.length + 3; lengthArray[0] = (byte)(255 & (length >> 8)); @@ -623,6 +634,7 @@ public final class ObexHelper { lengthArray[1] = (byte)(255 & length); out.write(lengthArray); out.write(value); + if (VDBG) Log.v(TAG," Add Unicode String value = " + value); if (nullOut) { headImpl.setHeader(i + 0x30, null); } @@ -637,6 +649,7 @@ public final class ObexHelper { lengthArray[1] = (byte)(255 & length); out.write(lengthArray); out.write(value); + if (VDBG) Log.v(TAG," Add ByteSeq value = " + value); if (nullOut) { headImpl.setHeader(i + 0x70, null); } @@ -647,6 +660,7 @@ public final class ObexHelper { if (byteHeader != null) { out.write((byte)i + 0xB0); out.write(byteHeader.byteValue()); + if (VDBG) Log.v(TAG," Add ByteHeader value = " + byteHeader.byteValue()); if (nullOut) { headImpl.setHeader(i + 0xB0, null); } @@ -657,6 +671,7 @@ public final class ObexHelper { if (intHeader != null) { out.write((byte)i + 0xF0); out.write(ObexHelper.convertToByteArray(intHeader.longValue())); + if (VDBG) Log.v(TAG," Add Int value = " + intHeader.longValue()); if (nullOut) { headImpl.setHeader(i + 0xF0, null); } @@ -671,6 +686,7 @@ public final class ObexHelper { lengthArray[1] = (byte)(255 & length); out.write(lengthArray); out.write(headImpl.mAuthChall); + if (VDBG) Log.v(TAG," Add mAuthChall value = " + headImpl.mAuthChall); if (nullOut) { headImpl.mAuthChall = null; } @@ -684,6 +700,7 @@ public final class ObexHelper { lengthArray[1] = (byte)(255 & length); out.write(lengthArray); out.write(headImpl.mAuthResp); + if (VDBG) Log.v(TAG," Add mAuthChall value = " + headImpl.mAuthResp); if (nullOut) { headImpl.mAuthResp = null; } @@ -699,8 +716,10 @@ public final class ObexHelper { // Add the SRM header byteHeader = (Byte)headImpl.getHeader(HeaderSet.SINGLE_RESPONSE_MODE); if (byteHeader != null) { + if (VDBG) Log.v(TAG," Add SRM Header = " + HeaderSet.SINGLE_RESPONSE_MODE); out.write((byte)HeaderSet.SINGLE_RESPONSE_MODE); out.write(byteHeader.byteValue()); + if (VDBG) Log.v(TAG," Add SRM value = " + byteHeader.byteValue()); if (nullOut) { headImpl.setHeader(HeaderSet.SINGLE_RESPONSE_MODE, null); } @@ -709,6 +728,7 @@ public final class ObexHelper { // Add the SRM parameter header byteHeader = (Byte)headImpl.getHeader(HeaderSet.SINGLE_RESPONSE_MODE_PARAMETER); if (byteHeader != null) { + if (VDBG) Log.v(TAG," Add Header = " + HeaderSet.SINGLE_RESPONSE_MODE_PARAMETER); out.write((byte)HeaderSet.SINGLE_RESPONSE_MODE_PARAMETER); out.write(byteHeader.byteValue()); if (nullOut) { diff --git a/obex/javax/obex/ObexSession.java b/obex/javax/obex/ObexSession.java index 542b9c8..f5e607c 100644 --- a/obex/javax/obex/ObexSession.java +++ b/obex/javax/obex/ObexSession.java @@ -50,7 +50,7 @@ import android.util.Log; public class ObexSession { private static final String TAG = "ObexSession"; - private static final boolean V = ObexHelper.VDBG; + private static final boolean V = Log.isLoggable(ObexHelper.LOG_TAG, Log.VERBOSE); protected Authenticator mAuthenticator; diff --git a/obex/javax/obex/ServerOperation.java b/obex/javax/obex/ServerOperation.java index 56a675a..28f5906 100644 --- a/obex/javax/obex/ServerOperation.java +++ b/obex/javax/obex/ServerOperation.java @@ -59,7 +59,7 @@ public final class ServerOperation implements Operation, BaseStream { private static final String TAG = "ServerOperation"; - private static final boolean V = ObexHelper.VDBG; // Verbose debugging + private static final boolean V = Log.isLoggable(ObexHelper.LOG_TAG, Log.VERBOSE); public boolean isAborted; @@ -124,6 +124,7 @@ public final class ServerOperation implements Operation, BaseStream { */ public ServerOperation(ServerSession p, InputStream in, int request, int maxSize, ServerRequestHandler listen) throws IOException { + if (V) Log.v(TAG, "ServerOperation"); isAborted = false; mParent = p; @@ -330,14 +331,17 @@ public final class ServerOperation implements Operation, BaseStream { */ public synchronized boolean continueOperation(boolean sendEmpty, boolean inStream) throws IOException { + if (V) Log.v(TAG, "continueOperation"); if (!mGetOperation) { if (!finalBitSet) { if (sendEmpty) { sendReply(ResponseCodes.OBEX_HTTP_CONTINUE); + if (V) Log.v(TAG, "continueOperation:ServerSet SRM sendEmpty clause"); return true; } else { if ((mResponseSize > 3) || (mPrivateOutput.size() > 0)) { sendReply(ResponseCodes.OBEX_HTTP_CONTINUE); + if (V) Log.v(TAG, "continueOperation: Server setting SRM"); return true; } else { return false; @@ -347,6 +351,7 @@ public final class ServerOperation implements Operation, BaseStream { return false; } } else { + if (V) Log.v(TAG, "Get continueOperation "); sendReply(ResponseCodes.OBEX_HTTP_CONTINUE); return true; } @@ -395,6 +400,8 @@ public final class ServerOperation implements Operation, BaseStream { bodyLength = mPrivateOutput.size(); orginalBodyLength = bodyLength; } + if(V)Log.v(TAG, "mMaxPcKLen : " + mMaxPacketLength); + if(V)Log.v(TAG, "headerArryLen : " + headerArray.length); if ((ObexHelper.BASE_PACKET_LENGTH + headerArray.length) > mMaxPacketLength) { diff --git a/obex/javax/obex/ServerSession.java b/obex/javax/obex/ServerSession.java index dcd0ce8..34a75f4 100644 --- a/obex/javax/obex/ServerSession.java +++ b/obex/javax/obex/ServerSession.java @@ -47,7 +47,7 @@ import java.io.OutputStream; public final class ServerSession extends ObexSession implements Runnable { private static final String TAG = "Obex ServerSession"; - private static final boolean V = ObexHelper.VDBG; + private static final boolean V = Log.isLoggable(ObexHelper.LOG_TAG, Log.VERBOSE); private ObexTransport mTransport; @@ -175,7 +175,7 @@ public final class ServerSession extends ObexSession implements Runnable { mInput.read(); } code = mListener.onAbort(request, reply); - Log.v(TAG, "onAbort request handler return value- " + code); + Log.d(TAG, "onAbort request handler return value- " + code); code = validateResponseCode(code); } sendResponse(code, null); @@ -195,6 +195,7 @@ public final class ServerSession extends ObexSession implements Runnable { * @throws IOException if an error occurred at the transport layer */ private void handlePutRequest(int type) throws IOException { + if (V) Log.v(TAG, "handlePutRequest"); ServerOperation op = new ServerOperation(this, mInput, type, mMaxPacketLength, mListener); try { int response = -1; @@ -206,10 +207,12 @@ public final class ServerSession extends ObexSession implements Runnable { response = validateResponseCode(mListener.onPut(op)); } if (response != ResponseCodes.OBEX_HTTP_OK && !op.isAborted) { + if (V) Log.v(TAG, "handlePutRequest pre != HTTP_OK sendReply"); op.sendReply(response); } else if (!op.isAborted) { // wait for the final bit while (!op.finalBitSet) { + if (V) Log.v(TAG, "handlePutRequest pre looped sendReply"); op.sendReply(ResponseCodes.OBEX_HTTP_CONTINUE); } op.sendReply(response); @@ -220,7 +223,7 @@ public final class ServerSession extends ObexSession implements Runnable { *internal error should not be sent because server has already replied with *OK response in "sendReply") */ - if(V) Log.d(TAG,"Exception occured - sending OBEX_HTTP_INTERNAL_ERROR reply",e); + if(V) Log.w(TAG,"Exception occured - sending OBEX_HTTP_INTERNAL_ERROR reply",e); if (!op.isAborted) { sendResponse(ResponseCodes.OBEX_HTTP_INTERNAL_ERROR, null); } @@ -241,6 +244,7 @@ public final class ServerSession extends ObexSession implements Runnable { * @throws IOException if an error occurred at the transport layer */ private void handleGetRequest(int type) throws IOException { + if (V) Log.v(TAG, "handleGetRequest"); ServerOperation op = new ServerOperation(this, mInput, type, mMaxPacketLength, mListener); try { int response = validateResponseCode(mListener.onGet(op)); @@ -263,6 +267,7 @@ public final class ServerSession extends ObexSession implements Runnable { public void sendResponse(int code, byte[] header) throws IOException { int totalLength = 3; byte[] data = null; + if (V) Log.v(TAG,"sendResponse code " + code + " header : " + header); OutputStream op = mOutput; if (op == null) { return; @@ -270,6 +275,7 @@ public final class ServerSession extends ObexSession implements Runnable { if (header != null) { totalLength += header.length; + if (V) Log.v(TAG, "header != null totalLength = " + totalLength); data = new byte[totalLength]; data[0] = (byte)code; data[1] = (byte)(totalLength >> 8); |