diff options
| author | Ivan Podogov <ginkage@google.com> | 2017-01-04 10:37:38 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2017-01-04 10:37:38 +0000 |
| commit | a7d58fecc69174df9db8fdc28645e57afe976181 (patch) | |
| tree | bc99014b203860abe4a42e567338f748f02395bf /core/java/android | |
| parent | ca5d56009074e8f8c7cb3e0bf00194a43b4f4260 (diff) | |
| parent | f33a71d017cbefb18408cd77ec8688121639151a (diff) | |
Merge "HID Device role API fixes"
am: f33a71d017
Change-Id: Ib7f524b7ad0bf63b852f2ffd4039d8b47ef7fc01
Diffstat (limited to 'core/java/android')
4 files changed, 108 insertions, 66 deletions
diff --git a/core/java/android/bluetooth/BluetoothHidDeviceCallback.java b/core/java/android/bluetooth/BluetoothHidDeviceCallback.java index 0f0e050a1f40..f519776276fc 100644 --- a/core/java/android/bluetooth/BluetoothHidDeviceCallback.java +++ b/core/java/android/bluetooth/BluetoothHidDeviceCallback.java @@ -45,9 +45,9 @@ public abstract class BluetoothHidDeviceCallback { * <code>false</code> otherwise. */ public void onAppStatusChanged(BluetoothDevice pluggedDevice, - BluetoothHidDeviceAppConfiguration config, boolean registered) { - Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + (pluggedDevice == null ? - null : pluggedDevice.toString()) + " registered=" + registered); + BluetoothHidDeviceAppConfiguration config, boolean registered) { + Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + pluggedDevice + " registered=" + + registered); } /** @@ -60,13 +60,13 @@ public abstract class BluetoothHidDeviceCallback { * @param state Connection state as defined in {@link BluetoothProfile}. */ public void onConnectionStateChanged(BluetoothDevice device, int state) { - Log.d(TAG, "onConnectionStateChanged: device=" + device.toString() + " state=" + state); + Log.d(TAG, "onConnectionStateChanged: device=" + device + " state=" + state); } /** * Callback called when GET_REPORT is received from remote host. Should be * replied by application using - * {@link BluetoothHidDevice#replyReport(byte, byte, byte[])}. + * {@link BluetoothHidDevice#replyReport(BluetoothDevice, byte, byte, byte[])}. * * @param type Requested Report Type. * @param id Requested Report Id, can be 0 if no Report Id are defined in @@ -74,21 +74,22 @@ public abstract class BluetoothHidDeviceCallback { * @param bufferSize Requested buffer size, application shall respond with * at least given number of bytes. */ - public void onGetReport(byte type, byte id, int bufferSize) { - Log.d(TAG, "onGetReport: type=" + type + " id=" + id + " bufferSize=" + bufferSize); + public void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize) { + Log.d(TAG, "onGetReport: device=" + device + " type=" + type + " id=" + id + " bufferSize=" + + bufferSize); } /** * Callback called when SET_REPORT is received from remote host. In case * received data are invalid, application shall respond with - * {@link BluetoothHidDevice#reportError()}. + * {@link BluetoothHidDevice#reportError(BluetoothDevice)}. * * @param type Report Type. * @param id Report Id. * @param data Report data. */ - public void onSetReport(byte type, byte id, byte[] data) { - Log.d(TAG, "onSetReport: type=" + type + " id=" + id); + public void onSetReport(BluetoothDevice device, byte type, byte id, byte[] data) { + Log.d(TAG, "onSetReport: device=" + device + " type=" + type + " id=" + id); } /** @@ -99,8 +100,8 @@ public abstract class BluetoothHidDeviceCallback { * * @param protocol Protocol Mode. */ - public void onSetProtocol(byte protocol) { - Log.d(TAG, "onSetProtocol: protocol=" + protocol); + public void onSetProtocol(BluetoothDevice device, byte protocol) { + Log.d(TAG, "onSetProtocol: device=" + device + " protocol=" + protocol); } /** @@ -111,16 +112,17 @@ public abstract class BluetoothHidDeviceCallback { * @param reportId Report Id. * @param data Report data. */ - public void onIntrData(byte reportId, byte[] data) { - Log.d(TAG, "onIntrData: reportId=" + reportId); + public void onIntrData(BluetoothDevice device, byte reportId, byte[] data) { + Log.d(TAG, "onIntrData: device=" + device + " reportId=" + reportId); } /** * Callback called when Virtual Cable is removed. This can be either due to - * {@link BluetoothHidDevice#unplug()} or request from remote side. After - * this callback is received connection will be disconnected automatically. + * {@link BluetoothHidDevice#unplug(BluetoothDevice)} or request from remote + * side. After this callback is received connection will be disconnected + * automatically. */ - public void onVirtualCableUnplug() { - Log.d(TAG, "onVirtualCableUnplug"); + public void onVirtualCableUnplug(BluetoothDevice device) { + Log.d(TAG, "onVirtualCableUnplug: device=" + device); } } diff --git a/core/java/android/bluetooth/BluetoothInputHost.java b/core/java/android/bluetooth/BluetoothInputHost.java index 129fe7ecdc39..68d105f1155d 100644 --- a/core/java/android/bluetooth/BluetoothInputHost.java +++ b/core/java/android/bluetooth/BluetoothInputHost.java @@ -27,6 +27,7 @@ import android.os.RemoteException; import android.util.Log; import java.util.Arrays; +import java.util.ArrayList; import java.util.List; /** @@ -137,28 +138,28 @@ public final class BluetoothInputHost implements BluetoothProfile { } @Override - public void onGetReport(byte type, byte id, int bufferSize) { - mCallback.onGetReport(type, id, bufferSize); + public void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize) { + mCallback.onGetReport(device, type, id, bufferSize); } @Override - public void onSetReport(byte type, byte id, byte[] data) { - mCallback.onSetReport(type, id, data); + public void onSetReport(BluetoothDevice device, byte type, byte id, byte[] data) { + mCallback.onSetReport(device, type, id, data); } @Override - public void onSetProtocol(byte protocol) { - mCallback.onSetProtocol(protocol); + public void onSetProtocol(BluetoothDevice device, byte protocol) { + mCallback.onSetProtocol(device, protocol); } @Override - public void onIntrData(byte reportId, byte[] data) { - mCallback.onIntrData(reportId, data); + public void onIntrData(BluetoothDevice device, byte reportId, byte[] data) { + mCallback.onIntrData(device, reportId, data); } @Override - public void onVirtualCableUnplug() { - mCallback.onVirtualCableUnplug(); + public void onVirtualCableUnplug(BluetoothDevice device) { + mCallback.onVirtualCableUnplug(device); } } @@ -276,21 +277,59 @@ public final class BluetoothInputHost implements BluetoothProfile { mServiceListener = null; } - @Override + /** + * {@inheritDoc} + */ public List<BluetoothDevice> getConnectedDevices() { Log.v(TAG, "getConnectedDevices()"); - return null; + + if (mService != null) { + try { + return mService.getConnectedDevices(); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + } + + return new ArrayList<BluetoothDevice>(); } - @Override + /** + * {@inheritDoc} + */ public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { Log.v(TAG, "getDevicesMatchingConnectionStates(): states=" + Arrays.toString(states)); - return null; + + if (mService != null) { + try { + return mService.getDevicesMatchingConnectionStates(states); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + } + + return new ArrayList<BluetoothDevice>(); } - @Override + /** + * {@inheritDoc} + */ public int getConnectionState(BluetoothDevice device) { - Log.v(TAG, "getConnectionState(): device=" + device.getAddress()); + Log.v(TAG, "getConnectionState(): device=" + device); + + if (mService != null) { + try { + return mService.getConnectionState(device); + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } + } else { + Log.w(TAG, "Proxy not attached to service"); + } return STATE_DISCONNECTED; } @@ -379,14 +418,12 @@ public final class BluetoothInputHost implements BluetoothProfile { * @param data Report data, not including Report Id. * @return */ - public boolean sendReport(int id, byte[] data) { - Log.v(TAG, "sendReport(): id=" + id); - + public boolean sendReport(BluetoothDevice device, int id, byte[] data) { boolean result = false; if (mService != null) { try { - result = mService.sendReport(id, data); + result = mService.sendReport(device, id, data); } catch (RemoteException e) { Log.e(TAG, e.toString()); } @@ -399,21 +436,21 @@ public final class BluetoothInputHost implements BluetoothProfile { /** * Sends report to remote host as reply for GET_REPORT request from - * {@link BluetoothHidDeviceCallback#onGetReport(byte, byte, int)}. + * {@link BluetoothHidDeviceCallback#onGetReport(BluetoothDevice, byte, byte, int)}. * * @param type Report Type, as in request. * @param id Report Id, as in request. * @param data Report data, not including Report Id. * @return */ - public boolean replyReport(byte type, byte id, byte[] data) { - Log.v(TAG, "replyReport(): type=" + type + " id=" + id); + public boolean replyReport(BluetoothDevice device, byte type, byte id, byte[] data) { + Log.v(TAG, "replyReport(): device=" + device + " type=" + type + " id=" + id); boolean result = false; if (mService != null) { try { - result = mService.replyReport(type, id, data); + result = mService.replyReport(device, type, id, data); } catch (RemoteException e) { Log.e(TAG, e.toString()); } @@ -426,19 +463,19 @@ public final class BluetoothInputHost implements BluetoothProfile { /** * Sends error handshake message as reply for invalid SET_REPORT request - * from {@link BluetoothHidDeviceCallback#onSetReport(byte, byte, byte[])}. + * from {@link BluetoothHidDeviceCallback#onSetReport(BluetoothDevice, byte, byte, byte[])}. * * @param error Error to be sent for SET_REPORT via HANDSHAKE. * @return */ - public boolean reportError(byte error) { - Log.v(TAG, "reportError(): error = " + error); + public boolean reportError(BluetoothDevice device, byte error) { + Log.v(TAG, "reportError(): device=" + device + " error=" + error); boolean result = false; if (mService != null) { try { - result = mService.reportError(error); + result = mService.reportError(device, error); } catch (RemoteException e) { Log.e(TAG, e.toString()); } @@ -454,14 +491,14 @@ public final class BluetoothInputHost implements BluetoothProfile { * * @return */ - public boolean unplug() { - Log.v(TAG, "unplug()"); + public boolean unplug(BluetoothDevice device) { + Log.v(TAG, "unplug(): device=" + device); boolean result = false; if (mService != null) { try { - result = mService.unplug(); + result = mService.unplug(device); } catch (RemoteException e) { Log.e(TAG, e.toString()); } @@ -478,14 +515,14 @@ public final class BluetoothInputHost implements BluetoothProfile { * * @return */ - public boolean connect() { - Log.v(TAG, "connect()"); + public boolean connect(BluetoothDevice device) { + Log.v(TAG, "connect(): device=" + device); boolean result = false; if (mService != null) { try { - result = mService.connect(); + result = mService.connect(device); } catch (RemoteException e) { Log.e(TAG, e.toString()); } @@ -501,14 +538,14 @@ public final class BluetoothInputHost implements BluetoothProfile { * * @return */ - public boolean disconnect() { - Log.v(TAG, "disconnect()"); + public boolean disconnect(BluetoothDevice device) { + Log.v(TAG, "disconnect(): device=" + device); boolean result = false; if (mService != null) { try { - result = mService.disconnect(); + result = mService.disconnect(device); } catch (RemoteException e) { Log.e(TAG, e.toString()); } diff --git a/core/java/android/bluetooth/IBluetoothHidDeviceCallback.aidl b/core/java/android/bluetooth/IBluetoothHidDeviceCallback.aidl index 125287696585..a737198ad954 100644 --- a/core/java/android/bluetooth/IBluetoothHidDeviceCallback.aidl +++ b/core/java/android/bluetooth/IBluetoothHidDeviceCallback.aidl @@ -23,9 +23,9 @@ import android.bluetooth.BluetoothHidDeviceAppConfiguration; interface IBluetoothHidDeviceCallback { void onAppStatusChanged(in BluetoothDevice device, in BluetoothHidDeviceAppConfiguration config, boolean registered); void onConnectionStateChanged(in BluetoothDevice device, in int state); - void onGetReport(in byte type, in byte id, in int bufferSize); - void onSetReport(in byte type, in byte id, in byte[] data); - void onSetProtocol(in byte protocol); - void onIntrData(in byte reportId, in byte[] data); - void onVirtualCableUnplug(); + void onGetReport(in BluetoothDevice device, in byte type, in byte id, in int bufferSize); + void onSetReport(in BluetoothDevice device, in byte type, in byte id, in byte[] data); + void onSetProtocol(in BluetoothDevice device, in byte protocol); + void onIntrData(in BluetoothDevice device, in byte reportId, in byte[] data); + void onVirtualCableUnplug(in BluetoothDevice device); } diff --git a/core/java/android/bluetooth/IBluetoothInputHost.aidl b/core/java/android/bluetooth/IBluetoothInputHost.aidl index b2c421c47c58..6c4993f750e6 100644 --- a/core/java/android/bluetooth/IBluetoothInputHost.aidl +++ b/core/java/android/bluetooth/IBluetoothInputHost.aidl @@ -28,10 +28,13 @@ interface IBluetoothInputHost { in BluetoothHidDeviceAppSdpSettings sdp, in BluetoothHidDeviceAppQosSettings inQos, in BluetoothHidDeviceAppQosSettings outQos, in IBluetoothHidDeviceCallback callback); boolean unregisterApp(in BluetoothHidDeviceAppConfiguration config); - boolean sendReport(in int id, in byte[] data); - boolean replyReport(in byte type, in byte id, in byte[] data); - boolean reportError(byte error); - boolean unplug(); - boolean connect(); - boolean disconnect(); + boolean sendReport(in BluetoothDevice device, in int id, in byte[] data); + boolean replyReport(in BluetoothDevice device, in byte type, in byte id, in byte[] data); + boolean reportError(in BluetoothDevice device, byte error); + boolean unplug(in BluetoothDevice device); + boolean connect(in BluetoothDevice device); + boolean disconnect(in BluetoothDevice device); + List<BluetoothDevice> getConnectedDevices(); + List<BluetoothDevice> getDevicesMatchingConnectionStates(in int[] states); + int getConnectionState(in BluetoothDevice device); } |
