Reworked a few logs

This commit is contained in:
Sylvain Berfini 2016-08-02 17:19:17 +02:00
parent e11780075a
commit c4e9fc742b
2 changed files with 27 additions and 27 deletions

View file

@ -67,14 +67,14 @@ public class BluetoothManager extends BroadcastReceiver {
public BluetoothManager() { public BluetoothManager() {
isBluetoothConnected = false; isBluetoothConnected = false;
if (!ensureInit()) { if (!ensureInit()) {
Log.w("BluetoothManager tried to init but LinphoneService not ready yet..."); Log.w("[Bluetooth] Manager tried to init but LinphoneService not ready yet...");
} }
instance = this; instance = this;
} }
public void initBluetooth() { public void initBluetooth() {
if (!ensureInit()) { if (!ensureInit()) {
Log.w("BluetoothManager tried to init bluetooth but LinphoneService not ready yet..."); Log.w("[Bluetooth] Manager tried to init bluetooth but LinphoneService not ready yet...");
return; return;
} }
@ -84,14 +84,14 @@ public class BluetoothManager extends BroadcastReceiver {
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
filter.addAction(BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT); filter.addAction(BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT);
mContext.registerReceiver(this, filter); mContext.registerReceiver(this, filter);
Log.d("Bluetooth receiver started"); Log.d("[Bluetooth] Receiver started");
startBluetooth(); startBluetooth();
} }
private void startBluetooth() { private void startBluetooth() {
if (isBluetoothConnected) { if (isBluetoothConnected) {
Log.e("Bluetooth already started"); Log.e("[Bluetooth] Already started, skipping...");
return; return;
} }
@ -99,14 +99,14 @@ public class BluetoothManager extends BroadcastReceiver {
if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) { if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
if (mProfileListener != null) { if (mProfileListener != null) {
Log.w("Bluetooth headset profile was already opened, let's close it"); Log.w("[Bluetooth] Headset profile was already opened, let's close it");
mBluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset); mBluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
} }
mProfileListener = new BluetoothProfile.ServiceListener() { mProfileListener = new BluetoothProfile.ServiceListener() {
public void onServiceConnected(int profile, BluetoothProfile proxy) { public void onServiceConnected(int profile, BluetoothProfile proxy) {
if (profile == BluetoothProfile.HEADSET) { if (profile == BluetoothProfile.HEADSET) {
Log.d("Bluetooth headset connected"); Log.d("[Bluetooth] Headset connected");
mBluetoothHeadset = (BluetoothHeadset) proxy; mBluetoothHeadset = (BluetoothHeadset) proxy;
isBluetoothConnected = true; isBluetoothConnected = true;
} }
@ -115,17 +115,17 @@ public class BluetoothManager extends BroadcastReceiver {
if (profile == BluetoothProfile.HEADSET) { if (profile == BluetoothProfile.HEADSET) {
mBluetoothHeadset = null; mBluetoothHeadset = null;
isBluetoothConnected = false; isBluetoothConnected = false;
Log.d("Bluetooth headset disconnected"); Log.d("[Bluetooth] Headset disconnected");
LinphoneManager.getInstance().routeAudioToReceiver(); LinphoneManager.getInstance().routeAudioToReceiver();
} }
} }
}; };
boolean success = mBluetoothAdapter.getProfileProxy(mContext, mProfileListener, BluetoothProfile.HEADSET); boolean success = mBluetoothAdapter.getProfileProxy(mContext, mProfileListener, BluetoothProfile.HEADSET);
if (!success) { if (!success) {
Log.e("Bluetooth getProfileProxy failed !"); Log.e("[Bluetooth] getProfileProxy failed !");
} }
} else { } else {
Log.w("Bluetooth interface disabled on device"); Log.w("[Bluetooth] Interface disabled on device");
} }
} }
@ -152,7 +152,7 @@ public class BluetoothManager extends BroadcastReceiver {
if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled() && mAudioManager != null && mAudioManager.isBluetoothScoAvailableOffCall()) { if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled() && mAudioManager != null && mAudioManager.isBluetoothScoAvailableOffCall()) {
if (isBluetoothHeadsetAvailable()) { if (isBluetoothHeadsetAvailable()) {
if (mAudioManager != null && !mAudioManager.isBluetoothScoOn()) { if (mAudioManager != null && !mAudioManager.isBluetoothScoOn()) {
Log.d("Bluetooth sco off, let's start it"); Log.d("[Bluetooth] SCO off, let's start it");
mAudioManager.setBluetoothScoOn(true); mAudioManager.setBluetoothScoOn(true);
mAudioManager.startBluetoothSco(); mAudioManager.startBluetoothSco();
} }
@ -179,12 +179,12 @@ public class BluetoothManager extends BroadcastReceiver {
} }
if (ok) { if (ok) {
if (retries > 0) { if (retries > 0) {
Log.d("Bluetooth route ok after " + retries + " retries"); Log.d("[Bluetooth] Audio route ok after " + retries + " retries");
} else { } else {
Log.d("Bluetooth route ok"); Log.d("[Bluetooth] Audio route ok");
} }
} else { } else {
Log.d("Bluetooth still not ok..."); Log.d("[Bluetooth] Audio route still not ok...");
} }
return ok; return ok;
@ -211,7 +211,7 @@ public class BluetoothManager extends BroadcastReceiver {
break; break;
} }
} }
Log.d(isHeadsetConnected ? "Headset found, bluetooth audio route available" : "No headset found, bluetooth audio route unavailable"); Log.d(isHeadsetConnected ? "[Bluetooth] Headset found, bluetooth audio route available" : "[Bluetooth] No headset found, bluetooth audio route unavailable");
} }
return isHeadsetConnected; return isHeadsetConnected;
} }
@ -236,12 +236,12 @@ public class BluetoothManager extends BroadcastReceiver {
mAudioManager.stopBluetoothSco(); mAudioManager.stopBluetoothSco();
mAudioManager.setBluetoothScoOn(false); mAudioManager.setBluetoothScoOn(false);
} }
Log.w("Bluetooth sco disconnected!"); Log.w("[Bluetooth] SCO disconnected!");
} }
} }
public void stopBluetooth() { public void stopBluetooth() {
Log.w("Stopping bluetooth..."); Log.w("[Bluetooth] Stopping...");
isBluetoothConnected = false; isBluetoothConnected = false;
disableBluetoothSCO(); disableBluetoothSCO();
@ -252,7 +252,7 @@ public class BluetoothManager extends BroadcastReceiver {
} }
mBluetoothDevice = null; mBluetoothDevice = null;
Log.w("Bluetooth stopped!"); Log.w("[Bluetooth] Stopped!");
if (LinphoneManager.isInstanciated()) { if (LinphoneManager.isInstanciated()) {
LinphoneManager.getInstance().routeAudioToReceiver(); LinphoneManager.getInstance().routeAudioToReceiver();
@ -265,7 +265,7 @@ public class BluetoothManager extends BroadcastReceiver {
try { try {
mContext.unregisterReceiver(this); mContext.unregisterReceiver(this);
Log.d("Bluetooth receiver stopped"); Log.d("[Bluetooth] Receiver stopped");
} catch (Exception e) {} } catch (Exception e) {}
} catch (Exception e) { } catch (Exception e) {
Log.e(e); Log.e(e);
@ -280,27 +280,27 @@ public class BluetoothManager extends BroadcastReceiver {
if (AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED.equals(action)) { if (AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED.equals(action)) {
int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, 0); int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, 0);
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) { if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
Log.d("Bluetooth sco state => connected"); Log.d("[Bluetooth] SCO state: connected");
// LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH); // LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH);
isScoConnected = true; isScoConnected = true;
} else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) { } else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
Log.d("Bluetooth sco state => disconnected"); Log.d("[Bluetooth] SCO state: disconnected");
// LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER); // LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER);
isScoConnected = false; isScoConnected = false;
} else { } else {
Log.d("Bluetooth sco state => " + state); Log.d("[Bluetooth] SCO state: " + state);
} }
} }
else if (BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED.equals(action)) { else if (BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED.equals(action)) {
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED); int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, BluetoothAdapter.STATE_DISCONNECTED);
if (state == 0) { if (state == 0) {
Log.d("Bluetooth state => disconnected"); Log.d("[Bluetooth] State: disconnected");
stopBluetooth(); stopBluetooth();
} else if (state == 2) { } else if (state == 2) {
Log.d("Bluetooth state => connected"); Log.d("[Bluetooth] State: connected");
startBluetooth(); startBluetooth();
} else { } else {
Log.d("Bluetooth state => " + state); Log.d("[Bluetooth] State: " + state);
} }
} }
else if (intent.getAction().equals(BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT)) { else if (intent.getAction().equals(BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT)) {
@ -313,7 +313,7 @@ public class BluetoothManager extends BroadcastReceiver {
if (eventName.equals("BUTTON") && args.length >= 3) { if (eventName.equals("BUTTON") && args.length >= 3) {
Integer buttonID = (Integer) args[1]; Integer buttonID = (Integer) args[1];
Integer mode = (Integer) args[2]; Integer mode = (Integer) args[2];
Log.d("Bluetooth event: " + command + " : " + eventName + ", id = " + buttonID + " (" + mode + ")"); Log.d("[Bluetooth] Event: " + command + " : " + eventName + ", id = " + buttonID + " (" + mode + ")");
} }
} }
} }

View file

@ -1048,10 +1048,10 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
public void setAudioManagerInCallMode() { public void setAudioManagerInCallMode() {
if (mAudioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION) { if (mAudioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION) {
Log.w("---AudioManager: already in MODE_IN_COMMUNICATION, skipping..."); Log.w("[AudioManager] already in MODE_IN_COMMUNICATION, skipping...");
return; return;
} }
Log.d("---AudioManager: set mode to MODE_IN_COMMUNICATION"); Log.d("[AudioManager] Mode: MODE_IN_COMMUNICATION");
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
} }