diff options
author | Jake Hamby <jhamby@google.com> | 2010-12-21 16:55:04 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-12-21 16:55:04 -0800 |
commit | 5d71e1400894c356cd8e69a54c7b83ce4a993b3b (patch) | |
tree | 93dce63746bb375e1fa2704a4fc15a18f2bca764 /core/java/android/server | |
parent | 19d0cefd0000c2dbb9adab7d3c737cbd8314ccfb (diff) | |
parent | 5200c8ab721b56025340306bdecca651e6bf2f12 (diff) | |
download | frameworks_base-5d71e1400894c356cd8e69a54c7b83ce4a993b3b.zip frameworks_base-5d71e1400894c356cd8e69a54c7b83ce4a993b3b.tar.gz frameworks_base-5d71e1400894c356cd8e69a54c7b83ce4a993b3b.tar.bz2 |
Merge "Add EXTRA_LOCAL_ROLE to Pan State change intent."
Diffstat (limited to 'core/java/android/server')
-rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 15 | ||||
-rw-r--r-- | core/java/android/server/BluetoothService.java | 36 |
2 files changed, 32 insertions, 19 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index 3b2e254..ff8be15 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -420,12 +420,14 @@ class BluetoothEventLoop { if (name.equals("Connected")) { if (propValues[1].equals("false")) { mBluetoothService.handlePanDeviceStateChange(device, - BluetoothInputDevice.STATE_DISCONNECTED); + BluetoothPan.STATE_DISCONNECTED, + BluetoothPan.LOCAL_PANU_ROLE); } } else if (name.equals("Interface")) { String iface = propValues[1]; mBluetoothService.handlePanDeviceStateChange(device, iface, - BluetoothInputDevice.STATE_CONNECTED); + BluetoothPan.STATE_CONNECTED, + BluetoothPan.LOCAL_PANU_ROLE); } } @@ -751,18 +753,21 @@ class BluetoothEventLoop { } int newState = connected? BluetoothPan.STATE_CONNECTED : BluetoothPan.STATE_DISCONNECTED; - mBluetoothService.handlePanDeviceStateChange(device, newState); + mBluetoothService.handlePanDeviceStateChange(device, newState, + BluetoothPan.LOCAL_PANU_ROLE); } } private void onNetworkDeviceDisconnected(String address) { BluetoothDevice device = mAdapter.getRemoteDevice(address); - mBluetoothService.handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTED); + mBluetoothService.handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTED, + BluetoothPan.LOCAL_NAP_ROLE); } private void onNetworkDeviceConnected(String address, String iface, int destUuid) { BluetoothDevice device = mAdapter.getRemoteDevice(address); - mBluetoothService.handlePanDeviceStateChange(device, iface, BluetoothPan.STATE_CONNECTED); + mBluetoothService.handlePanDeviceStateChange(device, iface, BluetoothPan.STATE_CONNECTED, + BluetoothPan.LOCAL_NAP_ROLE); } private void onRestartRequired() { diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index f91db87..af3730e 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -1513,12 +1513,14 @@ public class BluetoothService extends IBluetooth.Stub { return false; } - handlePanDeviceStateChange(device, BluetoothPan.STATE_CONNECTING); - if (connectPanDeviceNative(objectPath, "nap")) { + handlePanDeviceStateChange(device, BluetoothPan.STATE_CONNECTING, + BluetoothPan.LOCAL_PANU_ROLE); + if (connectPanDeviceNative(objectPath, "nap", "panu")) { log ("connecting to PAN"); return true; } else { - handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTED); + handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTED, + BluetoothPan.LOCAL_PANU_ROLE); log ("could not connect to PAN"); return false; } @@ -1560,13 +1562,15 @@ public class BluetoothService extends IBluetooth.Stub { if (getPanDeviceState(device) != BluetoothPan.STATE_CONNECTED) { log (device + " already disconnected from PAN"); } - handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTING); + handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTING, + BluetoothPan.LOCAL_PANU_ROLE); return disconnectPanDeviceNative(objectPath); } /*package*/ synchronized void handlePanDeviceStateChange(BluetoothDevice device, String iface, - int state) { + int state, + int role) { int prevState; String ifaceAddr = null; @@ -1578,13 +1582,16 @@ public class BluetoothService extends IBluetooth.Stub { } if (prevState == state) return; - if (state == BluetoothPan.STATE_CONNECTED) { - ifaceAddr = enableTethering(iface); - if (ifaceAddr == null) Log.e(TAG, "Error seting up tether interface"); - } else if (state == BluetoothPan.STATE_DISCONNECTED) { - if (ifaceAddr != null) { - mBluetoothIfaceAddresses.remove(ifaceAddr); - ifaceAddr = null; + // TODO: We might need this for PANU role too. + if (role == BluetoothPan.LOCAL_NAP_ROLE) { + if (state == BluetoothPan.STATE_CONNECTED) { + ifaceAddr = enableTethering(iface); + if (ifaceAddr == null) Log.e(TAG, "Error seting up tether interface"); + } else if (state == BluetoothPan.STATE_DISCONNECTED) { + if (ifaceAddr != null) { + mBluetoothIfaceAddresses.remove(ifaceAddr); + ifaceAddr = null; + } } } @@ -1595,6 +1602,7 @@ public class BluetoothService extends IBluetooth.Stub { intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); intent.putExtra(BluetoothPan.EXTRA_PREVIOUS_PAN_STATE, prevState); intent.putExtra(BluetoothPan.EXTRA_PAN_STATE, state); + intent.putExtra(BluetoothPan.EXTRA_LOCAL_ROLE, role); mContext.sendBroadcast(intent, BLUETOOTH_PERM); if (DBG) log("Pan Device state : device: " + device + " State:" + prevState + "->" + state); @@ -1602,8 +1610,8 @@ public class BluetoothService extends IBluetooth.Stub { } /*package*/ synchronized void handlePanDeviceStateChange(BluetoothDevice device, - int state) { - handlePanDeviceStateChange(device, null, state); + int state, int role) { + handlePanDeviceStateChange(device, null, state, role); } private String createNewTetheringAddressLocked() { |