Merge "HID Device role API fixes"
This commit is contained in:
@@ -45,9 +45,9 @@ public abstract class BluetoothHidDeviceCallback {
|
|||||||
* <code>false</code> otherwise.
|
* <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
public void onAppStatusChanged(BluetoothDevice pluggedDevice,
|
public void onAppStatusChanged(BluetoothDevice pluggedDevice,
|
||||||
BluetoothHidDeviceAppConfiguration config, boolean registered) {
|
BluetoothHidDeviceAppConfiguration config, boolean registered) {
|
||||||
Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + (pluggedDevice == null ?
|
Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + pluggedDevice + " registered="
|
||||||
null : pluggedDevice.toString()) + " registered=" + registered);
|
+ registered);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,13 +60,13 @@ public abstract class BluetoothHidDeviceCallback {
|
|||||||
* @param state Connection state as defined in {@link BluetoothProfile}.
|
* @param state Connection state as defined in {@link BluetoothProfile}.
|
||||||
*/
|
*/
|
||||||
public void onConnectionStateChanged(BluetoothDevice device, int state) {
|
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
|
* Callback called when GET_REPORT is received from remote host. Should be
|
||||||
* replied by application using
|
* replied by application using
|
||||||
* {@link BluetoothHidDevice#replyReport(byte, byte, byte[])}.
|
* {@link BluetoothHidDevice#replyReport(BluetoothDevice, byte, byte, byte[])}.
|
||||||
*
|
*
|
||||||
* @param type Requested Report Type.
|
* @param type Requested Report Type.
|
||||||
* @param id Requested Report Id, can be 0 if no Report Id are defined in
|
* @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
|
* @param bufferSize Requested buffer size, application shall respond with
|
||||||
* at least given number of bytes.
|
* at least given number of bytes.
|
||||||
*/
|
*/
|
||||||
public void onGetReport(byte type, byte id, int bufferSize) {
|
public void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize) {
|
||||||
Log.d(TAG, "onGetReport: type=" + type + " id=" + id + " bufferSize=" + 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
|
* Callback called when SET_REPORT is received from remote host. In case
|
||||||
* received data are invalid, application shall respond with
|
* received data are invalid, application shall respond with
|
||||||
* {@link BluetoothHidDevice#reportError()}.
|
* {@link BluetoothHidDevice#reportError(BluetoothDevice)}.
|
||||||
*
|
*
|
||||||
* @param type Report Type.
|
* @param type Report Type.
|
||||||
* @param id Report Id.
|
* @param id Report Id.
|
||||||
* @param data Report data.
|
* @param data Report data.
|
||||||
*/
|
*/
|
||||||
public void onSetReport(byte type, byte id, byte[] data) {
|
public void onSetReport(BluetoothDevice device, byte type, byte id, byte[] data) {
|
||||||
Log.d(TAG, "onSetReport: type=" + type + " id=" + id);
|
Log.d(TAG, "onSetReport: device=" + device + " type=" + type + " id=" + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,8 +100,8 @@ public abstract class BluetoothHidDeviceCallback {
|
|||||||
*
|
*
|
||||||
* @param protocol Protocol Mode.
|
* @param protocol Protocol Mode.
|
||||||
*/
|
*/
|
||||||
public void onSetProtocol(byte protocol) {
|
public void onSetProtocol(BluetoothDevice device, byte protocol) {
|
||||||
Log.d(TAG, "onSetProtocol: protocol=" + protocol);
|
Log.d(TAG, "onSetProtocol: device=" + device + " protocol=" + protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,16 +112,17 @@ public abstract class BluetoothHidDeviceCallback {
|
|||||||
* @param reportId Report Id.
|
* @param reportId Report Id.
|
||||||
* @param data Report data.
|
* @param data Report data.
|
||||||
*/
|
*/
|
||||||
public void onIntrData(byte reportId, byte[] data) {
|
public void onIntrData(BluetoothDevice device, byte reportId, byte[] data) {
|
||||||
Log.d(TAG, "onIntrData: reportId=" + reportId);
|
Log.d(TAG, "onIntrData: device=" + device + " reportId=" + reportId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback called when Virtual Cable is removed. This can be either due to
|
* Callback called when Virtual Cable is removed. This can be either due to
|
||||||
* {@link BluetoothHidDevice#unplug()} or request from remote side. After
|
* {@link BluetoothHidDevice#unplug(BluetoothDevice)} or request from remote
|
||||||
* this callback is received connection will be disconnected automatically.
|
* side. After this callback is received connection will be disconnected
|
||||||
|
* automatically.
|
||||||
*/
|
*/
|
||||||
public void onVirtualCableUnplug() {
|
public void onVirtualCableUnplug(BluetoothDevice device) {
|
||||||
Log.d(TAG, "onVirtualCableUnplug");
|
Log.d(TAG, "onVirtualCableUnplug: device=" + device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.os.RemoteException;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,28 +138,28 @@ public final class BluetoothInputHost implements BluetoothProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGetReport(byte type, byte id, int bufferSize) {
|
public void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize) {
|
||||||
mCallback.onGetReport(type, id, bufferSize);
|
mCallback.onGetReport(device, type, id, bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetReport(byte type, byte id, byte[] data) {
|
public void onSetReport(BluetoothDevice device, byte type, byte id, byte[] data) {
|
||||||
mCallback.onSetReport(type, id, data);
|
mCallback.onSetReport(device, type, id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetProtocol(byte protocol) {
|
public void onSetProtocol(BluetoothDevice device, byte protocol) {
|
||||||
mCallback.onSetProtocol(protocol);
|
mCallback.onSetProtocol(device, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIntrData(byte reportId, byte[] data) {
|
public void onIntrData(BluetoothDevice device, byte reportId, byte[] data) {
|
||||||
mCallback.onIntrData(reportId, data);
|
mCallback.onIntrData(device, reportId, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onVirtualCableUnplug() {
|
public void onVirtualCableUnplug(BluetoothDevice device) {
|
||||||
mCallback.onVirtualCableUnplug();
|
mCallback.onVirtualCableUnplug(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,21 +277,59 @@ public final class BluetoothInputHost implements BluetoothProfile {
|
|||||||
mServiceListener = null;
|
mServiceListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public List<BluetoothDevice> getConnectedDevices() {
|
public List<BluetoothDevice> getConnectedDevices() {
|
||||||
Log.v(TAG, "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) {
|
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
|
||||||
Log.v(TAG, "getDevicesMatchingConnectionStates(): states=" + Arrays.toString(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) {
|
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;
|
return STATE_DISCONNECTED;
|
||||||
}
|
}
|
||||||
@@ -379,14 +418,12 @@ public final class BluetoothInputHost implements BluetoothProfile {
|
|||||||
* @param data Report data, not including Report Id.
|
* @param data Report data, not including Report Id.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean sendReport(int id, byte[] data) {
|
public boolean sendReport(BluetoothDevice device, int id, byte[] data) {
|
||||||
Log.v(TAG, "sendReport(): id=" + id);
|
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
result = mService.sendReport(id, data);
|
result = mService.sendReport(device, id, data);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, e.toString());
|
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
|
* 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 type Report Type, as in request.
|
||||||
* @param id Report Id, as in request.
|
* @param id Report Id, as in request.
|
||||||
* @param data Report data, not including Report Id.
|
* @param data Report data, not including Report Id.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean replyReport(byte type, byte id, byte[] data) {
|
public boolean replyReport(BluetoothDevice device, byte type, byte id, byte[] data) {
|
||||||
Log.v(TAG, "replyReport(): type=" + type + " id=" + id);
|
Log.v(TAG, "replyReport(): device=" + device + " type=" + type + " id=" + id);
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
result = mService.replyReport(type, id, data);
|
result = mService.replyReport(device, type, id, data);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, e.toString());
|
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
|
* 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.
|
* @param error Error to be sent for SET_REPORT via HANDSHAKE.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean reportError(byte error) {
|
public boolean reportError(BluetoothDevice device, byte error) {
|
||||||
Log.v(TAG, "reportError(): error = " + error);
|
Log.v(TAG, "reportError(): device=" + device + " error=" + error);
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
result = mService.reportError(error);
|
result = mService.reportError(device, error);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
}
|
}
|
||||||
@@ -454,14 +491,14 @@ public final class BluetoothInputHost implements BluetoothProfile {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean unplug() {
|
public boolean unplug(BluetoothDevice device) {
|
||||||
Log.v(TAG, "unplug()");
|
Log.v(TAG, "unplug(): device=" + device);
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
result = mService.unplug();
|
result = mService.unplug(device);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
}
|
}
|
||||||
@@ -478,14 +515,14 @@ public final class BluetoothInputHost implements BluetoothProfile {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean connect() {
|
public boolean connect(BluetoothDevice device) {
|
||||||
Log.v(TAG, "connect()");
|
Log.v(TAG, "connect(): device=" + device);
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
result = mService.connect();
|
result = mService.connect(device);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
}
|
}
|
||||||
@@ -501,14 +538,14 @@ public final class BluetoothInputHost implements BluetoothProfile {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean disconnect() {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
Log.v(TAG, "disconnect()");
|
Log.v(TAG, "disconnect(): device=" + device);
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
result = mService.disconnect();
|
result = mService.disconnect(device);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, e.toString());
|
Log.e(TAG, e.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import android.bluetooth.BluetoothHidDeviceAppConfiguration;
|
|||||||
interface IBluetoothHidDeviceCallback {
|
interface IBluetoothHidDeviceCallback {
|
||||||
void onAppStatusChanged(in BluetoothDevice device, in BluetoothHidDeviceAppConfiguration config, boolean registered);
|
void onAppStatusChanged(in BluetoothDevice device, in BluetoothHidDeviceAppConfiguration config, boolean registered);
|
||||||
void onConnectionStateChanged(in BluetoothDevice device, in int state);
|
void onConnectionStateChanged(in BluetoothDevice device, in int state);
|
||||||
void onGetReport(in byte type, in byte id, in int bufferSize);
|
void onGetReport(in BluetoothDevice device, in byte type, in byte id, in int bufferSize);
|
||||||
void onSetReport(in byte type, in byte id, in byte[] data);
|
void onSetReport(in BluetoothDevice device, in byte type, in byte id, in byte[] data);
|
||||||
void onSetProtocol(in byte protocol);
|
void onSetProtocol(in BluetoothDevice device, in byte protocol);
|
||||||
void onIntrData(in byte reportId, in byte[] data);
|
void onIntrData(in BluetoothDevice device, in byte reportId, in byte[] data);
|
||||||
void onVirtualCableUnplug();
|
void onVirtualCableUnplug(in BluetoothDevice device);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,13 @@ interface IBluetoothInputHost {
|
|||||||
in BluetoothHidDeviceAppSdpSettings sdp, in BluetoothHidDeviceAppQosSettings inQos,
|
in BluetoothHidDeviceAppSdpSettings sdp, in BluetoothHidDeviceAppQosSettings inQos,
|
||||||
in BluetoothHidDeviceAppQosSettings outQos, in IBluetoothHidDeviceCallback callback);
|
in BluetoothHidDeviceAppQosSettings outQos, in IBluetoothHidDeviceCallback callback);
|
||||||
boolean unregisterApp(in BluetoothHidDeviceAppConfiguration config);
|
boolean unregisterApp(in BluetoothHidDeviceAppConfiguration config);
|
||||||
boolean sendReport(in int id, in byte[] data);
|
boolean sendReport(in BluetoothDevice device, in int id, in byte[] data);
|
||||||
boolean replyReport(in byte type, in byte id, in byte[] data);
|
boolean replyReport(in BluetoothDevice device, in byte type, in byte id, in byte[] data);
|
||||||
boolean reportError(byte error);
|
boolean reportError(in BluetoothDevice device, byte error);
|
||||||
boolean unplug();
|
boolean unplug(in BluetoothDevice device);
|
||||||
boolean connect();
|
boolean connect(in BluetoothDevice device);
|
||||||
boolean disconnect();
|
boolean disconnect(in BluetoothDevice device);
|
||||||
|
List<BluetoothDevice> getConnectedDevices();
|
||||||
|
List<BluetoothDevice> getDevicesMatchingConnectionStates(in int[] states);
|
||||||
|
int getConnectionState(in BluetoothDevice device);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user