[Libreoffice-commits] .: android/sdremote

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Sep 3 03:45:04 PDT 2012


 android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java |   55 ++--------
 1 file changed, 12 insertions(+), 43 deletions(-)

New commits:
commit cb6d2ed236bd8907d135ca6c292553fb4691f6d4
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Mon Sep 3 12:43:58 2012 +0200

    Repeat bluetooth discovery periodically.
    
    Change-Id: I2cccc3118a06b2202a249ae8ed116d2c3bc85395

diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
index b001d1a..dedce23 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothFinder.java
@@ -11,6 +11,7 @@ import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.os.Handler;
 import android.support.v4.content.LocalBroadcastManager;
 
 public class BluetoothFinder {
@@ -18,8 +19,6 @@ public class BluetoothFinder {
     // TODO: add removal of cached items
     private Context mContext;
 
-    private static final String CHARSET = "UTF-8";
-
     BluetoothAdapter mAdapter;
 
     public BluetoothFinder(Context aContext) {
@@ -64,8 +63,6 @@ public class BluetoothFinder {
         @Override
         public void onReceive(Context context, Intent aIntent) {
             // TODO Auto-generated method stub
-            System.out.print("Received intent<<<");
-            System.out.println(aIntent.getAction());
             if (aIntent.getAction().equals(BluetoothDevice.ACTION_FOUND)) {
                 BluetoothDevice aDevice = (BluetoothDevice) aIntent.getExtras()
                                 .get(BluetoothDevice.EXTRA_DEVICE);
@@ -79,45 +76,17 @@ public class BluetoothFinder {
                                 CommunicationService.MSG_SERVERLIST_CHANGED);
                 LocalBroadcastManager.getInstance(mContext).sendBroadcast(
                                 aNIntent);
-                //                System.out.println("Found " + aDevice.getName());
-                //                try {
-                //                    // "f36d0a20-e876-11e1-aff1-0800200c9a66"
-                //                    BluetoothSocket aSocket = aDevice
-                //                                    .createRfcommSocketToServiceRecord(UUID
-                //                                                    .fromString("00001101-0000-1000-8000-00805F9B34FB"));
-                //                    aSocket.connect();
-                //                } catch (IOException e) {
-                //                    // TODO Auto-generated catch block
-                //                    e.printStackTrace();
-                //                    System.out.println("Fallback");
-                //                    Method m;
-                //                    try {
-                //                        m = aDevice.getClass().getMethod("createRfcommSocket",
-                //                                        new Class[] { int.class });
-                //                        BluetoothSocket aFSocket = (BluetoothSocket) m.invoke(
-                //                                        aDevice, 1);
-                //
-                //                        mAdapter.cancelDiscovery();
-                //                        aFSocket.connect();
-                //                    } catch (NoSuchMethodException e1) {
-                //                        // TODO Auto-generated catch block
-                //                        e1.printStackTrace();
-                //                    } catch (IllegalArgumentException e1) {
-                //                        // TODO Auto-generated catch block
-                //                        e1.printStackTrace();
-                //                    } catch (IllegalAccessException e1) {
-                //                        // TODO Auto-generated catch block
-                //                        e1.printStackTrace();
-                //                    } catch (InvocationTargetException e1) {
-                //                        // TODO Auto-generated catch block
-                //                        e1.printStackTrace();
-                //                    } catch (IOException e1) {
-                //                        // TODO Auto-generated catch block
-                //                        e1.printStackTrace();
-                //                    }
-                //                    System.out.println("Fallback complete");
-                //
-                //                }
+            } else if (aIntent.getAction().equals(
+                            BluetoothAdapter.ACTION_DISCOVERY_FINISHED)) {
+                // Start discovery again after a small delay.
+                Handler aHandler = new Handler();
+                aHandler.postDelayed(new Runnable() {
+                    @Override
+                    public void run() {
+                        mAdapter.startDiscovery();
+                    }
+                }, 1000 * 15);
+                ;
             }
 
         }


More information about the Libreoffice-commits mailing list