Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76f9fb7a authored by Ashwini Munigala's avatar Ashwini Munigala Committed by Linux Build Service Account
Browse files

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
parent a6942694
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;

+2 −1
Original line number Diff line number Diff line
@@ -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);
    }
}
+24 −4
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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;

+8 −1
Original line number Diff line number Diff line
@@ -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) {

Loading