Clover Coverage Report - Subsonic-Android Coverage Report
Coverage timestamp: ven dic 19 2014 17:57:13 EST
../../../../../img/srcFileCovDistChart0.png 86% of files have more coverage
10   53   3   10
4   24   0,3   1
1     3  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  BluetoothIntentReceiver       Line # 33 10 3 0% 0.0
 
No Tests
 
1    /*
2    This file is part of Subsonic.
3   
4    Subsonic is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8   
9    Subsonic is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12    GNU General Public License for more details.
13   
14    You should have received a copy of the GNU General Public License
15    along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
16   
17    Copyright 2010 (C) Sindre Mehus
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    * Request media button focus when connected to Bluetooth A2DP.
30    *
31    * @author Sindre Mehus
32    */
 
33    public class BluetoothIntentReceiver extends BroadcastReceiver {
34   
35    private static final String TAG = BluetoothIntentReceiver.class.getSimpleName();
36   
 
37  0 toggle @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; // android.bluetooth.BluetoothA2dp.STATE_CONNECTED
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; // android.bluetooth.BluetoothA2dp.STATE_DISCONNECTED
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    }