Loading src/com/android/server/telecom/CallAudioManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -526,6 +526,13 @@ public class CallAudioManager extends CallsManagerListenerBase { pw.increaseIndent(); mCallAudioRouteStateMachine.dumpPendingMessages(pw); pw.decreaseIndent(); pw.println("BluetoothDeviceManager:"); pw.increaseIndent(); if (mBluetoothStateReceiver.getBluetoothDeviceManager() != null) { mBluetoothStateReceiver.getBluetoothDeviceManager().dump(pw); } pw.decreaseIndent(); } @VisibleForTesting Loading src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +26 −11 Original line number Diff line number Diff line Loading @@ -22,7 +22,9 @@ import android.bluetooth.BluetoothHearingAid; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.telecom.Log; import android.util.LocalLog; import com.android.internal.util.IndentingPrintWriter; import com.android.server.telecom.BluetoothAdapterProxy; import com.android.server.telecom.BluetoothHeadsetProxy; Loading @@ -43,18 +45,21 @@ public class BluetoothDeviceManager { Log.startSession("BMSL.oSC"); try { synchronized (mLock) { String logString; if (profile == BluetoothProfile.HEADSET) { mBluetoothHeadsetService = new BluetoothHeadsetProxy((BluetoothHeadset) proxy); Log.i(this, "- Got BluetoothHeadset: " + mBluetoothHeadsetService); logString = "Got BluetoothHeadset: " + mBluetoothHeadsetService; } else if (profile == BluetoothProfile.HEARING_AID) { mBluetoothHearingAidService = (BluetoothHearingAid) proxy; Log.i(this, "- Got BluetoothHearingAid: " + mBluetoothHearingAidService); logString = "Got BluetoothHearingAid: " + mBluetoothHearingAidService; } else { Log.w(this, "Connected to non-requested bluetooth service." + " Not changing bluetooth headset."); logString = "Connected to non-requested bluetooth service." + " Not changing bluetooth headset."; } Log.i(BluetoothDeviceManager.this, logString); mLocalLog.log(logString); } } finally { Log.endSession(); Loading @@ -67,23 +72,25 @@ public class BluetoothDeviceManager { try { synchronized (mLock) { LinkedHashMap<String, BluetoothDevice> lostServiceDevices; String logString; if (profile == BluetoothProfile.HEADSET) { mBluetoothHeadsetService = null; Log.i(BluetoothDeviceManager.this, "Lost BluetoothHeadset service. " + "Removing all tracked devices."); lostServiceDevices = mHfpDevicesByAddress; mBluetoothRouteManager.onActiveDeviceChanged(null, false); logString = "Lost BluetoothHeadset service. " + "Removing all tracked devices"; } else if (profile == BluetoothProfile.HEARING_AID) { mBluetoothHearingAidService = null; Log.i(BluetoothDeviceManager.this, "Lost BluetoothHearingAid service. " + "Removing all tracked devices."); logString = "Lost BluetoothHearingAid service. " + "Removing all tracked devices."; lostServiceDevices = mHearingAidDevicesByAddress; mBluetoothRouteManager.onActiveDeviceChanged(null, true); } else { return; } Log.i(BluetoothDeviceManager.this, logString); mLocalLog.log(logString); List<BluetoothDevice> devicesToRemove = new LinkedList<>( lostServiceDevices.values()); lostServiceDevices.clear(); Loading @@ -103,6 +110,7 @@ public class BluetoothDeviceManager { new LinkedHashMap<>(); private final LinkedHashMap<BluetoothDevice, Long> mHearingAidDeviceSyncIds = new LinkedHashMap<>(); private final LocalLog mLocalLog = new LocalLog(20); // This lock only protects internal state -- it doesn't lock on anything going into Telecom. private final Object mLock = new Object(); Loading Loading @@ -188,6 +196,8 @@ public class BluetoothDeviceManager { } void onDeviceConnected(BluetoothDevice device, boolean isHearingAid) { mLocalLog.log("Device connected -- address: " + device.getAddress() + " isHeadingAid: " + isHearingAid); synchronized (mLock) { LinkedHashMap<String, BluetoothDevice> targetDeviceMap; if (isHearingAid) { Loading @@ -213,6 +223,8 @@ public class BluetoothDeviceManager { } void onDeviceDisconnected(BluetoothDevice device, boolean isHearingAid) { mLocalLog.log("Device disconnected -- address: " + device.getAddress() + " isHeadingAid: " + isHearingAid); synchronized (mLock) { LinkedHashMap<String, BluetoothDevice> targetDeviceMap; if (isHearingAid) { Loading Loading @@ -297,4 +309,7 @@ public class BluetoothDeviceManager { } } public void dump(IndentingPrintWriter pw) { mLocalLog.dump(pw); } } src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java +4 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,10 @@ public class BluetoothStateReceiver extends BroadcastReceiver { } } public BluetoothDeviceManager getBluetoothDeviceManager() { return mBluetoothDeviceManager; } public BluetoothStateReceiver(BluetoothDeviceManager deviceManager, BluetoothRouteManager routeManager) { mBluetoothDeviceManager = deviceManager; Loading Loading
src/com/android/server/telecom/CallAudioManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -526,6 +526,13 @@ public class CallAudioManager extends CallsManagerListenerBase { pw.increaseIndent(); mCallAudioRouteStateMachine.dumpPendingMessages(pw); pw.decreaseIndent(); pw.println("BluetoothDeviceManager:"); pw.increaseIndent(); if (mBluetoothStateReceiver.getBluetoothDeviceManager() != null) { mBluetoothStateReceiver.getBluetoothDeviceManager().dump(pw); } pw.decreaseIndent(); } @VisibleForTesting Loading
src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java +26 −11 Original line number Diff line number Diff line Loading @@ -22,7 +22,9 @@ import android.bluetooth.BluetoothHearingAid; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.telecom.Log; import android.util.LocalLog; import com.android.internal.util.IndentingPrintWriter; import com.android.server.telecom.BluetoothAdapterProxy; import com.android.server.telecom.BluetoothHeadsetProxy; Loading @@ -43,18 +45,21 @@ public class BluetoothDeviceManager { Log.startSession("BMSL.oSC"); try { synchronized (mLock) { String logString; if (profile == BluetoothProfile.HEADSET) { mBluetoothHeadsetService = new BluetoothHeadsetProxy((BluetoothHeadset) proxy); Log.i(this, "- Got BluetoothHeadset: " + mBluetoothHeadsetService); logString = "Got BluetoothHeadset: " + mBluetoothHeadsetService; } else if (profile == BluetoothProfile.HEARING_AID) { mBluetoothHearingAidService = (BluetoothHearingAid) proxy; Log.i(this, "- Got BluetoothHearingAid: " + mBluetoothHearingAidService); logString = "Got BluetoothHearingAid: " + mBluetoothHearingAidService; } else { Log.w(this, "Connected to non-requested bluetooth service." + " Not changing bluetooth headset."); logString = "Connected to non-requested bluetooth service." + " Not changing bluetooth headset."; } Log.i(BluetoothDeviceManager.this, logString); mLocalLog.log(logString); } } finally { Log.endSession(); Loading @@ -67,23 +72,25 @@ public class BluetoothDeviceManager { try { synchronized (mLock) { LinkedHashMap<String, BluetoothDevice> lostServiceDevices; String logString; if (profile == BluetoothProfile.HEADSET) { mBluetoothHeadsetService = null; Log.i(BluetoothDeviceManager.this, "Lost BluetoothHeadset service. " + "Removing all tracked devices."); lostServiceDevices = mHfpDevicesByAddress; mBluetoothRouteManager.onActiveDeviceChanged(null, false); logString = "Lost BluetoothHeadset service. " + "Removing all tracked devices"; } else if (profile == BluetoothProfile.HEARING_AID) { mBluetoothHearingAidService = null; Log.i(BluetoothDeviceManager.this, "Lost BluetoothHearingAid service. " + "Removing all tracked devices."); logString = "Lost BluetoothHearingAid service. " + "Removing all tracked devices."; lostServiceDevices = mHearingAidDevicesByAddress; mBluetoothRouteManager.onActiveDeviceChanged(null, true); } else { return; } Log.i(BluetoothDeviceManager.this, logString); mLocalLog.log(logString); List<BluetoothDevice> devicesToRemove = new LinkedList<>( lostServiceDevices.values()); lostServiceDevices.clear(); Loading @@ -103,6 +110,7 @@ public class BluetoothDeviceManager { new LinkedHashMap<>(); private final LinkedHashMap<BluetoothDevice, Long> mHearingAidDeviceSyncIds = new LinkedHashMap<>(); private final LocalLog mLocalLog = new LocalLog(20); // This lock only protects internal state -- it doesn't lock on anything going into Telecom. private final Object mLock = new Object(); Loading Loading @@ -188,6 +196,8 @@ public class BluetoothDeviceManager { } void onDeviceConnected(BluetoothDevice device, boolean isHearingAid) { mLocalLog.log("Device connected -- address: " + device.getAddress() + " isHeadingAid: " + isHearingAid); synchronized (mLock) { LinkedHashMap<String, BluetoothDevice> targetDeviceMap; if (isHearingAid) { Loading @@ -213,6 +223,8 @@ public class BluetoothDeviceManager { } void onDeviceDisconnected(BluetoothDevice device, boolean isHearingAid) { mLocalLog.log("Device disconnected -- address: " + device.getAddress() + " isHeadingAid: " + isHearingAid); synchronized (mLock) { LinkedHashMap<String, BluetoothDevice> targetDeviceMap; if (isHearingAid) { Loading Loading @@ -297,4 +309,7 @@ public class BluetoothDeviceManager { } } public void dump(IndentingPrintWriter pw) { mLocalLog.dump(pw); } }
src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java +4 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,10 @@ public class BluetoothStateReceiver extends BroadcastReceiver { } } public BluetoothDeviceManager getBluetoothDeviceManager() { return mBluetoothDeviceManager; } public BluetoothStateReceiver(BluetoothDeviceManager deviceManager, BluetoothRouteManager routeManager) { mBluetoothDeviceManager = deviceManager; Loading