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

Commit f631d689 authored by Casper Bonde's avatar Casper Bonde Committed by Android Git Automerger
Browse files

am 90923da2: am 13c41337: SAP: Fix missing attribute in disconnect_ind

* commit '90923da2':
  SAP: Fix missing attribute in disconnect_ind
parents 9055ee26 90923da2
Loading
Loading
Loading
Loading
+75 −93
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ public class SapMessage {
    public static final String TAG = "SapMessage";
    public static final boolean DEBUG = SapService.DEBUG;
    public static final boolean VERBOSE = SapService.VERBOSE;
    public static final boolean TEST = SapService.PTS_TEST;
    public static final boolean TEST = false;

    /* Message IDs - SAP specification */
    public static final int ID_CONNECT_REQ        = 0x00;
@@ -404,11 +404,9 @@ public class SapMessage {
        case ID_DISCONNECT_REQ:    /* No params */
            break;
        default:
            if(TEST == false) {
            Log.e(TAG, "Unknown request type");
            return null;
        }
        }
        return newMessage;
    }

@@ -504,8 +502,7 @@ public class SapMessage {
                }
                break;
            case PARAM_CONNECTION_STATUS_ID:
                // not needed - server -> client
                if(TEST) {
                // not needed for server role, but used for module test
                if(paramLength != PARAM_CONNECTION_STATUS_LENGTH) {
                    Log.e(TAG, "Received PARAM_CONNECTION_STATUS with wrong length: " +
                            paramLength + " skipping this parameter.");
@@ -516,10 +513,8 @@ public class SapMessage {
                    skip(is, 4 - PARAM_CONNECTION_STATUS_LENGTH);
                }
                break;
                } // Fall through if TEST == false
            case PARAM_CARD_READER_STATUS_ID:
                // not needed - server -> client
                if(TEST) {
                // not needed for server role, but used for module test
                if(paramLength != PARAM_CARD_READER_STATUS_LENGTH) {
                    Log.e(TAG, "Received PARAM_CARD_READER_STATUS with wrong length: " +
                            paramLength + " skipping this parameter.");
@@ -530,10 +525,8 @@ public class SapMessage {
                    skip(is, 4 - PARAM_CARD_READER_STATUS_LENGTH);
                }
                break;
                } // Fall through if TEST == false
            case PARAM_STATUS_CHANGE_ID:
                // not needed - server -> client
                if(TEST) {
                // not needed for server role, but used for module test
                if(paramLength != PARAM_STATUS_CHANGE_LENGTH) {
                    Log.e(TAG, "Received PARAM_STATUS_CHANGE with wrong length: " +
                            paramLength + " skipping this parameter.");
@@ -544,10 +537,8 @@ public class SapMessage {
                    skip(is, 4 - PARAM_STATUS_CHANGE_LENGTH);
                }
                break;
                } // Fall through if TEST == false
            case PARAM_RESULT_CODE_ID:
                // not needed - server -> client
                if(TEST) {
                // not needed for server role, but used for module test
                if(paramLength != PARAM_RESULT_CODE_LENGTH) {
                    Log.e(TAG, "Received PARAM_RESULT_CODE with wrong length: " +
                            paramLength + " skipping this parameter.");
@@ -558,10 +549,8 @@ public class SapMessage {
                    skip(is, 4 - PARAM_RESULT_CODE_LENGTH);
                }
                break;
                } // Fall through if TEST == false
            case PARAM_DISCONNECT_TYPE_ID:
                // not needed - server -> client
                if(TEST) {
                // not needed for server role, but used for module test
                if(paramLength != PARAM_DISCONNECT_TYPE_LENGTH) {
                    Log.e(TAG, "Received PARAM_DISCONNECT_TYPE_ID with wrong length: " +
                            paramLength + " skipping this parameter.");
@@ -572,23 +561,18 @@ public class SapMessage {
                    skip(is, 4 - PARAM_DISCONNECT_TYPE_LENGTH);
                }
                break;
                } // Fall through if TEST == false
            case PARAM_RESPONSE_APDU_ID:
                // not needed - server -> client
                if(TEST) {
                // not needed for server role, but used for module test
                mApduResp = new byte[paramLength];
                read(is, mApduResp);
                skip(is, skipLen);
                break;
                } // Fall through if TEST == false
            case PARAM_ATR_ID:
                // not needed - server -> client
                if(TEST) {
                // not needed for server role, but used for module test
                mAtr = new byte[paramLength];
                read(is, mAtr);
                skip(is, skipLen);
                break;
                } // Fall through if TEST == false
            default:
                Log.e(TAG, "Received unknown parameter ID: " + paramId + " length: " +
                        paramLength + " skipping this parameter.");
@@ -677,7 +661,7 @@ public class SapMessage {
            writeParameter(os, PARAM_RESULT_CODE_ID, mResultCode,
                            PARAM_RESULT_CODE_LENGTH);
        }
        if(mDisconnectionType != INVALID_VALUE && TEST) {
        if(mDisconnectionType != INVALID_VALUE) {
            writeParameter(os, PARAM_DISCONNECT_TYPE_ID, mDisconnectionType,
                            PARAM_DISCONNECT_TYPE_LENGTH);
        }
@@ -689,14 +673,14 @@ public class SapMessage {
            writeParameter(os, PARAM_STATUS_CHANGE_ID, mStatusChange,
                            PARAM_STATUS_CHANGE_LENGTH);
        }
        if(mTransportProtocol != INVALID_VALUE && TEST) {
        if(mTransportProtocol != INVALID_VALUE) {
            writeParameter(os, PARAM_TRANSPORT_PROTOCOL_ID, mTransportProtocol,
                            PARAM_TRANSPORT_PROTOCOL_LENGTH);
        }
        if(mApdu != null && TEST) {
        if(mApdu != null) {
            writeParameter(os, PARAM_COMMAND_APDU_ID, mApdu);
        }
        if(mApdu7816 != null  && TEST) {
        if(mApdu7816 != null) {
            writeParameter(os, PARAM_COMMAND_APDU7816_ID, mApdu7816);
        }
        if(mApduResp != null) {
@@ -847,11 +831,9 @@ public class SapMessage {
            break;
        }
        default:
            if(TEST == false) {
            Log.e(TAG, "Unknown request type");
            throw new IllegalArgumentException();
        }
        }
        /* Update the ongoing requests queue */
        if(mClearRilQueue == true) {
            resetPendingRilMessages();
@@ -1223,7 +1205,7 @@ public class SapMessage {


    public static String getMsgTypeName(int msgType) {
        if(TEST || VERBOSE) {
        if(DEBUG || VERBOSE) {
            switch (msgType)
            {
                case ID_CONNECT_REQ: return "ID_CONNECT_REQ";
+18 −3
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import java.io.OutputStream;
import java.util.concurrent.CountDownLatch;

import com.android.bluetooth.R;

import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
@@ -26,8 +27,10 @@ import android.os.Looper;
import android.os.Message;
import android.os.Parcel;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.telephony.TelephonyManager;
import android.util.Log;

//import com.android.internal.telephony.RIL;
import com.google.protobuf.micro.CodedOutputStreamMicro;

@@ -48,7 +51,6 @@ public class SapServer extends Thread implements Callback {
    private static final String TAG_HANDLER = "SapServerHandler";
    public static final boolean DEBUG = SapService.DEBUG;
    public static final boolean VERBOSE = SapService.VERBOSE;
    public static final boolean PTS_TEST = SapService.PTS_TEST;

    private enum SAP_STATE    {
        DISCONNECTED, CONNECTING, CONNECTING_CALL_ONGOING, CONNECTED,
@@ -212,6 +214,13 @@ public class SapServer extends Thread implements Callback {
        String title, text, button, ticker;
        Notification notification;
        if(VERBOSE) Log.i(TAG, "setNotification type: " + type);
        /* For PTS TC_SERVER_DCN_BV_03_I we need to expose the option to send immediate disconnect
         * without first sending a graceful disconnect.
         * To enable this option set
         * bt.sap.pts="true" */
        String pts_enabled = SystemProperties.get("bt.sap.pts");
        Boolean pts_test = Boolean.parseBoolean(pts_enabled);

        /* put notification up for the user to be able to disconnect from the client*/
        Intent sapDisconnectIntent = new Intent(SapServer.SAP_DISCONNECT_ACTION);
        if(type == SapMessage.DISC_GRACEFULL){
@@ -225,7 +234,7 @@ public class SapServer extends Thread implements Callback {
            text = mContext.getString(R.string.bluetooth_sap_notif_disconnecting);
            ticker = mContext.getString(R.string.bluetooth_sap_notif_ticker);
        }
        if(!PTS_TEST)
        if(!pts_test)
        {
            sapDisconnectIntent.putExtra(SapServer.SAP_DISCONNECT_TYPE_EXTRA, type);
            PendingIntent pIntentDisconnect = PendingIntent.getBroadcast(mContext, type,
@@ -822,12 +831,18 @@ public class SapServer extends Thread implements Callback {
        if(VERBOSE) Log.i(TAG_HANDLER, "sendRilMessage() - "
                + SapMessage.getMsgTypeName(sapMsg.getMsgType()));
        try {
            if (mRilBtOutStream != null)
            if(mRilBtOutStream != null) {
                sapMsg.writeReqToStream(mRilBtOutStream);
            } /* Else SAP was enabled on a build that did not support SAP, which we will not
               * handle. */
        } catch (IOException e) {
            Log.e(TAG_HANDLER, "Unable to send message to RIL", e);
            SapMessage errorReply = new SapMessage(SapMessage.ID_ERROR_RESP);
            sendClientMessage(errorReply);
        } catch (IllegalArgumentException e) {
            Log.e(TAG_HANDLER, "Unable encode message", e);
            SapMessage errorReply = new SapMessage(SapMessage.ID_ERROR_RESP);
            sendClientMessage(errorReply);
        }
    }

+0 −1
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ public class SapService extends ProfileService {
    private static final String TAG = "SapService";
    public static final boolean DEBUG = false;
    public static final boolean VERBOSE = false;
    public static final boolean PTS_TEST = false;

    /* Message ID's */
    private static final int START_LISTENER = 1;