diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2020-05-01 15:00:00 -0700 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2020-05-01 15:39:47 -0700 |
commit | 443a70307a38a08d29aab75858dd29bf97e8cedf (patch) | |
tree | 8359db26445c8830d9f9338909a8d8e9b8e3a842 /framework/java/android/bluetooth/BluetoothProfileConnector.java | |
parent | 54846525c509a2d638e059095b12e64accc5b163 (diff) |
BluetoothProfileConnecter now calls the ServiceListener's
onServiceDisconnected method after unbinding the service
Bug: 155120232
Test: atest BluetoothHostTest#testMapClose
Change-Id: I324b4ea6654261eb67d5ec184f6b3456ba3d1aa4
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothProfileConnector.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothProfileConnector.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/framework/java/android/bluetooth/BluetoothProfileConnector.java b/framework/java/android/bluetooth/BluetoothProfileConnector.java index 863fd3698c..040f58ae48 100644 --- a/framework/java/android/bluetooth/BluetoothProfileConnector.java +++ b/framework/java/android/bluetooth/BluetoothProfileConnector.java @@ -103,14 +103,21 @@ public abstract class BluetoothProfileConnector<T> { private void doUnbind() { synchronized (mConnection) { - if (mService != null) { - logDebug("Unbinding service..."); - try { - mContext.unbindService(mConnection); - } catch (IllegalArgumentException ie) { - logError("Unable to unbind service: " + ie); - } finally { - mService = null; + try { + if (mService != null) { + logDebug("Unbinding service..."); + try { + mContext.unbindService(mConnection); + } catch (IllegalArgumentException ie) { + logError("Unable to unbind service: " + ie); + } finally { + mService = null; + } + } + } finally { + if (mServiceListener != null) { + mServiceListener.onServiceDisconnected(mProfileId); + mServiceListener = null; } } } @@ -131,7 +138,6 @@ public abstract class BluetoothProfileConnector<T> { } void disconnect() { - mServiceListener = null; IBluetoothManager mgr = BluetoothAdapter.getDefaultAdapter().getBluetoothManager(); if (mgr != null) { try { |