diff options
-rw-r--r-- | android/app/src/com/android/bluetooth/hfp/BluetoothHeadsetProxy.java | 12 | ||||
-rw-r--r-- | android/app/src/com/android/bluetooth/telephony/BluetoothInCallService.java | 17 |
2 files changed, 28 insertions, 1 deletions
diff --git a/android/app/src/com/android/bluetooth/hfp/BluetoothHeadsetProxy.java b/android/app/src/com/android/bluetooth/hfp/BluetoothHeadsetProxy.java index 824955d5a4..429ee7d0b8 100644 --- a/android/app/src/com/android/bluetooth/hfp/BluetoothHeadsetProxy.java +++ b/android/app/src/com/android/bluetooth/hfp/BluetoothHeadsetProxy.java @@ -16,8 +16,12 @@ package com.android.bluetooth.hfp; +import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; +import android.bluetooth.BluetoothManager; +import android.bluetooth.BluetoothProfile; +import android.content.Context; import java.util.List; @@ -36,6 +40,14 @@ public class BluetoothHeadsetProxy { mBluetoothHeadset = headset; } + public void closeBluetoothHeadsetProxy(Context context) { + final BluetoothManager btManager = + context.getSystemService(BluetoothManager.class); + if (btManager != null) { + btManager.getAdapter().closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset); + } + } + public void clccResponse(int index, int direction, int status, int mode, boolean mpty, String number, int type) { diff --git a/android/app/src/com/android/bluetooth/telephony/BluetoothInCallService.java b/android/app/src/com/android/bluetooth/telephony/BluetoothInCallService.java index dacfa069a5..5ca6397798 100644 --- a/android/app/src/com/android/bluetooth/telephony/BluetoothInCallService.java +++ b/android/app/src/com/android/bluetooth/telephony/BluetoothInCallService.java @@ -170,6 +170,8 @@ public class BluetoothInCallService extends InCallService { Log.d(TAG, "Bluetooth Adapter state: " + state); if (state == BluetoothAdapter.STATE_ON) { queryPhoneState(); + } else if (state == BluetoothAdapter.STATE_TURNING_OFF) { + clear(); } } } @@ -620,6 +622,12 @@ public class BluetoothInCallService extends InCallService { @Override public void onDestroy() { Log.d(TAG, "onDestroy"); + clear(); + super.onDestroy(); + } + + private void clear() { + Log.d(TAG, "clear"); if (mBluetoothOnModeChangedListener != null) { mAudioManager.removeOnModeChangedListener(mBluetoothOnModeChangedListener); mBluetoothOnModeChangedListener = null; @@ -628,8 +636,15 @@ public class BluetoothInCallService extends InCallService { unregisterReceiver(mBluetoothAdapterReceiver); mBluetoothAdapterReceiver = null; } + if (mBluetoothHeadset != null) { + mBluetoothHeadset.closeBluetoothHeadsetProxy(this); + mBluetoothHeadset = null; + } + mProfileListener = null; sInstance = null; - super.onDestroy(); + mCallbacks.clear(); + mBluetoothCallHashMap.clear(); + mClccIndexMap.clear(); } private void sendListOfCalls(boolean shouldLog) { |