diff options
author | Steve Kondik <steve@cyngn.com> | 2016-10-13 20:21:41 -0700 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2016-12-30 16:49:00 +0200 |
commit | c3175f10f122a382ffb1c01f6b816e2f8704a097 (patch) | |
tree | 638ab81c8a3084139da477498f7b3bf6dff81946 /src/com | |
parent | 519af800ca46a9cc557f78749f73a7cb9ca66781 (diff) | |
download | android_packages_apps_Bluetooth-c3175f10f122a382ffb1c01f6b816e2f8704a097.tar.gz android_packages_apps_Bluetooth-c3175f10f122a382ffb1c01f6b816e2f8704a097.tar.bz2 android_packages_apps_Bluetooth-c3175f10f122a382ffb1c01f6b816e2f8704a097.zip |
Kill logspam during battery level events
Change-Id: I7c0f5b1fee68392414aa4b4b2cca80bc15631565
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/bluetooth/hfp/HeadsetPhoneState.java | 28 | ||||
-rwxr-xr-x | src/com/android/bluetooth/hfp/HeadsetStateMachine.java | 626 |
2 files changed, 328 insertions, 326 deletions
diff --git a/src/com/android/bluetooth/hfp/HeadsetPhoneState.java b/src/com/android/bluetooth/hfp/HeadsetPhoneState.java index 80d10c75e..21e5286f4 100644 --- a/src/com/android/bluetooth/hfp/HeadsetPhoneState.java +++ b/src/com/android/bluetooth/hfp/HeadsetPhoneState.java @@ -34,6 +34,8 @@ import android.bluetooth.BluetoothDevice; class HeadsetPhoneState { private static final String TAG = "HeadsetPhoneState"; + private static final boolean DEBUG = Log.isLoggable(TAG, Log.VERBOSE); + private HeadsetStateMachine mStateMachine; private TelephonyManager mTelephonyManager; private ServiceState mServiceState; @@ -98,7 +100,7 @@ class HeadsetPhoneState { mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); mContext = context; - Log.d(TAG, "HeadsetPhoneState"); + if (DEBUG) Log.d(TAG, "HeadsetPhoneState"); // Register for SubscriptionInfo list changes which is guaranteed // to invoke onSubscriptionInfoChanged and which in turns calls // loadInBackgroud. @@ -107,7 +109,7 @@ class HeadsetPhoneState { } public void cleanup() { - Log.d(TAG, "cleanup"); + if (DEBUG) Log.d(TAG, "cleanup"); listenForPhoneState(false); mSubMgr.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener); @@ -118,20 +120,20 @@ class HeadsetPhoneState { void listenForPhoneState(boolean start) { mSlcReady = start; - Log.d(TAG, "Enter listenForPhoneState"); + if (DEBUG) Log.d(TAG, "Enter listenForPhoneState"); if (start) { startListenForPhoneState(); } else { stopListenForPhoneState(); } - Log.d(TAG, "Exit listenForPhoneState"); + if (DEBUG) Log.d(TAG, "Exit listenForPhoneState"); } private void startListenForPhoneState() { if (!mListening && mSlcReady && mTelephonyManager != null) { - Log.d(TAG, "Enter startListenForPhoneState"); + if (DEBUG) Log.d(TAG, "Enter startListenForPhoneState"); int subId = SubscriptionManager.getDefaultSubscriptionId(); @@ -151,12 +153,12 @@ class HeadsetPhoneState { } } - Log.d(TAG, "Exit startListenForPhoneState"); + if (DEBUG) Log.d(TAG, "Exit startListenForPhoneState"); } private void stopListenForPhoneState() { if (mListening && mTelephonyManager != null) { - Log.d(TAG, "Enter stopListenForPhoneState"); + if (DEBUG) Log.d(TAG, "Enter stopListenForPhoneState"); try { mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); } catch (NullPointerException npe) { @@ -166,7 +168,7 @@ class HeadsetPhoneState { } mListening = false; } - Log.d(TAG, "Exit stopListenForPhoneState"); + if (DEBUG) Log.d(TAG, "Exit stopListenForPhoneState"); } int getService() { @@ -274,7 +276,7 @@ class HeadsetPhoneState { // use the service indicator, but only the signal indicator int signal = mService == HeadsetHalConstants.NETWORK_STATE_AVAILABLE ? mSignal : 0; - Log.d(TAG, "sendDeviceStateChanged. mService="+ mService + + if (DEBUG) Log.d(TAG, "sendDeviceStateChanged. mService="+ mService + " mSignal=" + signal +" mRoam="+ mRoam + " mBatteryCharge=" + mBatteryCharge); HeadsetStateMachine sm = mStateMachine; @@ -288,7 +290,7 @@ class HeadsetPhoneState { PhoneStateListener mPhoneStateListener = new PhoneStateListener(subId) { @Override public void onServiceStateChanged(ServiceState serviceState) { - Log.d(TAG, "Enter onServiceStateChanged"); + if (DEBUG) Log.d(TAG, "Enter onServiceStateChanged"); mServiceState = serviceState; mService = (serviceState.getState() == ServiceState.STATE_IN_SERVICE) ? @@ -298,14 +300,14 @@ class HeadsetPhoneState { : HeadsetHalConstants.SERVICE_TYPE_HOME); sendDeviceStateChanged(); - Log.d(TAG, "Exit onServiceStateChanged"); + if (DEBUG) Log.d(TAG, "Exit onServiceStateChanged"); } @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { int prevSignal = mSignal; - Log.d(TAG, "Enter onSignalStrengthsChanged"); + if (DEBUG) Log.d(TAG, "Enter onSignalStrengthsChanged"); if (mService == HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE) { mSignal = 0; } else if (signalStrength.isGsm()) { @@ -327,7 +329,7 @@ class HeadsetPhoneState { if (prevSignal != mSignal) { sendDeviceStateChanged(); } - Log.d(TAG, "Exit onSignalStrengthsChanged"); + if (DEBUG) Log.d(TAG, "Exit onSignalStrengthsChanged"); } /* convert [0,31] ASU signal strength to the [0,5] expected by diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index 0f659ef21..091ad71fa 100755 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -272,7 +272,7 @@ final class HeadsetStateMachine extends StateMachine { int max_hfp_clients = SystemProperties.getInt("persist.bt.max.hs.connections", 1); if (max_hfp_clients >= 2) max_hf_connections = 2; - Log.d(TAG, "max_hf_connections = " + max_hf_connections); + if (DBG) if (DBG) Log.d(TAG, "max_hf_connections = " + max_hf_connections); initializeNative(max_hf_connections); mNativeAvailable=true; @@ -301,7 +301,7 @@ final class HeadsetStateMachine extends StateMachine { } static HeadsetStateMachine make(HeadsetService context) { - Log.d(TAG, "make"); + if (DBG) if (DBG) Log.d(TAG, "make"); HeadsetStateMachine hssm = new HeadsetStateMachine(context); hssm.start(); return hssm; @@ -309,7 +309,7 @@ final class HeadsetStateMachine extends StateMachine { public void doQuit() { - Log.d(TAG, "Enter doQuit()"); + if (DBG) if (DBG) Log.d(TAG, "Enter doQuit()"); int size = 0; if (mAudioManager != null) { mAudioManager.setBluetoothScoOn(false); @@ -323,23 +323,23 @@ final class HeadsetStateMachine extends StateMachine { } /* Broadcast disconnected state for connected devices.*/ size = mConnectedDevicesList.size(); - Log.d(TAG, "cleanup: mConnectedDevicesList size is " + size); + if (DBG) if (DBG) Log.d(TAG, "cleanup: mConnectedDevicesList size is " + size); for(int i = 0; i < size; i++) { mCurrentDevice = mConnectedDevicesList.get(i); broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.STATE_CONNECTED); } quitNow(); - Log.d(TAG, "Exit doQuit()"); + if (DBG) if (DBG) Log.d(TAG, "Exit doQuit()"); } public void cleanup() { - Log.d(TAG, "Enter cleanup()"); + if (DBG) if (DBG) Log.d(TAG, "Enter cleanup()"); if (mAudioManager != null) { mAudioManager.setBluetoothScoOn(false); } if (mPhoneProxy != null) { - if (DBG) Log.d(TAG,"Unbinding service..."); + if (DBG) if (DBG) Log.d(TAG,"Unbinding service..."); synchronized (mConnection) { try { mPhoneProxy = null; @@ -372,7 +372,7 @@ final class HeadsetStateMachine extends StateMachine { cleanupNative(); mNativeAvailable = false; } - Log.d(TAG, "Exit cleanup()"); + if (DBG) if (DBG) Log.d(TAG, "Exit cleanup()"); } public void dump(StringBuilder sb) { @@ -392,7 +392,7 @@ final class HeadsetStateMachine extends StateMachine { private class Disconnected extends State { @Override public void enter() { - Log.d(TAG, "Enter Disconnected: " + getCurrentMessage().what + + if (DBG) if (DBG) Log.d(TAG, "Enter Disconnected: " + getCurrentMessage().what + ", size: " + mConnectedDevicesList.size()); mPhonebook.resetAtState(); mPhoneState.listenForPhoneState(false); @@ -403,7 +403,7 @@ final class HeadsetStateMachine extends StateMachine { @Override public boolean processMessage(Message message) { - Log.d(TAG, "Disconnected process message: " + message.what + + if (DBG) if (DBG) Log.d(TAG, "Disconnected process message: " + message.what + ", size: " + mConnectedDevicesList.size()); if (mConnectedDevicesList.size() != 0 || mTargetDevice != null || mIncomingDevice != null) { @@ -417,7 +417,7 @@ final class HeadsetStateMachine extends StateMachine { case CONNECT: BluetoothDevice device = (BluetoothDevice) message.obj; if (!mRetryConnect.containsKey(device)) { - Log.d(TAG, "Make conn retry entry for device " + device); + if (DBG) if (DBG) Log.d(TAG, "Make conn retry entry for device " + device); mRetryConnect.put(device, 0); } int RetryConn = mRetryConnect.get(device); @@ -425,7 +425,7 @@ final class HeadsetStateMachine extends StateMachine { if (RetryConn > 1) { if (mRetryConnect.containsKey(device)) { - Log.d(TAG, "Removing device " + device + + if (DBG) if (DBG) Log.d(TAG, "Removing device " + device + " conn retry entry since RetryConn = " + RetryConn); mRetryConnect.remove(device); } @@ -483,7 +483,7 @@ final class HeadsetStateMachine extends StateMachine { break; case STACK_EVENT: StackEvent event = (StackEvent) message.obj; - Log.d(TAG, "event type: " + event.type); + if (DBG) if (DBG) Log.d(TAG, "event type: " + event.type); switch (event.type) { case EVENT_TYPE_CONNECTION_STATE_CHANGED: processConnectionEvent(event.valueInt, event.device); @@ -496,26 +496,26 @@ final class HeadsetStateMachine extends StateMachine { default: return NOT_HANDLED; } - Log.d(TAG, "Exit Disconnected processMessage() "); + if (DBG) if (DBG) Log.d(TAG, "Exit Disconnected processMessage() "); return retValue; } @Override public void exit() { - Log.d(TAG, "Exit Disconnected: " + getCurrentMessage().what); + if (DBG) if (DBG) Log.d(TAG, "Exit Disconnected: " + getCurrentMessage().what); } // in Disconnected state private void processConnectionEvent(int state, BluetoothDevice device) { - Log.d(TAG, "processConnectionEvent state = " + state + + if (DBG) if (DBG) Log.d(TAG, "processConnectionEvent state = " + state + ", device = " + device); switch (state) { case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTED: - Log.d(TAG, "Ignore HF DISCONNECTED event, device: " + device); + if (DBG) if (DBG) Log.d(TAG, "Ignore HF DISCONNECTED event, device: " + device); break; case HeadsetHalConstants.CONNECTION_STATE_CONNECTING: if (okToConnect(device)){ - Log.d(TAG, "Incoming Hf accepted"); + if (DBG) if (DBG) Log.d(TAG, "Incoming Hf accepted"); broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_DISCONNECTED); @@ -524,7 +524,7 @@ final class HeadsetStateMachine extends StateMachine { transitionTo(mPending); } } else { - Log.d(TAG,"Incoming Hf rejected. priority=" + mService.getPriority(device)+ + if (DBG) if (DBG) Log.d(TAG,"Incoming Hf rejected. priority=" + mService.getPriority(device)+ " bondState=" + device.getBondState()); //reject the connection and stay in Disconnected state itself disconnectHfpNative(getByteAddress(device)); @@ -537,9 +537,9 @@ final class HeadsetStateMachine extends StateMachine { } break; case HeadsetHalConstants.CONNECTION_STATE_CONNECTED: - Log.d(TAG, "HFP Connected from Disconnected state"); + if (DBG) if (DBG) Log.d(TAG, "HFP Connected from Disconnected state"); if (okToConnect(device)) { - Log.d(TAG, "Incoming Hf accepted"); + if (DBG) if (DBG) Log.d(TAG, "Incoming Hf accepted"); if (mPhoneProxy != null) { try { log("Query the phonestates"); @@ -553,7 +553,7 @@ final class HeadsetStateMachine extends StateMachine { synchronized (HeadsetStateMachine.this) { if (!mConnectedDevicesList.contains(device)) { mConnectedDevicesList.add(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) if (DBG) Log.d(TAG, "device " + device.getAddress() + " is adding in Disconnected state"); } mCurrentDevice = device; @@ -562,7 +562,7 @@ final class HeadsetStateMachine extends StateMachine { configAudioParameters(device); } else { //reject the connection and stay in Disconnected state itself - Log.d(TAG, "Incoming Hf rejected. priority=" + mService.getPriority(device) + + if (DBG) if (DBG) Log.d(TAG, "Incoming Hf rejected. priority=" + mService.getPriority(device) + " bondState=" + device.getBondState()); disconnectHfpNative(getByteAddress(device)); // the other profile connection should be initiated @@ -574,26 +574,26 @@ final class HeadsetStateMachine extends StateMachine { } break; case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTING: - Log.d(TAG, "Ignore HF DISCONNECTING event, device: " + device); + if (DBG) Log.d(TAG, "Ignore HF DISCONNECTING event, device: " + device); break; default: Log.e(TAG, "Incorrect state: " + state); break; } - Log.d(TAG, "Exit Disconnected processConnectionEvent()"); + if (DBG) Log.d(TAG, "Exit Disconnected processConnectionEvent()"); } } private class Pending extends State { @Override public void enter() { - Log.d(TAG, "Enter Pending: " + getCurrentMessage().what); + if (DBG) Log.d(TAG, "Enter Pending: " + getCurrentMessage().what); } @Override public boolean processMessage(Message message) { - Log.d(TAG, " Enter Pending processMessage() "); - Log.d(TAG, "Pending process message: " + message.what + ", size: " + if (DBG) Log.d(TAG, " Enter Pending processMessage() "); + if (DBG) Log.d(TAG, "Pending process message: " + message.what + ", size: " + mConnectedDevicesList.size()); boolean retValue = HANDLED; @@ -629,12 +629,12 @@ final class HeadsetStateMachine extends StateMachine { break; case STACK_EVENT: StackEvent event = (StackEvent) message.obj; - Log.d(TAG, "event type: " + event.type); + if (DBG) Log.d(TAG, "event type: " + event.type); switch (event.type) { case EVENT_TYPE_CONNECTION_STATE_CHANGED: BluetoothDevice device1 = getDeviceForMessage(CONNECT_TIMEOUT); if (device1 != null && device1.equals(event.device)) { - Log.d(TAG, "remove connect timeout for device = " + device1); + if (DBG) Log.d(TAG, "remove connect timeout for device = " + device1); removeMessages(CONNECT_TIMEOUT); } processConnectionEvent(event.valueInt, event.device); @@ -647,14 +647,14 @@ final class HeadsetStateMachine extends StateMachine { default: return NOT_HANDLED; } - Log.d(TAG, " Exit Pending processMessage() "); + if (DBG) Log.d(TAG, " Exit Pending processMessage() "); return retValue; } // in Pending state private void processConnectionEvent(int state, BluetoothDevice device) { - Log.d(TAG, "Enter Pending processConnectionEvent()"); - Log.d(TAG, "processConnectionEvent state = " + state + + if (DBG) Log.d(TAG, "Enter Pending processConnectionEvent()"); + if (DBG) Log.d(TAG, "processConnectionEvent state = " + state + ", device = " + device); switch (state) { @@ -666,7 +666,7 @@ final class HeadsetStateMachine extends StateMachine { mConnectedDevicesList.remove(device); mHeadsetAudioParam.remove(device); mHeadsetBrsf.remove(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is removed in Pending state"); } @@ -701,7 +701,7 @@ final class HeadsetStateMachine extends StateMachine { } else if (mTargetDevice != null && mTargetDevice.equals(device)) { // outgoing connection failed if (mRetryConnect.containsKey(mTargetDevice)) { - Log.d(TAG, "Removing conn retry entry for device = " + mTargetDevice); + if (DBG) Log.d(TAG, "Removing conn retry entry for device = " + mTargetDevice); mRetryConnect.remove(mTargetDevice); } broadcastConnectionState(mTargetDevice, BluetoothProfile.STATE_DISCONNECTED, @@ -752,7 +752,7 @@ final class HeadsetStateMachine extends StateMachine { synchronized (HeadsetStateMachine.this) { mCurrentDevice = device; mConnectedDevicesList.add(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is added in Pending state"); mTargetDevice = null; transitionTo(mConnected); @@ -765,7 +765,7 @@ final class HeadsetStateMachine extends StateMachine { synchronized (HeadsetStateMachine.this) { mCurrentDevice = device; mConnectedDevicesList.add(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is added in Pending state"); mIncomingDevice = null; transitionTo(mConnected); @@ -782,7 +782,7 @@ final class HeadsetStateMachine extends StateMachine { synchronized (HeadsetStateMachine.this) { mCurrentDevice = device; mConnectedDevicesList.add(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is added in Pending state"); } configAudioParameters(device); @@ -839,11 +839,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Incorrect state: " + state); break; } - Log.d(TAG, "Exit Pending processConnectionEvent()"); + if (DBG) Log.d(TAG, "Exit Pending processConnectionEvent()"); } private void processMultiHFDisconnect(BluetoothDevice device) { - Log.d(TAG, "Enter pending processMultiHFDisconnect()"); + if (DBG) Log.d(TAG, "Enter pending processMultiHFDisconnect()"); log("Pending state: processMultiHFDisconnect"); /* Assign the current activedevice again if the disconnected device equals to the current active device*/ @@ -863,14 +863,14 @@ final class HeadsetStateMachine extends StateMachine { "fake broadcasting for mCurrentDevice"); broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTED); - Log.d(TAG, "Exit pending processMultiHFDisconnect()"); + if (DBG) Log.d(TAG, "Exit pending processMultiHFDisconnect()"); } } private class Connected extends State { @Override public void enter() { - Log.d(TAG, "Enter Connected: " + getCurrentMessage().what + + if (DBG) Log.d(TAG, "Enter Connected: " + getCurrentMessage().what + ", size: " + mConnectedDevicesList.size()); // start phone state listener here so that the CIND response as part of SLC can be // responded to, correctly. @@ -881,8 +881,8 @@ final class HeadsetStateMachine extends StateMachine { @Override public boolean processMessage(Message message) { - Log.d(TAG, " Enter Connected processMessage() "); - Log.d(TAG, "Connected process message: " + message.what + + if (DBG) Log.d(TAG, " Enter Connected processMessage() "); + if (DBG) Log.d(TAG, "Connected process message: " + message.what + ", size: " + mConnectedDevicesList.size()); if (DBG) { @@ -907,15 +907,15 @@ final class HeadsetStateMachine extends StateMachine { } if (!mRetryConnect.containsKey(device)) { - Log.d(TAG, "Make conn retry entry for device " + device); + if (DBG) Log.d(TAG, "Make conn retry entry for device " + device); mRetryConnect.put(device, 0); } int RetryConn = mRetryConnect.get(device); - Log.d(TAG, "RetryConn = " + RetryConn); + if (DBG) Log.d(TAG, "RetryConn = " + RetryConn); if (RetryConn > 1) { if (mRetryConnect.containsKey(device)) { - Log.d(TAG, "Removing device " + device + + if (DBG) Log.d(TAG, "Removing device " + device + " conn retry entry since RetryConn = " + RetryConn); mRetryConnect.remove(device); } @@ -925,7 +925,7 @@ final class HeadsetStateMachine extends StateMachine { if (mConnectedDevicesList.size() >= max_hf_connections) { BluetoothDevice DisconnectConnectedDevice = null; IState CurrentAudioState = getCurrentState(); - Log.d(TAG, "Reach to max size, disconnect one of them first"); + if (DBG) Log.d(TAG, "Reach to max size, disconnect one of them first"); /* TODO: Disconnect based on CoD */ DisconnectConnectedDevice = mConnectedDevicesList.get(0); @@ -1045,9 +1045,9 @@ final class HeadsetStateMachine extends StateMachine { case DIALING_OUT_TIMEOUT: { BluetoothDevice device = (BluetoothDevice) message.obj; - Log.d(TAG, "mDialingOut is " + mDialingOut); + if (DBG) Log.d(TAG, "mDialingOut is " + mDialingOut); if (mDialingOut) { - Log.d(TAG, "Timeout waiting for call to be placed, resetting mDialingOut"); + if (DBG) Log.d(TAG, "Timeout waiting for call to be placed, resetting mDialingOut"); mDialingOut= false; atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); @@ -1103,7 +1103,7 @@ final class HeadsetStateMachine extends StateMachine { break; case STACK_EVENT: StackEvent event = (StackEvent) message.obj; - Log.d(TAG, "event type: " + event.type + "event device : " + if (DBG) Log.d(TAG, "event type: " + event.type + "event device : " + event.device); switch (event.type) { case EVENT_TYPE_CONNECTION_STATE_CHANGED: @@ -1137,7 +1137,7 @@ final class HeadsetStateMachine extends StateMachine { processNoiceReductionEvent(event.valueInt, event.device); break; case EVENT_TYPE_WBS: - Log.d(TAG, "EVENT_TYPE_WBS codec is "+event.valueInt); + if (DBG) Log.d(TAG, "EVENT_TYPE_WBS codec is "+event.valueInt); processWBSEvent(event.valueInt, event.device); break; case EVENT_TYPE_AT_CHLD: @@ -1175,14 +1175,14 @@ final class HeadsetStateMachine extends StateMachine { default: return NOT_HANDLED; } - Log.d(TAG, " Exit Connected processMessage() "); + if (DBG) Log.d(TAG, " Exit Connected processMessage() "); return retValue; } // in Connected state private void processConnectionEvent(int state, BluetoothDevice device) { - Log.d(TAG, "Enter Connected processConnectionEvent()"); - Log.d(TAG, "processConnectionEvent state = " + state + + if (DBG) Log.d(TAG, "Enter Connected processConnectionEvent()"); + if (DBG) Log.d(TAG, "processConnectionEvent state = " + state + ", device = " + device); switch (state) { case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTED: @@ -1192,7 +1192,7 @@ final class HeadsetStateMachine extends StateMachine { mConnectedDevicesList.remove(device); mHeadsetAudioParam.remove(device); mHeadsetBrsf.remove(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is removed in Connected state"); if (mConnectedDevicesList.size() == 0) { @@ -1211,7 +1211,7 @@ final class HeadsetStateMachine extends StateMachine { break; case HeadsetHalConstants.CONNECTION_STATE_SLC_CONNECTED: if (mRetryConnect.containsKey(device)) { - Log.d(TAG, "Removing device " + device + + if (DBG) Log.d(TAG, "Removing device " + device + " conn retry entry since we got SLC"); mRetryConnect.remove(device); } @@ -1233,7 +1233,7 @@ final class HeadsetStateMachine extends StateMachine { if(!mConnectedDevicesList.contains(device)) { mCurrentDevice = device; mConnectedDevicesList.add(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is added in Connected state"); } transitionTo(mConnected); @@ -1257,12 +1257,12 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Connection State Device: " + device + " bad state: " + state); break; } - Log.d(TAG, "Exit Connected processConnectionEvent()"); + if (DBG) Log.d(TAG, "Exit Connected processConnectionEvent()"); } // in Connected state private void processAudioEvent(int state, BluetoothDevice device) { - Log.d(TAG, "Enter Connected processAudioEvent()"); + if (DBG) Log.d(TAG, "Enter Connected processAudioEvent()"); if (!mConnectedDevicesList.contains(device)) { Log.e(TAG, "Audio changed on disconnected device: " + device); return; @@ -1301,11 +1301,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Audio State Device: " + device + " bad state: " + state); break; } - Log.d(TAG, "Exit Connected processAudioEvent()"); + if (DBG) Log.d(TAG, "Exit Connected processAudioEvent()"); } private void processSlcConnected() { - Log.d(TAG, "Enter Connected processSlcConnected()"); + if (DBG) Log.d(TAG, "Enter Connected processSlcConnected()"); if (mPhoneProxy != null) { sendMessageDelayed(QUERY_PHONE_STATE_AT_SLC, QUERY_PHONE_STATE_CHANGED_DELAYED); mA2dpSuspend = false;/*Reset at SLC*/ @@ -1322,11 +1322,11 @@ final class HeadsetStateMachine extends StateMachine { } else { Log.e(TAG, "Handsfree phone proxy null for query phone state"); } - Log.d(TAG, "Exit Connected processSlcConnected()"); + if (DBG) Log.d(TAG, "Exit Connected processSlcConnected()"); } private void processMultiHFDisconnect(BluetoothDevice device) { - Log.d(TAG, "Enter Connected processMultiHFDisconnect()"); + if (DBG) Log.d(TAG, "Enter Connected processMultiHFDisconnect()"); log("Connect state: processMultiHFDisconnect"); if (mActiveScoDevice != null && mActiveScoDevice.equals(device)) { log ("mActiveScoDevice is disconnected, setting it to null"); @@ -1348,7 +1348,7 @@ final class HeadsetStateMachine extends StateMachine { "fake broadcasting for mCurrentDevice"); broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTED); - Log.d(TAG, "Exit Connected processMultiHFDisconnect()"); + if (DBG) Log.d(TAG, "Exit Connected processMultiHFDisconnect()"); } } @@ -1356,15 +1356,15 @@ final class HeadsetStateMachine extends StateMachine { @Override public void enter() { - Log.d(TAG, "Enter AudioOn: " + getCurrentMessage().what + ", size: " + + if (DBG) Log.d(TAG, "Enter AudioOn: " + getCurrentMessage().what + ", size: " + mConnectedDevicesList.size()); } @Override public boolean processMessage(Message message) { - Log.d(TAG, " Enter AudioOn processMessage() "); - Log.d(TAG, "AudioOn process message: " + message.what + ", size: " + + if (DBG) Log.d(TAG, " Enter AudioOn processMessage() "); + if (DBG) Log.d(TAG, "AudioOn process message: " + message.what + ", size: " + mConnectedDevicesList.size()); if (mConnectedDevicesList.size() == 0) { log("ERROR: mConnectedDevicesList is empty in AudioOn"); @@ -1388,7 +1388,7 @@ final class HeadsetStateMachine extends StateMachine { deferMessage(obtainMessage(DISCONNECT, mCurrentDevice)); deferMessage(obtainMessage(CONNECT, device)); if (disconnectAudioNative(getByteAddress(mCurrentDevice))) { - Log.d(TAG, "Disconnecting SCO audio for device = " + mCurrentDevice); + if (DBG) Log.d(TAG, "Disconnecting SCO audio for device = " + mCurrentDevice); } else { Log.e(TAG, "disconnectAudioNative failed"); } @@ -1396,15 +1396,15 @@ final class HeadsetStateMachine extends StateMachine { } if (!mRetryConnect.containsKey(device)) { - Log.d(TAG, "Make conn retry entry for device " + device); + if (DBG) Log.d(TAG, "Make conn retry entry for device " + device); mRetryConnect.put(device, 0); } int RetryConn = mRetryConnect.get(device); - Log.d(TAG, "RetryConn = " + RetryConn); + if (DBG) Log.d(TAG, "RetryConn = " + RetryConn); if (RetryConn > 1) { if (mRetryConnect.containsKey(device)) { - Log.d(TAG, "Removing device " + device + + if (DBG) Log.d(TAG, "Removing device " + device + " conn retry entry since RetryConn = " + RetryConn); mRetryConnect.remove(device); } @@ -1414,7 +1414,7 @@ final class HeadsetStateMachine extends StateMachine { if (mConnectedDevicesList.size() >= max_hf_connections) { BluetoothDevice DisconnectConnectedDevice = null; IState CurrentAudioState = getCurrentState(); - Log.d(TAG, "Reach to max size, disconnect " + + if (DBG) Log.d(TAG, "Reach to max size, disconnect " + "one of them first"); DisconnectConnectedDevice = mConnectedDevicesList.get(0); @@ -1476,7 +1476,7 @@ final class HeadsetStateMachine extends StateMachine { } if (mActiveScoDevice != null && mActiveScoDevice.equals(device)) { // The disconnected device is active SCO device - Log.d(TAG, "AudioOn, the disconnected device" + + if (DBG) Log.d(TAG, "AudioOn, the disconnected device" + "is active SCO device"); deferMessage(obtainMessage(DISCONNECT, message.obj)); // Disconnect BT SCO first @@ -1489,7 +1489,7 @@ final class HeadsetStateMachine extends StateMachine { } else { /* Do not disconnect BT SCO if the disconnected device is not active SCO device */ - Log.d(TAG, "AudioOn, the disconnected device" + + if (DBG) Log.d(TAG, "AudioOn, the disconnected device" + "is not active SCO device"); broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTING, BluetoothProfile.STATE_CONNECTED); @@ -1571,10 +1571,10 @@ final class HeadsetStateMachine extends StateMachine { break; case DIALING_OUT_TIMEOUT: { - Log.d(TAG, "mDialingOut is " + mDialingOut); + if (DBG) Log.d(TAG, "mDialingOut is " + mDialingOut); if (mDialingOut) { BluetoothDevice device = (BluetoothDevice)message.obj; - Log.d(TAG, "Timeout waiting for call to be placed, resetting mDialingOut"); + if (DBG) Log.d(TAG, "Timeout waiting for call to be placed, resetting mDialingOut"); mDialingOut= false; atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); @@ -1607,12 +1607,12 @@ final class HeadsetStateMachine extends StateMachine { break; case STACK_EVENT: StackEvent event = (StackEvent) message.obj; - Log.d(TAG, "event type: " + event.type); + if (DBG) Log.d(TAG, "event type: " + event.type); switch (event.type) { case EVENT_TYPE_CONNECTION_STATE_CHANGED: BluetoothDevice device1 = getDeviceForMessage(CONNECT_TIMEOUT); if (device1 != null && device1.equals(event.device)) { - Log.d(TAG, "remove connect timeout for device = " + device1); + if (DBG) Log.d(TAG, "remove connect timeout for device = " + device1); removeMessages(CONNECT_TIMEOUT); } processConnectionEvent(event.valueInt, event.device); @@ -1643,7 +1643,7 @@ final class HeadsetStateMachine extends StateMachine { processNoiceReductionEvent(event.valueInt, event.device); break; case EVENT_TYPE_WBS: - Log.d(TAG, "EVENT_TYPE_WBS codec is " + event.valueInt); + if (DBG) Log.d(TAG, "EVENT_TYPE_WBS codec is " + event.valueInt); processWBSEvent(event.valueInt, event.device); break; case EVENT_TYPE_AT_CHLD: @@ -1681,14 +1681,14 @@ final class HeadsetStateMachine extends StateMachine { default: return NOT_HANDLED; } - Log.d(TAG, " Exit AudioOn processMessage() "); + if (DBG) Log.d(TAG, " Exit AudioOn processMessage() "); return retValue; } // in AudioOn state. Some headsets disconnect RFCOMM prior to SCO down. Handle this private void processConnectionEvent(int state, BluetoothDevice device) { - Log.d(TAG, "Enter AudioOn processConnectionEvent()"); - Log.d(TAG, "processConnectionEvent state = " + state + ", device = " + + if (DBG) Log.d(TAG, "Enter AudioOn processConnectionEvent()"); + if (DBG) Log.d(TAG, "processConnectionEvent state = " + state + ", device = " + device); switch (state) { case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTED: @@ -1705,7 +1705,7 @@ final class HeadsetStateMachine extends StateMachine { mConnectedDevicesList.remove(device); mHeadsetAudioParam.remove(device); mHeadsetBrsf.remove(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is removed in AudioOn state"); broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.STATE_CONNECTED); @@ -1722,7 +1722,7 @@ final class HeadsetStateMachine extends StateMachine { break; case HeadsetHalConstants.CONNECTION_STATE_SLC_CONNECTED: if (mRetryConnect.containsKey(device)) { - Log.d(TAG, "Removing device " + device + + if (DBG) Log.d(TAG, "Removing device " + device + " conn retry entry since we got SLC"); mRetryConnect.remove(device); } @@ -1744,7 +1744,7 @@ final class HeadsetStateMachine extends StateMachine { if (!mConnectedDevicesList.contains(device)) { mCurrentDevice = device; mConnectedDevicesList.add(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is added in AudioOn state"); } } @@ -1767,12 +1767,12 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Connection State Device: " + device + " bad state: " + state); break; } - Log.d(TAG, "Exit AudioOn processConnectionEvent()"); + if (DBG) Log.d(TAG, "Exit AudioOn processConnectionEvent()"); } // in AudioOn state private void processAudioEvent(int state, BluetoothDevice device) { - Log.d(TAG, "Enter AudioOn processAudioEvent()"); + if (DBG) Log.d(TAG, "Enter AudioOn processAudioEvent()"); if (!mConnectedDevicesList.contains(device)) { Log.e(TAG, "Audio changed on disconnected device: " + device); return; @@ -1818,11 +1818,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Audio State Device: " + device + " bad state: " + state); break; } - Log.d(TAG, "Exit AudioOn processAudioEvent()"); + if (DBG) Log.d(TAG, "Exit AudioOn processAudioEvent()"); } private void processSlcConnected() { - Log.d(TAG, "Enter AudioOn processSlcConnected()"); + if (DBG) Log.d(TAG, "Enter AudioOn processSlcConnected()"); if (mPhoneProxy != null) { try { mPhoneProxy.queryPhoneState(); @@ -1832,11 +1832,11 @@ final class HeadsetStateMachine extends StateMachine { } else { Log.e(TAG, "Handsfree phone proxy null for query phone state"); } - Log.d(TAG, "Exit AudioOn processSlcConnected()"); + if (DBG) Log.d(TAG, "Exit AudioOn processSlcConnected()"); } private void processIntentScoVolume(Intent intent, BluetoothDevice device) { - Log.d(TAG, "Enter AudioOn processIntentScoVolume()"); + if (DBG) Log.d(TAG, "Enter AudioOn processIntentScoVolume()"); int volumeValue = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 0); if (mPhoneState.getSpeakerVolume() != volumeValue) { mPhoneState.setSpeakerVolume(volumeValue); @@ -1850,11 +1850,11 @@ final class HeadsetStateMachine extends StateMachine { 0, getByteAddress(device)); } } - Log.d(TAG, "Exit AudioOn processIntentScoVolume()"); + if (DBG) Log.d(TAG, "Exit AudioOn processIntentScoVolume()"); } private void processMultiHFDisconnect(BluetoothDevice device) { - Log.d(TAG, "Enter AudioOn processMultiHFDisconnect()"); + if (DBG) Log.d(TAG, "Enter AudioOn processMultiHFDisconnect()"); log("AudioOn state: processMultiHFDisconnect"); /* Assign the current activedevice again if the disconnected device equals to the current active device */ @@ -1871,7 +1871,7 @@ final class HeadsetStateMachine extends StateMachine { "fake broadcasting for mCurrentDevice"); broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTED); - Log.d(TAG, "Exit AudioOn processMultiHFDisconnect()"); + if (DBG) Log.d(TAG, "Exit AudioOn processMultiHFDisconnect()"); } } @@ -1880,14 +1880,14 @@ final class HeadsetStateMachine extends StateMachine { private class MultiHFPending extends State { @Override public void enter() { - Log.d(TAG, "Enter MultiHFPending: " + getCurrentMessage().what + + if (DBG) Log.d(TAG, "Enter MultiHFPending: " + getCurrentMessage().what + ", size: " + mConnectedDevicesList.size()); } @Override public boolean processMessage(Message message) { - Log.d(TAG, " Enter MultiHFPending processMessage() "); - Log.d(TAG, "MultiHFPending process message: " + message.what + + if (DBG) Log.d(TAG, " Enter MultiHFPending processMessage() "); + if (DBG) Log.d(TAG, "MultiHFPending process message: " + message.what + ", size: " + mConnectedDevicesList.size()); boolean retValue = HANDLED; @@ -1909,7 +1909,7 @@ final class HeadsetStateMachine extends StateMachine { case DISCONNECT_AUDIO: if (mActiveScoDevice != null) { if (disconnectAudioNative(getByteAddress(mActiveScoDevice))) { - Log.d(TAG, "MultiHFPending, Disconnecting SCO audio for " + + if (DBG) Log.d(TAG, "MultiHFPending, Disconnecting SCO audio for " + mActiveScoDevice); } else { Log.e(TAG, "disconnectAudioNative failed" + @@ -1978,10 +1978,10 @@ final class HeadsetStateMachine extends StateMachine { processIntentUpdateCallType((Intent) message.obj); break; case DIALING_OUT_TIMEOUT: - Log.d(TAG, "mDialingOut is " + mDialingOut); + if (DBG) Log.d(TAG, "mDialingOut is " + mDialingOut); if (mDialingOut) { device = (BluetoothDevice) message.obj; - Log.d(TAG, "Timeout waiting for call to be placed, resetting mDialingOut"); + if (DBG) Log.d(TAG, "Timeout waiting for call to be placed, resetting mDialingOut"); mDialingOut= false; atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); @@ -2038,7 +2038,7 @@ final class HeadsetStateMachine extends StateMachine { case EVENT_TYPE_CONNECTION_STATE_CHANGED: BluetoothDevice device1 = getDeviceForMessage(CONNECT_TIMEOUT); if (device1 != null && device1.equals(event.device)) { - Log.d(TAG, "remove connect timeout for device = " + device1); + if (DBG) Log.d(TAG, "remove connect timeout for device = " + device1); removeMessages(CONNECT_TIMEOUT); } processConnectionEvent(event.valueInt, event.device); @@ -2105,14 +2105,14 @@ final class HeadsetStateMachine extends StateMachine { default: return NOT_HANDLED; } - Log.d(TAG, " Exit MultiHFPending processMessage() "); + if (DBG) Log.d(TAG, " Exit MultiHFPending processMessage() "); return retValue; } // in MultiHFPending state private void processConnectionEvent(int state, BluetoothDevice device) { - Log.d(TAG, "Enter MultiHFPending processConnectionEvent()"); - Log.d(TAG, "processConnectionEvent state = " + state + + if (DBG) Log.d(TAG, "Enter MultiHFPending processConnectionEvent()"); + if (DBG) Log.d(TAG, "processConnectionEvent state = " + state + ", device = " + device); switch (state) { case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTED: @@ -2125,7 +2125,7 @@ final class HeadsetStateMachine extends StateMachine { mConnectedDevicesList.remove(device); mHeadsetAudioParam.remove(device); mHeadsetBrsf.remove(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is removed in MultiHFPending state"); broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED, @@ -2143,7 +2143,7 @@ final class HeadsetStateMachine extends StateMachine { if (mConnectedDevicesList.size() == 0) { // Should be not in this state since it has at least // one HF connected in MultiHFPending state - Log.d(TAG, "Should be not in this state, error handling"); + if (DBG) Log.d(TAG, "Should be not in this state, error handling"); transitionTo(mDisconnected); } else { @@ -2169,7 +2169,7 @@ final class HeadsetStateMachine extends StateMachine { mHeadsetAudioParam.remove(device); mHeadsetBrsf.remove(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is removed in MultiHFPending state"); } broadcastConnectionState(device, @@ -2178,7 +2178,7 @@ final class HeadsetStateMachine extends StateMachine { } } else if (mTargetDevice != null && mTargetDevice.equals(device)) { if (mRetryConnect.containsKey(mTargetDevice)) { - Log.d(TAG, "Removing conn retry entry for device = " + mTargetDevice); + if (DBG) Log.d(TAG, "Removing conn retry entry for device = " + mTargetDevice); mRetryConnect.remove(mTargetDevice); } broadcastConnectionState(mTargetDevice, BluetoothProfile.STATE_DISCONNECTED, @@ -2220,7 +2220,7 @@ final class HeadsetStateMachine extends StateMachine { synchronized (HeadsetStateMachine.this) { mCurrentDevice = device; mConnectedDevicesList.add(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is added in MultiHFPending state"); mTargetDevice = null; if (mAudioState == BluetoothHeadset.STATE_AUDIO_CONNECTED) @@ -2244,7 +2244,7 @@ final class HeadsetStateMachine extends StateMachine { if (!mConnectedDevicesList.contains(device)) { mCurrentDevice = device; mConnectedDevicesList.add(device); - Log.d(TAG, "device " + device.getAddress() + + if (DBG) Log.d(TAG, "device " + device.getAddress() + " is added in MultiHFPending state"); } } @@ -2266,7 +2266,7 @@ final class HeadsetStateMachine extends StateMachine { break; case HeadsetHalConstants.CONNECTION_STATE_SLC_CONNECTED: if (mRetryConnect.containsKey(device)) { - Log.d(TAG, "Removing device " + device + + if (DBG) Log.d(TAG, "Removing device " + device + " conn retry entry since we got SLC"); mRetryConnect.remove(device); } @@ -2302,11 +2302,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Incorrect state: " + state); break; } - Log.d(TAG, "Exit MultiHFPending processConnectionEvent()"); + if (DBG) Log.d(TAG, "Exit MultiHFPending processConnectionEvent()"); } private void processAudioEvent(int state, BluetoothDevice device) { - Log.d(TAG, "Enter MultiHFPending processAudioEvent()"); + if (DBG) Log.d(TAG, "Enter MultiHFPending processAudioEvent()"); if (!mConnectedDevicesList.contains(device)) { Log.e(TAG, "Audio changed on disconnected device: " + device); return; @@ -2377,10 +2377,10 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Audio State Device: " + device + " bad state: " + state); break; } - Log.d(TAG, "Exit MultiHFPending processAudioEvent()"); + if (DBG) Log.d(TAG, "Exit MultiHFPending processAudioEvent()"); } private void processSlcConnected() { - Log.d(TAG, "Enter MultiHFPending processSlcConnected()"); + if (DBG) Log.d(TAG, "Enter MultiHFPending processSlcConnected()"); if (mPhoneProxy != null) { // start phone state listener here, instead of on disconnected exit() // On BT off, exitting SM sends a SM exit() call which incorrectly forces @@ -2400,11 +2400,11 @@ final class HeadsetStateMachine extends StateMachine { } else { Log.e(TAG, "Handsfree phone proxy null for query phone state"); } - Log.d(TAG, "Exit MultiHFPending processSlcConnected()"); + if (DBG) Log.d(TAG, "Exit MultiHFPending processSlcConnected()"); } private void processMultiHFDisconnect(BluetoothDevice device) { - Log.d(TAG, "Enter MultiHFPending processMultiHFDisconnect()"); + if (DBG) Log.d(TAG, "Enter MultiHFPending processMultiHFDisconnect()"); log("MultiHFPending state: processMultiHFDisconnect"); if (mActiveScoDevice != null && mActiveScoDevice.equals(device)) { log ("mActiveScoDevice is disconnected, setting it to null"); @@ -2426,11 +2426,11 @@ final class HeadsetStateMachine extends StateMachine { "fake broadcasting for mCurrentDevice"); broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTED); - Log.d(TAG, "Exit MultiHFPending processMultiHFDisconnect()"); + if (DBG) Log.d(TAG, "Exit MultiHFPending processMultiHFDisconnect()"); } private void processIntentScoVolume(Intent intent, BluetoothDevice device) { - Log.d(TAG, "Enter MultiHFPending processIntentScoVolume()"); + if (DBG) Log.d(TAG, "Enter MultiHFPending processIntentScoVolume()"); int volumeValue = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 0); if (mPhoneState.getSpeakerVolume() != volumeValue) { mPhoneState.setSpeakerVolume(volumeValue); @@ -2444,7 +2444,7 @@ final class HeadsetStateMachine extends StateMachine { 0, getByteAddress(device)); } } - Log.d(TAG, "Exit MultiHFPending processIntentScoVolume()"); + if (DBG) Log.d(TAG, "Exit MultiHFPending processIntentScoVolume()"); } } @@ -2464,7 +2464,7 @@ final class HeadsetStateMachine extends StateMachine { // HFP Connection state of the device could be changed by the state machine // in separate thread while this method is executing. int getConnectionState(BluetoothDevice device) { - Log.d(TAG, "Enter getConnectionState()"); + if (DBG) Log.d(TAG, "Enter getConnectionState()"); if (getCurrentState() == mDisconnected) { log("currentState is Disconnected"); return BluetoothProfile.STATE_DISCONNECTED; @@ -2517,24 +2517,24 @@ final class HeadsetStateMachine extends StateMachine { } List<BluetoothDevice> getConnectedDevices() { - Log.d(TAG, "Enter getConnectedDevices()"); + if (DBG) Log.d(TAG, "Enter getConnectedDevices()"); List<BluetoothDevice> devices = new ArrayList<BluetoothDevice>(); synchronized(this) { for (int i = 0; i < mConnectedDevicesList.size(); i++) devices.add(mConnectedDevicesList.get(i)); } - Log.d(TAG, "Exit getConnectedDevices()"); + if (DBG) Log.d(TAG, "Exit getConnectedDevices()"); return devices; } boolean isAudioOn() { - Log.d(TAG, "isAudioOn()"); + if (DBG) Log.d(TAG, "isAudioOn()"); return (getCurrentState() == mAudioOn); } boolean isAudioConnected(BluetoothDevice device) { - Log.d(TAG, "Enter isAudioConnected()"); + if (DBG) Log.d(TAG, "Enter isAudioConnected()"); synchronized(this) { /* Additional check for audio state included for the case when PhoneApp queries @@ -2548,40 +2548,40 @@ final class HeadsetStateMachine extends StateMachine { return true; } } - Log.d(TAG, "Exit isAudioConnected()"); + if (DBG) Log.d(TAG, "Exit isAudioConnected()"); return false; } public void setAudioRouteAllowed(boolean allowed) { - Log.d(TAG, "Enter setAudioRouteAllowed()"); + if (DBG) Log.d(TAG, "Enter setAudioRouteAllowed()"); mAudioRouteAllowed = allowed; - Log.d(TAG, "Exit setAudioRouteAllowed()"); + if (DBG) Log.d(TAG, "Exit setAudioRouteAllowed()"); } public boolean getAudioRouteAllowed() { - Log.d(TAG, "getAudioRouteAllowed()"); + if (DBG) Log.d(TAG, "getAudioRouteAllowed()"); return mAudioRouteAllowed; } int getAudioState(BluetoothDevice device) { - Log.d(TAG, "Enter getAudioState()"); + if (DBG) Log.d(TAG, "Enter getAudioState()"); synchronized(this) { if (mConnectedDevicesList.size() == 0) { return BluetoothHeadset.STATE_AUDIO_DISCONNECTED; } } - Log.d(TAG, "Exit getAudioState()"); + if (DBG) Log.d(TAG, "Exit getAudioState()"); return mAudioState; } private void processVrEvent(int state, BluetoothDevice device) { - Log.d(TAG, "Enter processVrEvent()"); + if (DBG) Log.d(TAG, "Enter processVrEvent()"); if(device == null) { Log.w(TAG, "processVrEvent device is null"); return; } - Log.d(TAG, "processVrEvent: state=" + state + " mVoiceRecognitionStarted: " + + if (DBG) Log.d(TAG, "processVrEvent: state=" + state + " mVoiceRecognitionStarted: " + mVoiceRecognitionStarted + " mWaitingforVoiceRecognition: " + mWaitingForVoiceRecognition + " isInCall: " + isInCall()); if (state == HeadsetHalConstants.VR_STATE_STARTED) { @@ -2628,12 +2628,12 @@ final class HeadsetStateMachine extends StateMachine { } else { Log.e(TAG, "Bad Voice Recognition state: " + state); } - Log.d(TAG, "Exit processVrEvent()"); + if (DBG) Log.d(TAG, "Exit processVrEvent()"); } private void processLocalVrEvent(int state) { - Log.d(TAG, "Enter processLocalVrEvent()"); + if (DBG) Log.d(TAG, "Enter processLocalVrEvent()"); BluetoothDevice device = null; if (state == HeadsetHalConstants.VR_STATE_STARTED) { @@ -2652,7 +2652,7 @@ final class HeadsetStateMachine extends StateMachine { if (device == null) return; - Log.d(TAG, "Voice recognition started successfully"); + if (DBG) Log.d(TAG, "Voice recognition started successfully"); mWaitingForVoiceRecognition = false; atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_OK, 0, getByteAddress(device)); @@ -2660,7 +2660,7 @@ final class HeadsetStateMachine extends StateMachine { } else { - Log.d(TAG, "Voice recognition started locally"); + if (DBG) Log.d(TAG, "Voice recognition started locally"); needAudio = startVoiceRecognitionNative(getByteAddress(mCurrentDevice)); if (mCurrentDevice != null) device = mCurrentDevice; @@ -2668,7 +2668,7 @@ final class HeadsetStateMachine extends StateMachine { if (needAudio && !isAudioOn()) { - Log.d(TAG, "Initiating audio connection for Voice Recognition"); + if (DBG) Log.d(TAG, "Initiating audio connection for Voice Recognition"); // At this stage, we need to be sure that AVDTP is not streaming. This is needed // to be compliant with the AV+HFP Whitepaper as we cannot have A2DP in // streaming state while a SCO connection is established. @@ -2691,7 +2691,7 @@ final class HeadsetStateMachine extends StateMachine { } else { - Log.d(TAG, "Voice Recognition stopped. mVoiceRecognitionStarted: " + mVoiceRecognitionStarted + + if (DBG) Log.d(TAG, "Voice Recognition stopped. mVoiceRecognitionStarted: " + mVoiceRecognitionStarted + " mWaitingForVoiceRecognition: " + mWaitingForVoiceRecognition); if (mVoiceRecognitionStarted || mWaitingForVoiceRecognition) { @@ -2707,11 +2707,11 @@ final class HeadsetStateMachine extends StateMachine { } } } - Log.d(TAG, "Exit processLocalVrEvent()"); + if (DBG) Log.d(TAG, "Exit processLocalVrEvent()"); } private synchronized void expectVoiceRecognition(BluetoothDevice device) { - Log.d(TAG, "Enter expectVoiceRecognition()"); + if (DBG) Log.d(TAG, "Enter expectVoiceRecognition()"); mWaitingForVoiceRecognition = true; Message m = obtainMessage(START_VR_TIMEOUT); m.obj = getMatchingDevice(device); @@ -2720,11 +2720,11 @@ final class HeadsetStateMachine extends StateMachine { if (!mStartVoiceRecognitionWakeLock.isHeld()) { mStartVoiceRecognitionWakeLock.acquire(START_VR_TIMEOUT_VALUE); } - Log.d(TAG, "Exit expectVoiceRecognition()"); + if (DBG) Log.d(TAG, "Exit expectVoiceRecognition()"); } List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { - Log.d(TAG, "Enter getDevicesMatchingConnectionStates()"); + if (DBG) Log.d(TAG, "Enter getDevicesMatchingConnectionStates()"); List<BluetoothDevice> deviceList = new ArrayList<BluetoothDevice>(); Set<BluetoothDevice> bondedDevices = mAdapter.getBondedDevices(); int connectionState; @@ -2742,13 +2742,13 @@ final class HeadsetStateMachine extends StateMachine { } } } - Log.d(TAG, "Exit getDevicesMatchingConnectionStates()"); + if (DBG) Log.d(TAG, "Exit getDevicesMatchingConnectionStates()"); return deviceList; } private BluetoothDevice getDeviceForMessage(int what) { - Log.d(TAG, "Enter getDeviceForMessage()"); + if (DBG) Log.d(TAG, "Enter getDeviceForMessage()"); if (what == CONNECT_TIMEOUT) { log("getDeviceForMessage: returning mTargetDevice for what=" + what); return mTargetDevice; @@ -2771,7 +2771,7 @@ final class HeadsetStateMachine extends StateMachine { private BluetoothDevice getMatchingDevice(BluetoothDevice device) { - Log.d(TAG, "Enter getMatchingDevice()"); + if (DBG) Log.d(TAG, "Enter getMatchingDevice()"); for (BluetoothDevice matchingDevice : mConnectedDevicesList) { if (matchingDevice.equals(device)) @@ -2779,14 +2779,14 @@ final class HeadsetStateMachine extends StateMachine { return matchingDevice; } } - Log.d(TAG, "Exit getMatchingDevice()"); + if (DBG) Log.d(TAG, "Exit getMatchingDevice()"); return null; } // This method does not check for error conditon (newState == prevState) private void broadcastConnectionState(BluetoothDevice device, int newState, int prevState) { - Log.d(TAG, "Enter broadcastConnectionState()"); - Log.d(TAG, "Connection state " + device + ": " + prevState + "->" + newState); + if (DBG) Log.d(TAG, "Enter broadcastConnectionState()"); + if (DBG) Log.d(TAG, "Connection state " + device + ": " + prevState + "->" + newState); if(prevState == BluetoothProfile.STATE_CONNECTED) { // Headset is disconnecting, stop Virtual call if active. terminateScoUsingVirtualVoiceCall(); @@ -2803,11 +2803,11 @@ final class HeadsetStateMachine extends StateMachine { intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); mService.sendBroadcastAsUser(intent, UserHandle.ALL, HeadsetService.BLUETOOTH_PERM); - Log.d(TAG, "Exit broadcastConnectionState()"); + if (DBG) Log.d(TAG, "Exit broadcastConnectionState()"); } private void broadcastAudioState(BluetoothDevice device, int newState, int prevState) { - Log.d(TAG, "Enter broadcastAudioState()"); + if (DBG) Log.d(TAG, "Enter broadcastAudioState()"); if(prevState == BluetoothHeadset.STATE_AUDIO_CONNECTED) { // When SCO gets disconnected during call transfer, Virtual call //needs to be cleaned up.So call terminateScoUsingVirtualVoiceCall. @@ -2819,8 +2819,8 @@ final class HeadsetStateMachine extends StateMachine { intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); mService.sendBroadcastAsUser(intent, UserHandle.ALL, HeadsetService.BLUETOOTH_PERM); - Log.d(TAG, "Audio state " + device + ": " + prevState + "->" + newState); - Log.d(TAG, "Exit broadcastAudioState()"); + if (DBG) Log.d(TAG, "Audio state " + device + ": " + prevState + "->" + newState); + if (DBG) Log.d(TAG, "Exit broadcastAudioState()"); } /* @@ -2831,7 +2831,7 @@ final class HeadsetStateMachine extends StateMachine { int commandType, Object[] arguments, BluetoothDevice device) { - Log.d(TAG, "Enter broadcastVendorSpecificEventIntent()"); + if (DBG) Log.d(TAG, "Enter broadcastVendorSpecificEventIntent()"); log("broadcastVendorSpecificEventIntent(" + command + ")"); Intent intent = new Intent(BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT); @@ -2847,7 +2847,7 @@ final class HeadsetStateMachine extends StateMachine { mService.sendBroadcastAsUser(intent, UserHandle.ALL, HeadsetService.BLUETOOTH_PERM); - Log.d(TAG, "Exit broadcastVendorSpecificEventIntent()"); + if (DBG) Log.d(TAG, "Exit broadcastVendorSpecificEventIntent()"); } /* @@ -2856,8 +2856,8 @@ final class HeadsetStateMachine extends StateMachine { private void broadcastHfIndicatorValueChangeIntent(int anum, long value, BluetoothDevice device) { - Log.d(TAG, "Enter broadcastHfIndicatorValueChangeIntent()"); - Log.d(TAG, "broadcastHfIndicatorValueChangeIntent"); + if (DBG) Log.d(TAG, "Enter broadcastHfIndicatorValueChangeIntent()"); + if (DBG) Log.d(TAG, "broadcastHfIndicatorValueChangeIntent"); Intent intent = new Intent(BluetoothHeadset.ACTION_HF_INDICATOR_VALUE_CHANGED); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); @@ -2867,12 +2867,12 @@ final class HeadsetStateMachine extends StateMachine { + "." + Long.toString(value)); mService.sendBroadcast(intent, HeadsetService.BLUETOOTH_PERM); - Log.d(TAG, "Exit broadcastHfIndicatorValueChangeIntent()"); + if (DBG) Log.d(TAG, "Exit broadcastHfIndicatorValueChangeIntent()"); } private void configAudioParameters(BluetoothDevice device) { - Log.d(TAG, "Enter configAudioParameters()"); + if (DBG) Log.d(TAG, "Enter configAudioParameters()"); // Reset NREC on connect event. Headset will override later HashMap<String, Integer> AudioParamConfig = new HashMap<String, Integer>(); AudioParamConfig.put("NREC", 1); @@ -2880,14 +2880,14 @@ final class HeadsetStateMachine extends StateMachine { mHeadsetAudioParam.put(device, AudioParamConfig); mAudioManager.setParameters(HEADSET_NAME + "=" + getCurrentDeviceName(device) + ";" + HEADSET_NREC + "=on"); - Log.d(TAG, "configAudioParameters for device:" + device + " are: nrec = " + + if (DBG) Log.d(TAG, "configAudioParameters for device:" + device + " are: nrec = " + AudioParamConfig.get("NREC")); - Log.d(TAG, "Exit configAudioParameters()"); + if (DBG) Log.d(TAG, "Exit configAudioParameters()"); } private void setAudioParameters(BluetoothDevice device) { - Log.d(TAG, "Enter setAudioParameters()"); + if (DBG) Log.d(TAG, "Enter setAudioParameters()"); // 1. update nrec value // 2. update headset name int mNrec = 0; @@ -2903,10 +2903,10 @@ final class HeadsetStateMachine extends StateMachine { } if (mCodec != WBS_CODEC) { - Log.d(TAG, "Use NBS PCM samples:" + device); + if (DBG) Log.d(TAG, "Use NBS PCM samples:" + device); mAudioManager.setParameters(HEADSET_WBS + "=off"); } else { - Log.d(TAG, "Use WBS PCM samples:" + device); + if (DBG) Log.d(TAG, "Use WBS PCM samples:" + device); mAudioManager.setParameters(HEADSET_WBS + "=on"); } if (mNrec == 1) { @@ -2917,12 +2917,12 @@ final class HeadsetStateMachine extends StateMachine { mAudioManager.setParameters(HEADSET_NREC + "=off"); } mAudioManager.setParameters(HEADSET_NAME + "=" + getCurrentDeviceName(device)); - Log.d(TAG, "Exit setAudioParameters()"); + if (DBG) Log.d(TAG, "Exit setAudioParameters()"); } private String parseUnknownAt(String atString) { - Log.d(TAG, "Enter parseUnknownAt()"); + if (DBG) Log.d(TAG, "Enter parseUnknownAt()"); StringBuilder atCommand = new StringBuilder(atString.length()); String result = null; @@ -2942,13 +2942,13 @@ final class HeadsetStateMachine extends StateMachine { } } result = atCommand.toString(); - Log.d(TAG, "Exit parseUnknownAt()"); + if (DBG) Log.d(TAG, "Exit parseUnknownAt()"); return result; } private int getAtCommandType(String atCommand) { - Log.d(TAG, "Enter getAtCommandType()"); + if (DBG) Log.d(TAG, "Enter getAtCommandType()"); int commandType = mPhonebook.TYPE_UNKNOWN; String atString = null; atCommand = atCommand.trim(); @@ -2964,20 +2964,20 @@ final class HeadsetStateMachine extends StateMachine { else commandType = mPhonebook.TYPE_UNKNOWN; } - Log.d(TAG, "Exit getAtCommandType()"); + if (DBG) Log.d(TAG, "Exit getAtCommandType()"); return commandType; } /* Method to check if Virtual Call in Progress */ private boolean isVirtualCallInProgress() { - Log.d(TAG, "isVirtualCallInProgress()"); + if (DBG) Log.d(TAG, "isVirtualCallInProgress()"); return mVirtualCallStarted; } void setVirtualCallInProgress(boolean state) { - Log.d(TAG, "Enter setVirtualCallInProgress()"); + if (DBG) Log.d(TAG, "Enter setVirtualCallInProgress()"); mVirtualCallStarted = state; - Log.d(TAG, "Exit setVirtualCallInProgress()"); + if (DBG) Log.d(TAG, "Exit setVirtualCallInProgress()"); } /* NOTE: Currently the VirtualCall API does not support handling of @@ -2985,7 +2985,7 @@ final class HeadsetStateMachine extends StateMachine { HeadsetStateMachine will end the virtual call by calling terminateScoUsingVirtualVoiceCall() in broadcastAudioState() */ synchronized boolean initiateScoUsingVirtualVoiceCall() { - Log.d(TAG, "Enter initiateScoUsingVirtualVoiceCall()"); + if (DBG) Log.d(TAG, "Enter initiateScoUsingVirtualVoiceCall()"); log("initiateScoUsingVirtualVoiceCall: Received"); // 1. Check if the SCO state is idle if (isInCall() || mVoiceRecognitionStarted) { @@ -3017,12 +3017,12 @@ final class HeadsetStateMachine extends StateMachine { HeadsetHalConstants.CALL_STATE_IDLE, "", 0), true); // Done log("initiateScoUsingVirtualVoiceCall: Done"); - Log.d(TAG, "Exit initiateScoUsingVirtualVoiceCall()"); + if (DBG) Log.d(TAG, "Exit initiateScoUsingVirtualVoiceCall()"); return true; } synchronized boolean terminateScoUsingVirtualVoiceCall() { - Log.d(TAG, "Enter terminateScoUsingVirtualVoiceCall()"); + if (DBG) Log.d(TAG, "Enter terminateScoUsingVirtualVoiceCall()"); log("terminateScoUsingVirtualVoiceCall: Received"); if (!isVirtualCallInProgress()) { @@ -3046,7 +3046,7 @@ final class HeadsetStateMachine extends StateMachine { // Done log("terminateScoUsingVirtualVoiceCall: Done"); - Log.d(TAG, "Exit terminateScoUsingVirtualVoiceCall()"); + if (DBG) Log.d(TAG, "Exit terminateScoUsingVirtualVoiceCall()"); return true; } @@ -3055,22 +3055,22 @@ final class HeadsetStateMachine extends StateMachine { connected while in call and music was played before that (Special case to handle RINGER VOLUME zero + music + call) */ private void processIntentA2dpStateChanged(Intent intent) { - Log.d(TAG, "Enter processIntentA2dpStateChanged()"); + if (DBG) Log.d(TAG, "Enter processIntentA2dpStateChanged()"); int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, BluetoothProfile.STATE_DISCONNECTED); int oldState = intent.getIntExtra(BluetoothProfile. EXTRA_PREVIOUS_STATE,BluetoothProfile.STATE_DISCONNECTED); - Log.d(TAG, "A2dp State Changed: Current State: " + state + + if (DBG) Log.d(TAG, "A2dp State Changed: Current State: " + state + "Prev State: " + oldState + "A2pSuspend: " + mA2dpSuspend); mA2dpState = state; - Log.d(TAG, "Exit processIntentA2dpStateChanged()"); + if (DBG) Log.d(TAG, "Exit processIntentA2dpStateChanged()"); } private void processIntentUpdateCallType(Intent intent) { - Log.d(TAG, "Enter processIntentUpdateCallType()"); + if (DBG) Log.d(TAG, "Enter processIntentUpdateCallType()"); mIsCsCall = intent.getBooleanExtra(TelecomManager.EXTRA_CALL_TYPE_CS, true); - Log.d(TAG, "processIntentUpdateCallType " + mIsCsCall); + if (DBG) Log.d(TAG, "processIntentUpdateCallType " + mIsCsCall); mPhoneState.setIsCsCall(mIsCsCall); if (mActiveScoDevice != null) { if (!mPhoneState.getIsCsCall()) { @@ -3082,18 +3082,18 @@ final class HeadsetStateMachine extends StateMachine { } else { log("processIntentUpdateCallType: Sco not yet connected"); } - Log.d(TAG, "Exit processIntentUpdateCallType()"); + if (DBG) Log.d(TAG, "Exit processIntentUpdateCallType()"); } private void processIntentA2dpPlayStateChanged(Intent intent) { - Log.d(TAG, "Enter processIntentA2dpPlayStateChanged()"); + if (DBG) Log.d(TAG, "Enter processIntentA2dpPlayStateChanged()"); int currState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, BluetoothA2dp.STATE_NOT_PLAYING); int prevState = intent.getIntExtra( BluetoothProfile.EXTRA_PREVIOUS_STATE, BluetoothA2dp.STATE_NOT_PLAYING); - Log.d(TAG, "A2dp Play State Changed: Current State: " + currState + + if (DBG) Log.d(TAG, "A2dp Play State Changed: Current State: " + currState + "Prev State: " + prevState + "A2pSuspend: " + mA2dpSuspend); if (prevState == BluetoothA2dp.STATE_PLAYING) { @@ -3122,14 +3122,14 @@ final class HeadsetStateMachine extends StateMachine { it.remove(); } } else { - Log.d(TAG, "There are no pending call state changes"); + if (DBG) Log.d(TAG, "There are no pending call state changes"); } } mPendingCiev = false; } } else if (prevState == BluetoothA2dp.STATE_NOT_PLAYING) { - Log.d(TAG, "A2dp Started " + currState); + if (DBG) Log.d(TAG, "A2dp Started " + currState); if ((isInCall() || isVirtualCallInProgress()) && isConnected()) { if(mA2dpSuspend) Log.e(TAG,"A2dp started while in call, ERROR"); @@ -3141,11 +3141,11 @@ final class HeadsetStateMachine extends StateMachine { } } mA2dpPlayState = currState; - Log.d(TAG, "Exit processIntentA2dpPlayStateChanged()"); + if (DBG) Log.d(TAG, "Exit processIntentA2dpPlayStateChanged()"); } private void processAnswerCall(BluetoothDevice device) { - Log.d(TAG, "Enter processAnswerCall()"); + if (DBG) Log.d(TAG, "Enter processAnswerCall()"); if(device == null) { Log.w(TAG, "processAnswerCall device is null"); return; @@ -3161,11 +3161,11 @@ final class HeadsetStateMachine extends StateMachine { } else { Log.e(TAG, "Handsfree phone proxy null for answering call"); } - Log.d(TAG, "Exit processAnswerCall()"); + if (DBG) Log.d(TAG, "Exit processAnswerCall()"); } private void processHangupCall(BluetoothDevice device) { - Log.d(TAG, "Enter processHangupCall()"); + if (DBG) Log.d(TAG, "Enter processHangupCall()"); if(device == null) { Log.w(TAG, "processHangupCall device is null"); return; @@ -3185,11 +3185,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Handsfree phone proxy null for hanging up call"); } } - Log.d(TAG, "Exit processHangupCall()"); + if (DBG) Log.d(TAG, "Exit processHangupCall()"); } private void processDialCall(String number, BluetoothDevice device) { - Log.d(TAG, "Enter processDialCall()"); + if (DBG) Log.d(TAG, "Enter processDialCall()"); if(device == null) { Log.w(TAG, "processDialCall device is null"); return; @@ -3197,7 +3197,7 @@ final class HeadsetStateMachine extends StateMachine { String dialNumber; if (mDialingOut) { - Log.d(TAG, "processDialCall, already dialling"); + if (DBG) Log.d(TAG, "processDialCall, already dialling"); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); return; @@ -3205,7 +3205,7 @@ final class HeadsetStateMachine extends StateMachine { if ((number == null) || (number.length() == 0)) { dialNumber = mPhonebook.getLastDialledNumber(); if (dialNumber == null) { - Log.d(TAG, "processDialCall, last dial number null"); + if (DBG) Log.d(TAG, "processDialCall, last dial number null"); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); return; @@ -3221,7 +3221,7 @@ final class HeadsetStateMachine extends StateMachine { log("processDialCall, memory dial do last dial for now"); dialNumber = mPhonebook.getLastDialledNumber(); if (dialNumber == null) { - Log.d(TAG, "processDialCall, last dial number null"); + if (DBG) Log.d(TAG, "processDialCall, last dial number null"); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); return; @@ -3248,11 +3248,11 @@ final class HeadsetStateMachine extends StateMachine { Message m = obtainMessage(DIALING_OUT_TIMEOUT); m.obj = getMatchingDevice(device); sendMessageDelayed(m, DIALING_OUT_TIMEOUT_VALUE); - Log.d(TAG, "Exit processDialCall()"); + if (DBG) Log.d(TAG, "Exit processDialCall()"); } private void processVolumeEvent(int volumeType, int volume, BluetoothDevice device) { - Log.d(TAG, "Enter processVolumeEvent()"); + if (DBG) Log.d(TAG, "Enter processVolumeEvent()"); if(device != null && !device.equals(mActiveScoDevice) && mPhoneState.isInCall()) { Log.w(TAG, "ignore processVolumeEvent"); return; @@ -3267,11 +3267,11 @@ final class HeadsetStateMachine extends StateMachine { } else { Log.e(TAG, "Bad voluem type: " + volumeType); } - Log.d(TAG, "Exit processVolumeEvent()"); + if (DBG) Log.d(TAG, "Exit processVolumeEvent()"); } private void processSendDtmf(int dtmf, BluetoothDevice device) { - Log.d(TAG, "Enter processSendDtmf()"); + if (DBG) Log.d(TAG, "Enter processSendDtmf()"); if(device == null) { Log.w(TAG, "processSendDtmf device is null"); return; @@ -3286,18 +3286,18 @@ final class HeadsetStateMachine extends StateMachine { } else { Log.e(TAG, "Handsfree phone proxy null for sending DTMF"); } - Log.d(TAG, "Exit processSendDtmf()"); + if (DBG) Log.d(TAG, "Exit processSendDtmf()"); } private void processCallState(HeadsetCallState callState) { - Log.d(TAG, "Enter processCallState()"); + if (DBG) Log.d(TAG, "Enter processCallState()"); processCallState(callState, false); - Log.d(TAG, "Exit processCallState()"); + if (DBG) Log.d(TAG, "Exit processCallState()"); } private void processCallState(HeadsetCallState callState, boolean isVirtualCall) { - Log.d(TAG, "Enter processCallState()"); + if (DBG) Log.d(TAG, "Enter processCallState()"); mPhoneState.setNumActiveCall(callState.mNumActive); mPhoneState.setNumHeldCall(callState.mNumHeld); mPhoneState.setCallState(callState.mCallState); @@ -3307,7 +3307,7 @@ final class HeadsetStateMachine extends StateMachine { HeadsetHalConstants.CALL_STATE_DIALING) { BluetoothDevice device = getDeviceForMessage(DIALING_OUT_TIMEOUT); removeMessages(DIALING_OUT_TIMEOUT); - Log.d(TAG, "mDialingOut is " + mDialingOut + ", device " + device); + if (DBG) Log.d(TAG, "mDialingOut is " + mDialingOut + ", device " + device); mDialingOut = false; if (device == null) { return; @@ -3328,7 +3328,7 @@ final class HeadsetStateMachine extends StateMachine { /* Specific handling when HS connects while in Voip call */ if (isVirtualCallInProgress() && !isInCall() && callState.mCallState == HeadsetHalConstants.CALL_STATE_IDLE) { - Log.d(TAG, "update btif for Virtual Call active"); + if (DBG) Log.d(TAG, "update btif for Virtual Call active"); callState.mNumActive = 1; mPhoneState.setNumActiveCall(callState.mNumActive); } else { @@ -3348,7 +3348,7 @@ final class HeadsetStateMachine extends StateMachine { } } processA2dpState(callState); - Log.d(TAG, "Exit processCallState()"); + if (DBG) Log.d(TAG, "Exit processCallState()"); } /* This function makes sure that we send a2dp suspend before updating on Incomming call status. @@ -3357,18 +3357,18 @@ final class HeadsetStateMachine extends StateMachine { callstate is idle and there are no active or held calls. */ private void processA2dpState(HeadsetCallState callState) { - Log.d(TAG, "Enter processA2dpState()"); + if (DBG) Log.d(TAG, "Enter processA2dpState()"); log("mA2dpPlayState " + mA2dpPlayState + " mA2dpSuspend " + mA2dpSuspend ); if ((isInCall()) && (isConnected()) && (mA2dpState == BluetoothProfile.STATE_CONNECTED)) { if (!mA2dpSuspend) { - Log.d(TAG, "Suspend A2DP streaming"); + if (DBG) Log.d(TAG, "Suspend A2DP streaming"); mAudioManager.setParameters("A2dpSuspended=true"); mA2dpSuspend = true; } // Cache the call states for CS calls only if (mA2dpPlayState == BluetoothA2dp.STATE_PLAYING && !isVirtualCallInProgress()) { - Log.d(TAG, "Cache the call state for future"); + if (DBG) Log.d(TAG, "Cache the call state for future"); mPendingCiev = true; mPendingCallStates.add(callState); return ; @@ -3386,13 +3386,13 @@ final class HeadsetStateMachine extends StateMachine { mA2dpSuspend = false; } } - Log.d(TAG, "Exit processA2dpState()"); + if (DBG) Log.d(TAG, "Exit processA2dpState()"); } // 1 enable noice reduction // 0 disable noice reduction private void processNoiceReductionEvent(int enable, BluetoothDevice device) { - Log.d(TAG, "Enter processNoiceReductionEvent()"); + if (DBG) Log.d(TAG, "Enter processNoiceReductionEvent()"); HashMap<String, Integer> AudioParamNrec = mHeadsetAudioParam.get(device); if (AudioParamNrec != null && !AudioParamNrec.isEmpty()) { if (enable == 1) @@ -3409,13 +3409,13 @@ final class HeadsetStateMachine extends StateMachine { && mAudioState == BluetoothHeadset.STATE_AUDIO_CONNECTED) { setAudioParameters(device); } - Log.d(TAG, "Exit processNoiceReductionEvent()"); + if (DBG) Log.d(TAG, "Exit processNoiceReductionEvent()"); } // 2 - WBS on // 1 - NBS on private void processWBSEvent(int enable, BluetoothDevice device) { - Log.d(TAG, "Enter processWBSEvent()"); + if (DBG) Log.d(TAG, "Enter processWBSEvent()"); HashMap<String, Integer> AudioParamCodec = mHeadsetAudioParam.get(device); if (AudioParamCodec != null && !AudioParamCodec.isEmpty()) { AudioParamCodec.put("codec", enable); @@ -3424,19 +3424,19 @@ final class HeadsetStateMachine extends StateMachine { } if (enable == 2) { - Log.d(TAG, "AudioManager.setParameters bt_wbs=on for " + + if (DBG) Log.d(TAG, "AudioManager.setParameters bt_wbs=on for " + device.getName() + " - " + device.getAddress()); mAudioManager.setParameters(HEADSET_WBS + "=on"); } else { - Log.d(TAG, "AudioManager.setParameters bt_wbs=off for " + + if (DBG) Log.d(TAG, "AudioManager.setParameters bt_wbs=off for " + device.getName() + " - " + device.getAddress()); mAudioManager.setParameters(HEADSET_WBS + "=off"); } - Log.d(TAG, "Exit processWBSEvent()"); + if (DBG) Log.d(TAG, "Exit processWBSEvent()"); } private void processAtChld(int chld, BluetoothDevice device) { - Log.d(TAG, "Enter processAtChld()"); + if (DBG) Log.d(TAG, "Enter processAtChld()"); if(device == null) { Log.w(TAG, "processAtChld device is null"); return; @@ -3461,11 +3461,11 @@ final class HeadsetStateMachine extends StateMachine { atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); } - Log.d(TAG, "Exit processAtChld()"); + if (DBG) Log.d(TAG, "Exit processAtChld()"); } private void processSubscriberNumberRequest(BluetoothDevice device) { - Log.d(TAG, "Enter processSubscriberNumberRequest()"); + if (DBG) Log.d(TAG, "Enter processSubscriberNumberRequest()"); if(device == null) { Log.w(TAG, "processSubscriberNumberRequest device is null"); return; @@ -3493,11 +3493,11 @@ final class HeadsetStateMachine extends StateMachine { } else { Log.e(TAG, "Handsfree phone proxy null for At+CNUM"); } - Log.d(TAG, "Exit processSubscriberNumberRequest()"); + if (DBG) Log.d(TAG, "Exit processSubscriberNumberRequest()"); } private void processAtCind(BluetoothDevice device) { - Log.d(TAG, "Enter processAtCind()"); + if (DBG) Log.d(TAG, "Enter processAtCind()"); int call, call_setup; if(device == null) { @@ -3521,11 +3521,11 @@ final class HeadsetStateMachine extends StateMachine { call_setup, mPhoneState.getCallState(), mPhoneState.getSignal(), mPhoneState.getRoam(), mPhoneState.getBatteryCharge(), getByteAddress(device)); - Log.d(TAG, "Exit processAtCind()"); + if (DBG) Log.d(TAG, "Exit processAtCind()"); } private void processAtCops(BluetoothDevice device) { - Log.d(TAG, "Enter processAtCops()"); + if (DBG) Log.d(TAG, "Enter processAtCops()"); if(device == null) { Log.w(TAG, "processAtCops device is null"); return; @@ -3546,11 +3546,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Handsfree phone proxy null for At+COPS"); copsResponseNative("", getByteAddress(device)); } - Log.d(TAG, "Exit processAtCops()"); + if (DBG) Log.d(TAG, "Exit processAtCops()"); } private void processAtClcc(BluetoothDevice device) { - Log.d(TAG, "Enter processAtClcc()"); + if (DBG) Log.d(TAG, "Enter processAtClcc()"); if(device == null) { Log.w(TAG, "processAtClcc device is null"); return; @@ -3579,7 +3579,7 @@ final class HeadsetStateMachine extends StateMachine { } else { - Log.d(TAG, "Starting CLCC response timeout for device: " + if (DBG) Log.d(TAG, "Starting CLCC response timeout for device: " + device); Message m = obtainMessage(CLCC_RSP_TIMEOUT); m.obj = getMatchingDevice(device); @@ -3593,11 +3593,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Handsfree phone proxy null for At+CLCC"); clccResponseNative(0, 0, 0, 0, false, "", 0, getByteAddress(device)); } - Log.d(TAG, "Exit processAtClcc()"); + if (DBG) Log.d(TAG, "Exit processAtClcc()"); } private void processAtCscs(String atString, int type, BluetoothDevice device) { - Log.d(TAG, "Enter processAtCscs()"); + if (DBG) Log.d(TAG, "Enter processAtCscs()"); log("processAtCscs - atString = "+ atString); if(mPhonebook != null) { mPhonebook.handleCscsCommand(atString, type, device); @@ -3606,11 +3606,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Phonebook handle null for At+CSCS"); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); } - Log.d(TAG, "Exit processAtCscs()"); + if (DBG) Log.d(TAG, "Exit processAtCscs()"); } private void processAtCpbs(String atString, int type, BluetoothDevice device) { - Log.d(TAG, "Enter processAtCpbs()"); + if (DBG) Log.d(TAG, "Enter processAtCpbs()"); log("processAtCpbs - atString = "+ atString); if(mPhonebook != null) { mPhonebook.handleCpbsCommand(atString, type, device); @@ -3619,11 +3619,11 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Phonebook handle null for At+CPBS"); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); } - Log.d(TAG, "Exit processAtCpbs()"); + if (DBG) Log.d(TAG, "Exit processAtCpbs()"); } private void processAtCpbr(String atString, int type, BluetoothDevice device) { - Log.d(TAG, "Enter processAtCpbr()"); + if (DBG) Log.d(TAG, "Enter processAtCpbr()"); log("processAtCpbr - atString = "+ atString); if(mPhonebook != null) { mPhonebook.handleCpbrCommand(atString, type, device); @@ -3632,7 +3632,7 @@ final class HeadsetStateMachine extends StateMachine { Log.e(TAG, "Phonebook handle null for At+CPBR"); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); } - Log.d(TAG, "Exit processAtCpbr()"); + if (DBG) Log.d(TAG, "Exit processAtCpbr()"); } /** @@ -3640,7 +3640,7 @@ final class HeadsetStateMachine extends StateMachine { * Return input.length() if not found. */ static private int findChar(char ch, String input, int fromIndex) { - Log.d(TAG, "Enter findChar()"); + if (DBG) Log.d(TAG, "Enter findChar()"); for (int i = fromIndex; i < input.length(); i++) { char c = input.charAt(i); if (c == '"') { @@ -3652,7 +3652,7 @@ final class HeadsetStateMachine extends StateMachine { return i; } } - Log.d(TAG, "Exit findChar()"); + if (DBG) Log.d(TAG, "Exit findChar()"); return input.length(); } @@ -3662,7 +3662,7 @@ final class HeadsetStateMachine extends StateMachine { * object is used. */ static private Object[] generateArgs(String input) { - Log.d(TAG, "Enter generateArgs()"); + if (DBG) Log.d(TAG, "Enter generateArgs()"); int i = 0; int j; ArrayList<Object> out = new ArrayList<Object>(); @@ -3678,7 +3678,7 @@ final class HeadsetStateMachine extends StateMachine { i = j + 1; // move past comma } - Log.d(TAG, "Exit generateArgs()"); + if (DBG) Log.d(TAG, "Exit generateArgs()"); return out.toArray(); } @@ -3688,7 +3688,7 @@ final class HeadsetStateMachine extends StateMachine { * Otherwise a String object is used. */ static private Object[] generateArgsBiev(String input) { - Log.d(TAG, "Enter generateArgsBiev()"); + if (DBG) Log.d(TAG, "Enter generateArgsBiev()"); int i = 0; int j; ArrayList<Object> out = new ArrayList<Object>(); @@ -3706,7 +3706,7 @@ final class HeadsetStateMachine extends StateMachine { i = j + 1; // move past comma } - Log.d(TAG, "Exit generateArgsBiev()"); + if (DBG) Log.d(TAG, "Exit generateArgsBiev()"); return out.toArray(); } @@ -3714,7 +3714,7 @@ final class HeadsetStateMachine extends StateMachine { * @return {@code true} if the given string is a valid vendor-specific AT command. */ private boolean processVendorSpecificAt(String atString) { - Log.d(TAG, "Enter processVendorSpecificAt()"); + if (DBG) Log.d(TAG, "Enter processVendorSpecificAt()"); log("processVendorSpecificAt - atString = " + atString); // Currently we accept only SET type commands. @@ -3744,12 +3744,12 @@ final class HeadsetStateMachine extends StateMachine { args, mCurrentDevice); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_OK, 0, getByteAddress(mCurrentDevice)); - Log.d(TAG, "Exit processVendorSpecificAt()"); + if (DBG) Log.d(TAG, "Exit processVendorSpecificAt()"); return true; } private void processUnknownAt(String atString, BluetoothDevice device) { - Log.d(TAG, "Enter processUnknownAt()"); + if (DBG) Log.d(TAG, "Enter processUnknownAt()"); if(device == null) { Log.w(TAG, "processUnknownAt device is null"); return; @@ -3767,11 +3767,11 @@ final class HeadsetStateMachine extends StateMachine { processAtCpbr(atCommand.substring(5), commandType, device); else if (!processVendorSpecificAt(atCommand)) atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); - Log.d(TAG, "Exit processUnknownAt()"); + if (DBG) Log.d(TAG, "Exit processUnknownAt()"); } private void processKeyPressed(BluetoothDevice device) { - Log.d(TAG, "Enter processKeyPressed()"); + if (DBG) Log.d(TAG, "Enter processKeyPressed()"); if(device == null) { Log.w(TAG, "processKeyPressed device is null"); return; @@ -3815,16 +3815,16 @@ final class HeadsetStateMachine extends StateMachine { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mService.startActivity(intent); } - Log.d(TAG, "Exit processKeyPressed()"); + if (DBG) Log.d(TAG, "Exit processKeyPressed()"); } private void processAtBind(String hf_ind, int type, BluetoothDevice device) { - Log.d(TAG, "Enter processAtBind()"); + if (DBG) Log.d(TAG, "Enter processAtBind()"); if(device == null) { Log.w(TAG, "processAtBind device is null"); return; } - Log.d(TAG, "processAtBind for device:" + device + "type = " + type); + if (DBG) Log.d(TAG, "processAtBind for device:" + device + "type = " + type); // find the current enable/diable status from app and update to stack. // loop through list of hf indicators AG supports if (type == 1) { @@ -3835,7 +3835,7 @@ final class HeadsetStateMachine extends StateMachine { } atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_OK, 0, getByteAddress(device)); } else if (type == 0) { - Log.d(TAG, "hf_ind " + hf_ind); + if (DBG) Log.d(TAG, "hf_ind " + hf_ind); Object[] args = generateArgs(hf_ind); for (int i = 0; i < args.length; i++) { mHfIndicatorHfList.add((int)args[i]); @@ -3854,15 +3854,15 @@ final class HeadsetStateMachine extends StateMachine { } sb.replace(sb.length() - 1, sb.length(), ")"); result = sb.toString(); - Log.d(TAG, "AG list of HF ind = " + result); + if (DBG) Log.d(TAG, "AG list of HF ind = " + result); bindStringResponseNative(result, getByteAddress(device)); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_OK, 0, getByteAddress(device)); } - Log.d(TAG, "Exit processAtBind()"); + if (DBG) Log.d(TAG, "Exit processAtBind()"); } private void processAtBiev(String hf_ind_value, BluetoothDevice device) { - Log.d(TAG, "Enter processAtBiev()"); + if (DBG) Log.d(TAG, "Enter processAtBiev()"); boolean found = false; int anum; long value; @@ -3874,7 +3874,7 @@ final class HeadsetStateMachine extends StateMachine { Object[] args = generateArgsBiev(hf_ind_value); anum = (int)args[0]; value = (long)args[1]; - Log.d(TAG, "processAtBiev for device:" + device + " anum = " + anum + " value = " + value); + if (DBG) Log.d(TAG, "processAtBiev for device:" + device + " anum = " + anum + " value = " + value); for (Iterator<Pair<Integer, Boolean>> iter = mHfIndicatorAgList.iterator(); iter.hasNext(); ) { Pair<Integer, Boolean> entry = iter.next(); @@ -3901,177 +3901,177 @@ final class HeadsetStateMachine extends StateMachine { Log.w(TAG, "assigned num " + anum + " not present in AG list"); atResponseCodeNative(HeadsetHalConstants.AT_RESPONSE_ERROR, 0, getByteAddress(device)); } - Log.d(TAG, "Exit processAtBiev()"); + if (DBG) Log.d(TAG, "Exit processAtBiev()"); } private void onConnectionStateChanged(int state, byte[] address) { - Log.d(TAG, "Enter onConnectionStateChanged()"); + if (DBG) Log.d(TAG, "Enter onConnectionStateChanged()"); StackEvent event = new StackEvent(EVENT_TYPE_CONNECTION_STATE_CHANGED); event.valueInt = state; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onConnectionStateChanged()"); + if (DBG) Log.d(TAG, "Exit onConnectionStateChanged()"); } private void onAudioStateChanged(int state, byte[] address) { - Log.d(TAG, "Enter onAudioStateChanged()"); + if (DBG) Log.d(TAG, "Enter onAudioStateChanged()"); StackEvent event = new StackEvent(EVENT_TYPE_AUDIO_STATE_CHANGED); event.valueInt = state; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAudioStateChanged()"); + if (DBG) Log.d(TAG, "Exit onAudioStateChanged()"); } private void onVrStateChanged(int state, byte[] address) { - Log.d(TAG, "Enter onVrStateChanged()"); + if (DBG) Log.d(TAG, "Enter onVrStateChanged()"); StackEvent event = new StackEvent(EVENT_TYPE_VR_STATE_CHANGED); event.valueInt = state; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onVrStateChanged()"); + if (DBG) Log.d(TAG, "Exit onVrStateChanged()"); } private void onAnswerCall(byte[] address) { - Log.d(TAG, "Enter onAnswerCall()"); + if (DBG) Log.d(TAG, "Enter onAnswerCall()"); StackEvent event = new StackEvent(EVENT_TYPE_ANSWER_CALL); event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAnswerCall()"); + if (DBG) Log.d(TAG, "Exit onAnswerCall()"); } private void onHangupCall(byte[] address) { - Log.d(TAG, "Enter onHangupCall()"); + if (DBG) Log.d(TAG, "Enter onHangupCall()"); StackEvent event = new StackEvent(EVENT_TYPE_HANGUP_CALL); event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onHangupCall()"); + if (DBG) Log.d(TAG, "Exit onHangupCall()"); } private void onVolumeChanged(int type, int volume, byte[] address) { - Log.d(TAG, "Enter onVolumeChanged()"); + if (DBG) Log.d(TAG, "Enter onVolumeChanged()"); StackEvent event = new StackEvent(EVENT_TYPE_VOLUME_CHANGED); event.valueInt = type; event.valueInt2 = volume; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onVolumeChanged()"); + if (DBG) Log.d(TAG, "Exit onVolumeChanged()"); } private void onDialCall(String number, byte[] address) { - Log.d(TAG, "Enter onDialCall()"); + if (DBG) Log.d(TAG, "Enter onDialCall()"); StackEvent event = new StackEvent(EVENT_TYPE_DIAL_CALL); event.valueString = number; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onDialCall()"); + if (DBG) Log.d(TAG, "Exit onDialCall()"); } private void onSendDtmf(int dtmf, byte[] address) { - Log.d(TAG, "Enter onSendDtmf()"); + if (DBG) Log.d(TAG, "Enter onSendDtmf()"); StackEvent event = new StackEvent(EVENT_TYPE_SEND_DTMF); event.valueInt = dtmf; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onSendDtmf()"); + if (DBG) Log.d(TAG, "Exit onSendDtmf()"); } private void onNoiceReductionEnable(boolean enable, byte[] address) { - Log.d(TAG, "Enter onNoiceReductionEnable()"); + if (DBG) Log.d(TAG, "Enter onNoiceReductionEnable()"); StackEvent event = new StackEvent(EVENT_TYPE_NOICE_REDUCTION); event.valueInt = enable ? 1 : 0; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onNoiceReductionEnable()"); + if (DBG) Log.d(TAG, "Exit onNoiceReductionEnable()"); } private void onWBS(int codec, byte[] address) { - Log.d(TAG, "Enter onWBS()"); + if (DBG) Log.d(TAG, "Enter onWBS()"); StackEvent event = new StackEvent(EVENT_TYPE_WBS); event.valueInt = codec; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onWBS()"); + if (DBG) Log.d(TAG, "Exit onWBS()"); } private void onAtChld(int chld, byte[] address) { - Log.d(TAG, "Enter onAtChld()"); + if (DBG) Log.d(TAG, "Enter onAtChld()"); StackEvent event = new StackEvent(EVENT_TYPE_AT_CHLD); event.valueInt = chld; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAtChld()"); + if (DBG) Log.d(TAG, "Exit onAtChld()"); } private void onAtCnum(byte[] address) { - Log.d(TAG, "Enter onAtCnum()"); + if (DBG) Log.d(TAG, "Enter onAtCnum()"); StackEvent event = new StackEvent(EVENT_TYPE_SUBSCRIBER_NUMBER_REQUEST); event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAtCnum()"); + if (DBG) Log.d(TAG, "Exit onAtCnum()"); } private void onAtCind(byte[] address) { - Log.d(TAG, "Enter onAtCind()"); + if (DBG) Log.d(TAG, "Enter onAtCind()"); StackEvent event = new StackEvent(EVENT_TYPE_AT_CIND); event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAtCind()"); + if (DBG) Log.d(TAG, "Exit onAtCind()"); } private void onAtCops(byte[] address) { - Log.d(TAG, "Enter onAtCops()"); + if (DBG) Log.d(TAG, "Enter onAtCops()"); StackEvent event = new StackEvent(EVENT_TYPE_AT_COPS); event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAtCops()"); + if (DBG) Log.d(TAG, "Exit onAtCops()"); } private void onAtClcc(byte[] address) { - Log.d(TAG, "Enter onAtClcc()"); + if (DBG) Log.d(TAG, "Enter onAtClcc()"); StackEvent event = new StackEvent(EVENT_TYPE_AT_CLCC); event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAtClcc()"); + if (DBG) Log.d(TAG, "Exit onAtClcc()"); } private void onUnknownAt(String atString, byte[] address) { - Log.d(TAG, "Enter onUnknownAt()"); + if (DBG) Log.d(TAG, "Enter onUnknownAt()"); StackEvent event = new StackEvent(EVENT_TYPE_UNKNOWN_AT); event.valueString = atString; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onUnknownAt()"); + if (DBG) Log.d(TAG, "Exit onUnknownAt()"); } private void onKeyPressed(byte[] address) { - Log.d(TAG, "Enter onKeyPressed()"); + if (DBG) Log.d(TAG, "Enter onKeyPressed()"); StackEvent event = new StackEvent(EVENT_TYPE_KEY_PRESSED); event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onKeyPressed()"); + if (DBG) Log.d(TAG, "Exit onKeyPressed()"); } private void onAtBind(String hf_ind, int type, byte[] address) { - Log.d(TAG, "Enter onAtBind()"); + if (DBG) Log.d(TAG, "Enter onAtBind()"); StackEvent event = new StackEvent(EVENT_TYPE_AT_BIND); event.valueString = hf_ind; event.valueInt = type; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAtBind()"); + if (DBG) Log.d(TAG, "Exit onAtBind()"); } private void onAtBiev(String hf_ind_val, byte[] address) { - Log.d(TAG, "Enter onAtBiev()"); + if (DBG) Log.d(TAG, "Enter onAtBiev()"); StackEvent event = new StackEvent(EVENT_TYPE_AT_BIEV); event.valueString= hf_ind_val; event.device = getDevice(address); sendMessage(STACK_EVENT, event); - Log.d(TAG, "Exit onAtBiev()"); + if (DBG) Log.d(TAG, "Exit onAtBiev()"); } private void processIntentBatteryChanged(Intent intent) { - Log.d(TAG, "Enter processIntentBatteryChanged()"); + if (DBG) Log.d(TAG, "Enter processIntentBatteryChanged()"); int batteryLevel = intent.getIntExtra("level", -1); int scale = intent.getIntExtra("scale", -1); if (batteryLevel == -1 || scale == -1 || scale == 0) { @@ -4080,18 +4080,18 @@ final class HeadsetStateMachine extends StateMachine { } batteryLevel = batteryLevel * 5 / scale; mPhoneState.setBatteryCharge(batteryLevel); - Log.d(TAG, "Exit processIntentBatteryChanged()"); + if (DBG) Log.d(TAG, "Exit processIntentBatteryChanged()"); } private void processDeviceStateChanged(HeadsetDeviceState deviceState) { - Log.d(TAG, "Enter processDeviceStateChanged()"); + if (DBG) Log.d(TAG, "Enter processDeviceStateChanged()"); notifyDeviceStatusNative(deviceState.mService, deviceState.mRoam, deviceState.mSignal, deviceState.mBatteryCharge); - Log.d(TAG, "Exit processDeviceStateChanged()"); + if (DBG) Log.d(TAG, "Exit processDeviceStateChanged()"); } private void processSendClccResponse(HeadsetClccResponse clcc) { - Log.d(TAG, "Enter processSendClccResponse()"); + if (DBG) Log.d(TAG, "Enter processSendClccResponse()"); BluetoothDevice device = getDeviceForMessage(CLCC_RSP_TIMEOUT); if (device == null) { Log.w(TAG, "device is null, not sending clcc response"); @@ -4102,21 +4102,21 @@ final class HeadsetStateMachine extends StateMachine { } clccResponseNative(clcc.mIndex, clcc.mDirection, clcc.mStatus, clcc.mMode, clcc.mMpty, clcc.mNumber, clcc.mType, getByteAddress(device)); - Log.d(TAG, "Exit processSendClccResponse()"); + if (DBG) Log.d(TAG, "Exit processSendClccResponse()"); } private void processSendVendorSpecificResultCode(HeadsetVendorSpecificResultCode resultCode) { - Log.d(TAG, "Enter processSendVendorSpecificResultCode()"); + if (DBG) Log.d(TAG, "Enter processSendVendorSpecificResultCode()"); String stringToSend = resultCode.mCommand + ": "; if (resultCode.mArg != null) { stringToSend += resultCode.mArg; } atResponseStringNative(stringToSend, getByteAddress(resultCode.mDevice)); - Log.d(TAG, "Exit processSendVendorSpecificResultCode()"); + if (DBG) Log.d(TAG, "Exit processSendVendorSpecificResultCode()"); } private String getCurrentDeviceName(BluetoothDevice device) { - Log.d(TAG, "Enter getCurrentDeviceName()"); + if (DBG) Log.d(TAG, "Enter getCurrentDeviceName()"); String defaultName = "<unknown>"; if(device == null) { @@ -4127,22 +4127,22 @@ final class HeadsetStateMachine extends StateMachine { if (deviceName == null) { return defaultName; } - Log.d(TAG, "Exit getCurrentDeviceName()"); + if (DBG) Log.d(TAG, "Exit getCurrentDeviceName()"); return deviceName; } private byte[] getByteAddress(BluetoothDevice device) { - Log.d(TAG, "getByteAddress()"); + if (DBG) Log.d(TAG, "getByteAddress()"); return Utils.getBytesFromAddress(device.getAddress()); } private BluetoothDevice getDevice(byte[] address) { - Log.d(TAG, "getDevice()"); + if (DBG) Log.d(TAG, "getDevice()"); return mAdapter.getRemoteDevice(Utils.getAddressStringFromByte(address)); } private boolean isInCall() { - Log.d(TAG, "isInCall()"); + if (DBG) Log.d(TAG, "isInCall()"); return ((mPhoneState.getNumActiveCall() > 0) || (mPhoneState.getNumHeldCall() > 0) || ((mPhoneState.getCallState() != HeadsetHalConstants.CALL_STATE_IDLE) && (mPhoneState.getCallState() != HeadsetHalConstants.CALL_STATE_INCOMING))); @@ -4151,18 +4151,18 @@ final class HeadsetStateMachine extends StateMachine { // Accept incoming SCO only when there is active call, VR activated, // active VOIP call private boolean isScoAcceptable() { - Log.d(TAG, "isScoAcceptable()"); + if (DBG) Log.d(TAG, "isScoAcceptable()"); return mAudioRouteAllowed && (mVoiceRecognitionStarted || isInCall()); } boolean isConnected() { - Log.d(TAG, "isConnected()"); + if (DBG) Log.d(TAG, "isConnected()"); IState currentState = getCurrentState(); return (currentState == mConnected || currentState == mAudioOn); } boolean okToConnect(BluetoothDevice device) { - Log.d(TAG, "Enter okToConnect()"); + if (DBG) Log.d(TAG, "Enter okToConnect()"); AdapterService adapterService = AdapterService.getAdapterService(); int priority = mService.getPriority(device); boolean ret = false; @@ -4180,12 +4180,12 @@ final class HeadsetStateMachine extends StateMachine { (device.getBondState() != BluetoothDevice.BOND_NONE))){ ret= true; } - Log.d(TAG, "Exit okToConnect()"); + if (DBG) Log.d(TAG, "Exit okToConnect()"); return ret; } private void sendVoipConnectivityNetworktype(boolean isVoipStarted) { - Log.d(TAG, "Enter sendVoipConnectivityNetworktype()"); + if (DBG) Log.d(TAG, "Enter sendVoipConnectivityNetworktype()"); NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); if (networkInfo == null || !networkInfo.isAvailable() || !networkInfo.isConnected()) { Log.e(TAG, "No connected/available connectivity network, don't update soc"); @@ -4200,7 +4200,7 @@ final class HeadsetStateMachine extends StateMachine { } else { log("Voip/VoLTE started/stopped on some other n/w, don't update to soc"); } - Log.d(TAG, "Exit sendVoipConnectivityNetworktype()"); + if (DBG) Log.d(TAG, "Exit sendVoipConnectivityNetworktype()"); } @Override @@ -4211,7 +4211,7 @@ final class HeadsetStateMachine extends StateMachine { } public void handleAccessPermissionResult(Intent intent) { - Log.d(TAG, "Enter handleAccessPermissionResult()"); + if (DBG) Log.d(TAG, "Enter handleAccessPermissionResult()"); log("handleAccessPermissionResult"); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (mPhonebook != null) { @@ -4254,7 +4254,7 @@ final class HeadsetStateMachine extends StateMachine { getByteAddress(device)); } } - Log.d(TAG, "Exit handleAccessPermissionResult()"); + if (DBG) Log.d(TAG, "Exit handleAccessPermissionResult()"); } private static final String SCHEME_TEL = "tel"; |