blob: f519776276fcbdc7160f3ed7ca710805339bc546 [file] [log] [blame]
Hemant Guptae88fd4b2014-04-18 11:22:45 +05301/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.bluetooth;
18
19import android.util.Log;
20
21/** @hide */
22public abstract class BluetoothHidDeviceCallback {
23
24 private static final String TAG = BluetoothHidDeviceCallback.class.getSimpleName();
25
26 /**
27 * Callback called when application registration state changes. Usually it's
28 * called due to either
29 * {@link BluetoothHidDevice#registerApp(String, String, String, byte, byte[],
30 * BluetoothHidDeviceCallback)}
31 * or
32 * {@link BluetoothHidDevice#unregisterApp(BluetoothHidDeviceAppConfiguration)}
33 * , but can be also unsolicited in case e.g. Bluetooth was turned off in
34 * which case application is unregistered automatically.
35 *
36 * @param pluggedDevice {@link BluetoothDevice} object which represents host
37 * that currently has Virtual Cable established with device. Only
38 * valid when application is registered, can be <code>null</code>
39 * .
40 * @param config {@link BluetoothHidDeviceAppConfiguration} object which
41 * represents token required to unregister application using
42 * {@link BluetoothHidDevice#unregisterApp(BluetoothHidDeviceAppConfiguration)}
43 * .
44 * @param registered <code>true</code> if application is registered,
45 * <code>false</code> otherwise.
46 */
47 public void onAppStatusChanged(BluetoothDevice pluggedDevice,
Ivan Podogovdd87cd32016-12-30 14:43:29 +000048 BluetoothHidDeviceAppConfiguration config, boolean registered) {
49 Log.d(TAG, "onAppStatusChanged: pluggedDevice=" + pluggedDevice + " registered="
50 + registered);
Hemant Guptae88fd4b2014-04-18 11:22:45 +053051 }
52
53 /**
54 * Callback called when connection state with remote host was changed.
55 * Application can assume than Virtual Cable is established when called with
56 * {@link BluetoothProfile#STATE_CONNECTED} <code>state</code>.
57 *
58 * @param device {@link BluetoothDevice} object representing host device
59 * which connection state was changed.
60 * @param state Connection state as defined in {@link BluetoothProfile}.
61 */
62 public void onConnectionStateChanged(BluetoothDevice device, int state) {
Ivan Podogovdd87cd32016-12-30 14:43:29 +000063 Log.d(TAG, "onConnectionStateChanged: device=" + device + " state=" + state);
Hemant Guptae88fd4b2014-04-18 11:22:45 +053064 }
65
66 /**
67 * Callback called when GET_REPORT is received from remote host. Should be
68 * replied by application using
Ivan Podogovdd87cd32016-12-30 14:43:29 +000069 * {@link BluetoothHidDevice#replyReport(BluetoothDevice, byte, byte, byte[])}.
Hemant Guptae88fd4b2014-04-18 11:22:45 +053070 *
71 * @param type Requested Report Type.
72 * @param id Requested Report Id, can be 0 if no Report Id are defined in
73 * descriptor.
74 * @param bufferSize Requested buffer size, application shall respond with
75 * at least given number of bytes.
76 */
Ivan Podogovdd87cd32016-12-30 14:43:29 +000077 public void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize) {
78 Log.d(TAG, "onGetReport: device=" + device + " type=" + type + " id=" + id + " bufferSize="
79 + bufferSize);
Hemant Guptae88fd4b2014-04-18 11:22:45 +053080 }
81
82 /**
83 * Callback called when SET_REPORT is received from remote host. In case
84 * received data are invalid, application shall respond with
Ivan Podogovdd87cd32016-12-30 14:43:29 +000085 * {@link BluetoothHidDevice#reportError(BluetoothDevice)}.
Hemant Guptae88fd4b2014-04-18 11:22:45 +053086 *
87 * @param type Report Type.
88 * @param id Report Id.
89 * @param data Report data.
90 */
Ivan Podogovdd87cd32016-12-30 14:43:29 +000091 public void onSetReport(BluetoothDevice device, byte type, byte id, byte[] data) {
92 Log.d(TAG, "onSetReport: device=" + device + " type=" + type + " id=" + id);
Hemant Guptae88fd4b2014-04-18 11:22:45 +053093 }
94
95 /**
96 * Callback called when SET_PROTOCOL is received from remote host.
97 * Application shall use this information to send only reports valid for
98 * given protocol mode. By default,
99 * {@link BluetoothHidDevice#PROTOCOL_REPORT_MODE} shall be assumed.
100 *
101 * @param protocol Protocol Mode.
102 */
Ivan Podogovdd87cd32016-12-30 14:43:29 +0000103 public void onSetProtocol(BluetoothDevice device, byte protocol) {
104 Log.d(TAG, "onSetProtocol: device=" + device + " protocol=" + protocol);
Hemant Guptae88fd4b2014-04-18 11:22:45 +0530105 }
106
107 /**
108 * Callback called when report data is received over interrupt channel.
109 * Report Type is assumed to be
110 * {@link BluetoothHidDevice#REPORT_TYPE_OUTPUT}.
111 *
112 * @param reportId Report Id.
113 * @param data Report data.
114 */
Ivan Podogovdd87cd32016-12-30 14:43:29 +0000115 public void onIntrData(BluetoothDevice device, byte reportId, byte[] data) {
116 Log.d(TAG, "onIntrData: device=" + device + " reportId=" + reportId);
Hemant Guptae88fd4b2014-04-18 11:22:45 +0530117 }
118
119 /**
120 * Callback called when Virtual Cable is removed. This can be either due to
Ivan Podogovdd87cd32016-12-30 14:43:29 +0000121 * {@link BluetoothHidDevice#unplug(BluetoothDevice)} or request from remote
122 * side. After this callback is received connection will be disconnected
123 * automatically.
Hemant Guptae88fd4b2014-04-18 11:22:45 +0530124 */
Ivan Podogovdd87cd32016-12-30 14:43:29 +0000125 public void onVirtualCableUnplug(BluetoothDevice device) {
126 Log.d(TAG, "onVirtualCableUnplug: device=" + device);
Hemant Guptae88fd4b2014-04-18 11:22:45 +0530127 }
128}