1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package net.sourceforge.subsonic.androidapp.receiver; |
20 |
|
|
21 |
|
import android.content.BroadcastReceiver; |
22 |
|
import android.content.Context; |
23 |
|
import android.content.Intent; |
24 |
|
import android.util.Log; |
25 |
|
import net.sourceforge.subsonic.androidapp.service.DownloadServiceImpl; |
26 |
|
import net.sourceforge.subsonic.androidapp.util.Util; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@author |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0,3 |
|
33 |
|
public class BluetoothIntentReceiver extends BroadcastReceiver { |
34 |
|
|
35 |
|
private static final String TAG = BluetoothIntentReceiver.class.getSimpleName(); |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0,3 |
|
37 |
0
|
@Override... |
38 |
|
public void onReceive(Context context, Intent intent) { |
39 |
0
|
int state = intent.getIntExtra("android.bluetooth.a2dp.extra.SINK_STATE", -1); |
40 |
0
|
Log.i(TAG, "android.bluetooth.a2dp.extra.SINK_STATE, state = " + state); |
41 |
0
|
boolean connected = state == 2; |
42 |
0
|
if (connected) { |
43 |
0
|
Log.i(TAG, "Connected to Bluetooth A2DP, requesting media button focus."); |
44 |
0
|
Util.registerMediaButtonEventReceiver(context); |
45 |
|
} |
46 |
|
|
47 |
0
|
boolean disconnected = state == 0; |
48 |
0
|
if (disconnected) { |
49 |
0
|
Log.i(TAG, "Disconnected from Bluetooth A2DP, requesting pause."); |
50 |
0
|
context.sendBroadcast(new Intent(DownloadServiceImpl.CMD_PAUSE)); |
51 |
|
} |
52 |
|
} |
53 |
|
} |