diff options
author | Diogo Ferreira <defer@cyngn.com> | 2016-09-08 10:56:47 +0100 |
---|---|---|
committer | Michael Bestas <mikeioannina@cyanogenmod.org> | 2016-09-08 05:41:52 -0700 |
commit | 2e5f3ba8423603ec1b71fb0e471df7a8ad2a4d66 (patch) | |
tree | aa3e23da53a83f59e713a80f262b8e6f0bc7f43f | |
parent | 2a7a6adcace74d76e51dc559a2c36f0834615ed4 (diff) | |
download | android_packages_apps_SoundRecorder-2e5f3ba8423603ec1b71fb0e471df7a8ad2a4d66.tar.gz android_packages_apps_SoundRecorder-2e5f3ba8423603ec1b71fb0e471df7a8ad2a4d66.tar.bz2 android_packages_apps_SoundRecorder-2e5f3ba8423603ec1b71fb0e471df7a8ad2a4d66.zip |
SoundRecorder: Only attempt bluetooth recording if an adapter is present
Having a bluetooth adapter is not a required feature and the app will
crash if one is not present.
Change-Id: Ia1a91a2aa44acb6290e6e158c70542e68b0490b8
(cherry picked from commit 29c110f23fb2140c73765a2fa55fd2403d4afb66)
-rw-r--r-- | src/com/android/soundrecorder/SoundRecorder.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/com/android/soundrecorder/SoundRecorder.java b/src/com/android/soundrecorder/SoundRecorder.java index a3be032..aae95ed 100644 --- a/src/com/android/soundrecorder/SoundRecorder.java +++ b/src/com/android/soundrecorder/SoundRecorder.java @@ -502,14 +502,16 @@ public class SoundRecorder extends Activity if (BLUETOOTH_RECORDING_ENABLED) { mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - mBluetoothAdapter.getProfileProxy(this, mProfileListener, BluetoothProfile.HEADSET); - registerReceiver(new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - onBluetoothScoStateChanged( - intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1)); - } - }, new IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED)); + if (mBluetoothAdapter != null) { + mBluetoothAdapter.getProfileProxy(this, mProfileListener, BluetoothProfile.HEADSET); + registerReceiver(new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + onBluetoothScoStateChanged( + intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1)); + } + }, new IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED)); + } } View menuButton = findViewById(R.id.menu_button); @@ -560,7 +562,7 @@ public class SoundRecorder extends Activity mRecorder.stopPlayback(); break; case START_RECORDING: - if (BLUETOOTH_RECORDING_ENABLED) { + if (BLUETOOTH_RECORDING_ENABLED && mBluetoothAdapter != null) { if (mAudioSourceType == MediaRecorder.AudioSource.MIC && startBluetoothSco()) { // We just started an async bluetooth connection request |