Fix connection problem with NFC headset devices.

This commit is contained in:
Jimmie Matsson 2019-05-02 18:20:53 +02:00
parent 9f25f43060
commit 4fbf202e86
7 changed files with 42 additions and 60 deletions

View file

@ -1,29 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View file

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

2
.idea/gradle.xml generated
View file

@ -10,9 +10,9 @@
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$/../../dixitmobile-common/library" />
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/vxt-engine" />
<option value="$PROJECT_DIR$/../../dixitmobile-common/library" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />

View file

@ -1,4 +1,4 @@
#Fri Mar 15 12:36:31 CET 2019
#Wed Jun 20 09:05:23 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

View file

@ -1,21 +1,3 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /AndroidSDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
@ -24,7 +6,14 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-assumenosideeffects class android.util.Log { *; }
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
-keep class com.nuance.android.vocalizer.** { *; }

View file

@ -46,7 +46,7 @@ public class BluetoothSCOManager extends BroadcastReceiver {
public interface SCOStatusInterface {
void connected();
void disconnected();
boolean disconnected();
}
public BluetoothSCOManager(VoiXtremeService service, VxtEngineApi engineApi) {
@ -198,7 +198,7 @@ public class BluetoothSCOManager extends BroadcastReceiver {
*/
public void stop() {
Log.i(TAG, "eml: stop()");
Log.i(TAG, "eml: SCO stop()");
if (mStarted && !mPaused) {
unregisterReceivers();
@ -610,12 +610,12 @@ public class BluetoothSCOManager extends BroadcastReceiver {
}
/**
* Helper Thread to check if we can connect to a headset or not. There might be multiple retries, therefore
* the delay and multiple checks...
* Helper Thread to check if we can connect to a headset or not.
* There might be multiple retries, therefore the delay and multiple checks...
*/
private class SCOTester extends Thread implements Runnable {
private static final int MAX_DELAY = 1000;
private static final int MAX_DELAY = 900;
@Override
public void run() {
@ -644,7 +644,9 @@ public class BluetoothSCOManager extends BroadcastReceiver {
mSCOStatusCallback.connected();
} else {
BluetoothSCOManager.this.stop();
mSCOStatusCallback.disconnected();
if (mSCOStatusCallback.disconnected()) {
return;
}
}
mSCOTester = null;

View file

@ -1208,6 +1208,9 @@ public class VoiXtremeService extends VoiXtremeServiceBase
setHeadsetErrorState(false);
mInputType = BroadcastParams.INPUT_TYPE_NFC;
Log.i(TAG, "eml: bt enabled: " + BluetoothAdapter.getDefaultAdapter().isEnabled());
Log.i(TAG, "eml: bonded dev: " + BluetoothAdapter.getDefaultAdapter().getBondedDevices().size());
if (!BluetoothAdapter.getDefaultAdapter().isEnabled()
|| BluetoothAdapter.getDefaultAdapter().getBondedDevices().isEmpty()) {
Log.v(TAG, "sendInputConnectionStatus6 - false");
@ -1240,6 +1243,10 @@ public class VoiXtremeService extends VoiXtremeServiceBase
*/
private BluetoothSCOManager.SCOStatusInterface mSCOTestCallback = new BluetoothSCOManager.SCOStatusInterface() {
private boolean secondCheck = false;
@Override
public void connected() {
@ -1249,11 +1256,19 @@ public class VoiXtremeService extends VoiXtremeServiceBase
}
@Override
public void disconnected() {
public boolean disconnected() {
Log.i(TAG, "Bluetooth SCO connected: FAIL");
Log.v(TAG, "sendInputConnectionStatus77 - false");
sendInputConnectionStatus(false);
if (mInputType == BroadcastParams.INPUT_TYPE_NFC && !secondCheck) {
secondCheck = true;
initializeInputTypeFunctionality(BroadcastParams.INPUT_TYPE_NFC);
return true;
} else {
secondCheck = false;
Log.i(TAG, "Bluetooth SCO connected: FAIL");
Log.v(TAG, "sendInputConnectionStatus77 - false");
sendInputConnectionStatus(false);
return false;
}
}
};