diff --git a/speech_to_text/android/src/main/AndroidManifest.xml b/speech_to_text/android/src/main/AndroidManifest.xml
index 61a73f32..b0454e69 100644
--- a/speech_to_text/android/src/main/AndroidManifest.xml
+++ b/speech_to_text/android/src/main/AndroidManifest.xml
@@ -1,3 +1,5 @@
+
+
diff --git a/speech_to_text/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt b/speech_to_text/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt
index c2bab69e..83495c60 100644
--- a/speech_to_text/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt
+++ b/speech_to_text/android/src/main/kotlin/com/csdcorp/speech_to_text/SpeechToTextPlugin.kt
@@ -99,6 +99,7 @@ public class SpeechToTextPlugin :
private var debugLogging: Boolean = false
private var alwaysUseStop: Boolean = false
private var intentLookup: Boolean = false
+ private var noBluetooth: Boolean = false
private var resultSent: Boolean = false
private var speechRecognizer: SpeechRecognizer? = null
private var recognizerIntent: Intent? = null
@@ -188,6 +189,10 @@ public class SpeechToTextPlugin :
if (null != iOpt) {
intentLookup = iOpt == true
}
+ var noBtOpt = call.argument("noBluetooth")
+ if (null != noBtOpt) {
+ noBluetooth = noBtOpt == true
+ }
initialize(result)
}
"listen" -> {
@@ -301,6 +306,7 @@ public class SpeechToTextPlugin :
}
private fun optionallyStartBluetooth() {
+ if ( noBluetooth ) return
val lbt = bluetoothAdapter
val lpaired = pairedDevices
val lhead = bluetoothHeadset
@@ -391,6 +397,7 @@ public class SpeechToTextPlugin :
}
private fun optionallyStopBluetooth() {
+ if ( noBluetooth ) return
val lactive = activeBluetooth
val lbt = bluetoothHeadset
if (null != lactive && null != lbt ) {
@@ -454,8 +461,13 @@ public class SpeechToTextPlugin :
val localActivity = currentActivity
if (null != localActivity) {
debugLog("Requesting permission")
+ var requiredPermissions = arrayOf(Manifest.permission.RECORD_AUDIO)
+ if ( !noBluetooth ) {
+ requiredPermissions = requiredPermissions.plus(Manifest.permission.BLUETOOTH_CONNECT)
+ }
+
ActivityCompat.requestPermissions(localActivity,
- arrayOf(Manifest.permission.RECORD_AUDIO, Manifest.permission.BLUETOOTH_CONNECT), speechToTextPermissionCode)
+ requiredPermissions, speechToTextPermissionCode)
} else {
debugLog("no permission, no activity, completing")
completeInitialize()
@@ -502,6 +514,7 @@ public class SpeechToTextPlugin :
}
private fun setupBluetooth() {
+ if ( noBluetooth ) return
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
pairedDevices = bluetoothAdapter?.getBondedDevices()
diff --git a/speech_to_text/lib/speech_to_text.dart b/speech_to_text/lib/speech_to_text.dart
index f38d2441..cae76a3d 100644
--- a/speech_to_text/lib/speech_to_text.dart
+++ b/speech_to_text/lib/speech_to_text.dart
@@ -114,15 +114,36 @@ class SpeechToText {
SpeechConfigOption('android', 'alwaysUseStop', true);
static final SpeechConfigOption androidIntentLookup =
SpeechConfigOption('android', 'intentLookup', true);
+ static final SpeechConfigOption androidNoBluetooth =
+ SpeechConfigOption('android', 'noBluetooth', true);
+ static final SpeechConfigOption iosNoBluetooth =
+ SpeechConfigOption('ios', 'noBluetooth', true);
static final SpeechToText _instance = SpeechToText.withMethodChannel();
bool _initWorked = false;
+
+ /// True when any words have been recognized during the current listen session.
bool _recognized = false;
+
+ /// True as soon as the platform reports it has started listening which
+ /// happens some time after the listen method is called.
bool _listening = false;
bool _cancelOnError = false;
+
+ /// True if the user has requested to cancel recognition when a permanent
+ /// error occurs.
bool _partialResults = false;
+
+ /// True when the results callback has already been called with a
+ /// final result.
bool _notifiedFinal = false;
+
+ /// True when the internal status callback has been called with the
+ /// done status. Note that this does not mean the user callback has
+ /// been called since that is only called after the final result has been
+ /// seen.
bool _notifiedDone = false;
+
int _listenStartedAt = 0;
int _lastSpeechEventAt = 0;
Duration? _pauseFor;