summaryrefslogtreecommitdiffstats
path: root/core/java/android/server/BluetoothEventLoop.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/server/BluetoothEventLoop.java')
-rw-r--r--core/java/android/server/BluetoothEventLoop.java49
1 files changed, 48 insertions, 1 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index eb9b62b..9948060 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -21,6 +21,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothInputDevice;
+import android.bluetooth.BluetoothPan;
import android.bluetooth.BluetoothUuid;
import android.content.Context;
import android.content.Intent;
@@ -365,7 +366,8 @@ class BluetoothEventLoop {
return;
}
if (DBG) {
- log("Device property changed:" + address + "property:" + name);
+ log("Device property changed: " + address + " property: "
+ + name + " value: " + propValues[1]);
}
BluetoothDevice device = mAdapter.getRemoteDevice(address);
if (name.equals("Name")) {
@@ -442,6 +444,25 @@ class BluetoothEventLoop {
mBluetoothService.handleInputDevicePropertyChange(address, state);
}
+ private void onPanDevicePropertyChanged(String deviceObjectPath, String[] propValues) {
+ String name = propValues[0];
+ String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath);
+ if (address == null) {
+ Log.e(TAG, "onPanDevicePropertyChanged: Address of the remote device in null");
+ return;
+ }
+ if (DBG) {
+ log("Pan Device property changed: " + address + " property: "
+ + name + " value: "+ propValues[1]);
+ }
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (name.equals("Connected")) {
+ int state = propValues[1].equals("true") ? BluetoothInputDevice.STATE_CONNECTED :
+ BluetoothInputDevice.STATE_DISCONNECTED;
+ mBluetoothService.handlePanDeviceStateChange(device, state);
+ }
+ }
+
private String checkPairingRequestAndGetAddress(String objectPath, int nativeData) {
String address = mBluetoothService.getAddressFromObjectPath(objectPath);
if (address == null) {
@@ -623,6 +644,8 @@ class BluetoothEventLoop {
} else {
Log.i(TAG, "Rejecting incoming HID connection from " + address);
}
+ } else if (BluetoothUuid.isNAP(uuid)){
+ authorized = true;
} else {
Log.i(TAG, "Rejecting incoming " + deviceUuid + " connection from " + address);
}
@@ -713,6 +736,30 @@ class BluetoothEventLoop {
}
}
+ private void onPanDeviceConnectionResult(String path, boolean result) {
+ log ("onPanDeviceConnectionResult " + path + " " + result);
+ // Success case gets handled by Property Change signal
+ if (!result) {
+ String address = mBluetoothService.getAddressFromObjectPath(path);
+ if (address == null) return;
+
+ boolean connected = false;
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ int state = mBluetoothService.getPanDeviceState(device);
+ if (state == BluetoothPan.STATE_CONNECTING) {
+ connected = false;
+ } else if (state == BluetoothPan.STATE_DISCONNECTING) {
+ connected = true;
+ } else {
+ Log.e(TAG, "Error onPanDeviceConnectionResult. State is: "
+ + state + " result: "+ result);
+ }
+ int newState = connected? BluetoothPan.STATE_CONNECTED :
+ BluetoothPan.STATE_DISCONNECTED;
+ mBluetoothService.handlePanDeviceStateChange(device, newState);
+ }
+ }
+
private void onRestartRequired() {
if (mBluetoothService.isEnabled()) {
Log.e(TAG, "*** A serious error occured (did bluetoothd crash?) - " +