forked from upstream-mirrors/OpenTracks
Fix BluetoothConnectionManager by using the public api
to create an insecure connection.
This commit is contained in:
+2
-15
@@ -30,8 +30,6 @@ import android.util.Log;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -262,19 +260,8 @@ public class BluetoothConnectionManager {
|
|||||||
|
|
||||||
private BluetoothSocket getSocket() throws IOException {
|
private BluetoothSocket getSocket() throws IOException {
|
||||||
try {
|
try {
|
||||||
Class<? extends BluetoothDevice> c = device.getClass();
|
return device.createInsecureRfcommSocketToServiceRecord(SPP_UUID);
|
||||||
Method insecure = c.getMethod("createInsecureRfcommSocketToServiceRecord", UUID.class);
|
} catch (IOException e) {
|
||||||
insecure.setAccessible(true);
|
|
||||||
return (BluetoothSocket) insecure.invoke(device, SPP_UUID);
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
Log.e(Constants.TAG, "Unable to get insecure connect.", e);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
Log.e(Constants.TAG, "Unable to get insecure connect.", e);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Log.e(Constants.TAG, "Unable to get insecure connect.", e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
Log.e(Constants.TAG, "Unable to get insecure connect.", e);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
Log.e(Constants.TAG, "Unable to get insecure connect.", e);
|
Log.e(Constants.TAG, "Unable to get insecure connect.", e);
|
||||||
}
|
}
|
||||||
return device.createRfcommSocketToServiceRecord(SPP_UUID);
|
return device.createRfcommSocketToServiceRecord(SPP_UUID);
|
||||||
|
|||||||
Reference in New Issue
Block a user