Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 570ac351 authored by Ivan Podogov's avatar Ivan Podogov Committed by Gerrit Code Review
Browse files

Merge "HID Device role API fixes"

parents 9ac35f73 b2320848
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -46,8 +46,8 @@ public abstract class BluetoothHidDeviceCallback {
     */
    public void onAppStatusChanged(BluetoothDevice pluggedDevice,
            BluetoothHidDeviceAppConfiguration config, boolean registered) {
        Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + (pluggedDevice == null ?
            null : pluggedDevice.toString()) + " registered=" + 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);
    }
}
+74 −37
Original line number Diff line number Diff line
@@ -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");
        }

    @Override
        return new ArrayList<BluetoothDevice>();
    }

    /**
     * {@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");
        }

    @Override
        return new ArrayList<BluetoothDevice>();
    }

    /**
     * {@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());
            }
+5 −5
Original line number Diff line number Diff line
@@ -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);
}
+9 −6
Original line number Diff line number Diff line
@@ -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);
}