From 06088b807b0b0e5cfab51ed8e5d6f31150f9fc29 Mon Sep 17 00:00:00 2001 From: Jimmy Shih Date: Mon, 10 Oct 2011 17:12:17 -0700 Subject: [PATCH] Fix BluetoothConnectionManager by using the public api to create an insecure connection. --- .../sensors/BluetoothConnectionManager.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java index 2f1b90fea..082e8e0d1 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java @@ -30,8 +30,6 @@ import android.util.Log; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.UUID; /** @@ -262,19 +260,8 @@ public class BluetoothConnectionManager { private BluetoothSocket getSocket() throws IOException { try { - Class c = device.getClass(); - Method insecure = c.getMethod("createInsecureRfcommSocketToServiceRecord", UUID.class); - 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) { + return device.createInsecureRfcommSocketToServiceRecord(SPP_UUID); + } catch (IOException e) { Log.e(Constants.TAG, "Unable to get insecure connect.", e); } return device.createRfcommSocketToServiceRecord(SPP_UUID);