aboutsummaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothAdapter.java
diff options
context:
space:
mode:
authorVinit Deshpande <vinitd@google.com>2015-04-14 16:15:02 -0700
committerVinit Deshpande <vinitd@google.com>2015-04-14 16:15:02 -0700
commit40a7fac42afb88359928b08ca036526139c48dd1 (patch)
tree74af6612345382f7bf1b7a4b03a453075f38e35f /framework/java/android/bluetooth/BluetoothAdapter.java
parent467aff6bb03c185080e94b70ecf71c580681d487 (diff)
parent9653e2757354c571ff9354b1b3a2c3282b2af43f (diff)
am b5e0cfb..557d2f5 from mirror-m-wireless-internal-release
557d2f5 Merge "Add ConnectivityManager.reportNetworkConnectivity() API" into m-wireless-dev 9653e27 Fix onLost/onFound logic in isSettingsAndFilterComboAllowed bfd17b7 Add ConnectivityManager.reportNetworkConnectivity() API c0a7c93 OBEX Over L2CAP + SDP search API for BT profiles 31a94f4 Add ConnectivityManager.getActiveNetwork(). Rework NetID allocation in ConnectivityService so registerNetworkAgent() can return the allocated NetID. bf18bed Merge "Non-functional code cleanup of ConnectivityService." into m-wireless-dev db8784e Merge "Cleanup of Video Call pause functionality." into m-wireless-dev e75b9e3 Non-functional code cleanup of ConnectivityService. 98d25c5 Onfound onlost feature. 0326f58 Merge "API for config app." into m-wireless-dev e9b056f API for config app. d5351e7 RTT framework interface update 582b868 Unhide Network.openConnection(URL, Proxy). 0d719ca Fix typos in ConnectivityManager documentation. Change-Id: Ib4c88f6d7ad1b24227b032555c62a5804194384b
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothAdapter.java48
1 files changed, 47 insertions, 1 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index 2b3cf340bc..87d5bb030e 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2009-2014 The Android Open Source Project
+ * Copyright (C) 2009-2015 The Android Open Source Project
+ * Copyright (C) 2015 Samsung LSI
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -374,6 +375,18 @@ public final class BluetoothAdapter {
/** @hide */
public static final String BLUETOOTH_MANAGER_SERVICE = "bluetooth_manager";
+
+ /** When creating a ServerSocket using listenUsingRfcommOn() or
+ * listenUsingL2capOn() use SOCKET_CHANNEL_AUTO_STATIC to create
+ * a ServerSocket that auto assigns a channel number to the first
+ * bluetooth socket.
+ * The channel number assigned to this first Bluetooth Socket will
+ * be stored in the ServerSocket, and reused for subsequent Bluetooth
+ * sockets.
+ * @hide */
+ public static final int SOCKET_CHANNEL_AUTO_STATIC_NO_SDP = -2;
+
+
private static final int ADDRESS_LENGTH = 17;
private static final int CONTROLLER_ENERGY_UPDATE_TIMEOUT_MILLIS = 30;
@@ -1141,6 +1154,9 @@ public final class BluetoothAdapter {
BluetoothServerSocket socket = new BluetoothServerSocket(
BluetoothSocket.TYPE_RFCOMM, true, true, channel);
int errno = socket.mSocket.bindListen();
+ if(channel == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ socket.setChannel(socket.mSocket.getPort());
+ }
if (errno != 0) {
//TODO(BT): Throw the same exception error code
// that the previous code was using.
@@ -1275,6 +1291,9 @@ public final class BluetoothAdapter {
BluetoothServerSocket socket = new BluetoothServerSocket(
BluetoothSocket.TYPE_RFCOMM, false, false, port);
int errno = socket.mSocket.bindListen();
+ if(port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ socket.setChannel(socket.mSocket.getPort());
+ }
if (errno != 0) {
//TODO(BT): Throw the same exception error code
// that the previous code was using.
@@ -1297,6 +1316,9 @@ public final class BluetoothAdapter {
BluetoothServerSocket socket = new BluetoothServerSocket(
BluetoothSocket.TYPE_RFCOMM, false, true, port);
int errno = socket.mSocket.bindListen();
+ if(port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ socket.setChannel(socket.mSocket.getPort());
+ }
if (errno < 0) {
//TODO(BT): Throw the same exception error code
// that the previous code was using.
@@ -1327,6 +1349,30 @@ public final class BluetoothAdapter {
}
/**
+ * Construct an encrypted, authenticated, L2CAP server socket.
+ * Call #accept to retrieve connections to this socket.
+ * @return An L2CAP BluetoothServerSocket
+ * @throws IOException On error, for example Bluetooth not available, or
+ * insufficient permissions.
+ * @hide
+ */
+ public BluetoothServerSocket listenUsingL2capOn(int port) throws IOException {
+ BluetoothServerSocket socket = new BluetoothServerSocket(
+ BluetoothSocket.TYPE_L2CAP, true, true, port);
+ int errno = socket.mSocket.bindListen();
+ if(port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ socket.setChannel(socket.mSocket.getPort());
+ }
+ if (errno != 0) {
+ //TODO(BT): Throw the same exception error code
+ // that the previous code was using.
+ //socket.mSocket.throwErrnoNative(errno);
+ throw new IOException("Error: " + errno);
+ }
+ return socket;
+ }
+
+ /**
* Read the local Out of Band Pairing Data
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
*