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

Commit a23c9d40 authored by Aritra Sen's avatar Aritra Sen
Browse files

Change the BluetoothSocket#connect API to return L2CAP connection error code...

Change the BluetoothSocket#connect API to return L2CAP connection error code propagated from Native.

Bug: 263522407
Test: mma -j $(nproc)
Change-Id: Ia2d84cbc776aceeb59c330e731ac800642dbacf3
parent e5a87118
Loading
Loading
Loading
Loading
+34 −1
Original line number Diff line number Diff line
@@ -440,7 +440,40 @@ public final class BluetoothSocket implements Closeable {
                mSocketOS = mSocket.getOutputStream();
            }
            int channel = readInt(mSocketIS);
            if (channel <= 0) {
            if (channel == 0) {
                int errCode = (int) mSocketIS.read();
                switch(errCode) {
                    case /*BTA_JV_L2CAP_REASON_ACL_FAILURE*/ 2:
                        throw new IOException("ACL connection failed");
                    case /*BTA_JV_L2CAP_REASON_CL_SEC_FAILURE*/ 3:
                        throw new IOException("Client security clearance failed");
                    case /*BTA_JV_L2CAP_REASON_INSUFFICIENT_AUTHENTICATION*/ 4:
                        throw new IOException("Insufficient authentication");
                    case /*BTA_JV_L2CAP_REASON_INSUFFICIENT_AUTHORIZATION*/ 5:
                        throw new IOException("Insufficient authorization");
                    case /*BTA_JV_L2CAP_REASON_INSUFFICIENT_ENCRYP_KEY_SIZE*/ 6:
                        throw new IOException("Insufficient encryption key size");
                    case /*BTA_JV_L2CAP_REASON_INSUFFICIENT_ENCRYP*/ 7:
                        throw new IOException("Insufficient encryption");
                    case /*BTA_JV_L2CAP_REASON_INVALID_SOURCE_CID*/ 8:
                        throw new IOException("Invalid source CID");
                    case /*BTA_JV_L2CAP_REASON_SOURCE_CID_ALREADY_ALLOCATED*/ 9:
                        throw new IOException("Source CID already allocated");
                    case /*BTA_JV_L2CAP_REASON_UNACCEPTABLE_PARAMETERS*/ 10:
                        throw new IOException("Unacceptable Parameters");
                    case /*BTA_JV_L2CAP_REASON_INVALID_PARAMETERS*/ 11:
                        throw new IOException("Invalid Parameters");
                    case /*BTA_JV_L2CAP_REASON_NO_RESOURCES*/ 12:
                        throw new IOException("No resources Available");
                    case /*BTA_JV_L2CAP_REASON_NO_PSM*/ 13:
                        throw new IOException("No PSM available");
                    case /*BTA_JV_L2CAP_REASON_TIMEOUT*/ 14:
                        throw new IOException("Connection Timeout");
                    default:
                        throw new IOException("bt socket connect failed for unknown reason");
                }
            }
            if (channel < 0) {
                throw new IOException("bt socket connect failed");
            }
            mPort = channel;