1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settingslib.bluetooth;
import android.bluetooth.BluetoothCodecStatus;
import java.util.UUID;
/**
* BluetoothCallback provides a callback interface for the settings
* UI to receive events from {@link BluetoothEventManager}.
*/
public interface BluetoothCallback {
/**
* It will be called when the state of the local Bluetooth adapter has been changed.
* It is listening {@link android.bluetooth.BluetoothAdapter#ACTION_STATE_CHANGED}.
* For example, Bluetooth has been turned on or off.
*
* @param bluetoothState the current Bluetooth state, the possible values are:
* {@link android.bluetooth.BluetoothAdapter#STATE_OFF},
* {@link android.bluetooth.BluetoothAdapter#STATE_TURNING_ON},
* {@link android.bluetooth.BluetoothAdapter#STATE_ON},
* {@link android.bluetooth.BluetoothAdapter#STATE_TURNING_OFF}.
*/
default void onBluetoothStateChanged(int bluetoothState) {}
/**
* It will be called when the local Bluetooth adapter has started
* or finished the remote device discovery process.
* It is listening {@link android.bluetooth.BluetoothAdapter#ACTION_DISCOVERY_STARTED} and
* {@link android.bluetooth.BluetoothAdapter#ACTION_DISCOVERY_FINISHED}.
*
* @param started indicate the current process is started or finished.
*/
default void onScanningStateChanged(boolean started) {}
/**
* It will be called in following situations:
* 1. In scanning mode, when a new device has been found.
* 2. When a profile service is connected and existing connected devices has been found.
* This API only invoked once for each device and all devices will be cached in
* {@link CachedBluetoothDeviceManager}.
*
* @param cachedDevice the Bluetooth device.
*/
default void onDeviceAdded(CachedBluetoothDevice cachedDevice) {}
/**
* It will be called when requiring to remove a remote device from CachedBluetoothDevice list
*
* @param cachedDevice the Bluetooth device.
*/
default void onDeviceDeleted(CachedBluetoothDevice cachedDevice) {}
/**
* It will be called when bond state of a remote device is changed.
* It is listening {@link android.bluetooth.BluetoothDevice#ACTION_BOND_STATE_CHANGED}
*
* @param cachedDevice the Bluetooth device.
* @param bondState the Bluetooth device bond state, the possible values are:
* {@link android.bluetooth.BluetoothDevice#BOND_NONE},
* {@link android.bluetooth.BluetoothDevice#BOND_BONDING},
* {@link android.bluetooth.BluetoothDevice#BOND_BONDED}.
*/
default void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {}
/**
* It will be called in following situations:
* 1. When the adapter is not connected to any profiles of any remote devices
* and it attempts a connection to a profile.
* 2. When the adapter disconnects from the last profile of the last device.
* It is listening {@link android.bluetooth.BluetoothAdapter#ACTION_CONNECTION_STATE_CHANGED}
*
* @param cachedDevice the Bluetooth device.
* @param state the Bluetooth device connection state, the possible values are:
* {@link android.bluetooth.BluetoothAdapter#STATE_DISCONNECTED},
* {@link android.bluetooth.BluetoothAdapter#STATE_CONNECTING},
* {@link android.bluetooth.BluetoothAdapter#STATE_CONNECTED},
* {@link android.bluetooth.BluetoothAdapter#STATE_DISCONNECTING}.
*/
default void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {}
/**
* It will be called when device been set as active for {@code bluetoothProfile}
* It is listening in following intent:
* {@link android.bluetooth.BluetoothA2dp#ACTION_ACTIVE_DEVICE_CHANGED}
* {@link android.bluetooth.BluetoothHeadset#ACTION_ACTIVE_DEVICE_CHANGED}
* {@link android.bluetooth.BluetoothHearingAid#ACTION_ACTIVE_DEVICE_CHANGED}
*
* @param activeDevice the active Bluetooth device.
* @param bluetoothProfile the profile of active Bluetooth device.
*/
default void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile) {}
/**
* It will be called in following situations:
* 1. When the call state on the device is changed.
* 2. When the audio connection state of the A2DP profile is changed.
* It is listening in following intent:
* {@link android.bluetooth.BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED}
* {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED}
*/
default void onAudioModeChanged() {}
/**
* It will be called when one of the bluetooth device profile connection state is changed.
*
* @param cachedDevice the active Bluetooth device.
* @param state the BluetoothProfile connection state, the possible values are:
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTED},
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTING},
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTED},
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING}.
* @param bluetoothProfile the BluetoothProfile id.
*/
default void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice,
int state, int bluetoothProfile) {
}
/**
* Called when ACL connection state is changed. It listens to
* {@link android.bluetooth.BluetoothDevice#ACTION_ACL_CONNECTED} and {@link
* android.bluetooth.BluetoothDevice#ACTION_ACL_DISCONNECTED}
*
* @param cachedDevice Bluetooth device that changed
* @param state the Bluetooth device connection state, the possible values are:
* {@link android.bluetooth.BluetoothAdapter#STATE_DISCONNECTED},
* {@link android.bluetooth.BluetoothAdapter#STATE_CONNECTED}
*/
default void onAclConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {
}
/**
* Called when a2dp codec config is changed. It listens to
* {@link android.bluetooth.BluetoothA2dp#ACTION_CODEC_CONFIG_CHANGED}.
*
* @param cachedDevice Bluetooth device that changed
* @param codecStatus the current codec status of the a2dp profile
*/
default void onA2dpCodecConfigChanged(CachedBluetoothDevice cachedDevice,
BluetoothCodecStatus codecStatus) {
}
/**
* Called when new device group has been identified with the bonded remote device
*
* @param cachedDevice Bluetooth device with which device group has been found.
* @param groupId Identifier of the device group.
* @param setPrimaryServiceUuid Primary service with which this Device Group
* is associated.
*/
default void onNewGroupFound(CachedBluetoothDevice cachedDevice, int groupId,
UUID setPrimaryServiceUuid) {
}
/**
* Called when Group Discovery status has been changed.
*
* @param groupId Identifier of the coordinated set.
* @param status Status of the group discovery procedure.
* @param reason Reason for the change in status of discovery.
*/
default void onGroupDiscoveryStatusChanged (int groupId, int status, int reason) {
}
/**
* Called when Broadcast state is changed. It listens to
* {@link android.bluetooth.BluetoothBroadcast#ACTION_BROADCAST_STATE_CHANGED}
*
* @param state the Bluetooth device connection state, the possible values are:
* {@link android.bluetooth.BluetoothBroadcast#STATE_DISABLED},
* {@link android.bluetooth.BluetoothBroadcast#STATE_ENABLING},
* {@link android.bluetooth.BluetoothBroadcast#STATE_ENABLED},
* {@link android.bluetooth.BluetoothBroadcast#STATE_DISABLING},
* {@link android.bluetooth.BluetoothBroadcast#STATE_STREAMING}
*/
default void onBroadcastStateChanged(int state) {
}
/**
* Called when Broadcast key is changed. It listens to
* {@link android.bluetooth.BluetoothBroadcast#ACTION_BROADCAST_ENCRYPTION_KEY_GENERATED}
*
*/
default void onBroadcastKeyGenerated() {
}
}
|