Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3366

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/66/3366/1

fdo#61873 add WiFi experimental feature alert.

fixes reconnect crash. Won't crash when server-end disconnect.

seperate Client construction and initialization so that Client() will release its mutex lock and 
won't block service.run(). Otherwise onBackPressed() will be blocked in PairingActivity

Change-Id: I424a470aa02b0c74b28cb9f9ba79489aa0d4ab1b
---
M android/sdremote/AndroidManifest.xml
M android/sdremote/res/layout/activity_reconnect.xml
M android/sdremote/res/layout/dialog_addserver.xml
M android/sdremote/res/values/strings.xml
M android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java
M android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
M android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java
M android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
M android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
M android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
M android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
M android/sdremote/src/org/libreoffice/impressremote/communication/ReconnectionActivity.java
M android/sdremote/src/org/libreoffice/impressremote/communication/Server.java
13 files changed, 362 insertions(+), 102 deletions(-)



diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml
index d279fbb..8eaf63d 100644
--- a/android/sdremote/AndroidManifest.xml
+++ b/android/sdremote/AndroidManifest.xml
@@ -57,6 +57,11 @@
             android:icon="@drawable/icon_options"
             android:label="@string/options" >
         </activity>
+        <activity
+            android:name=".communication.ReconnectionActivity"
+            android:logo="@drawable/actionbar_icon_computer"
+            android:label="@string/reconnect" >
+        </activity>
     </application>
 
 </manifest>
diff --git a/android/sdremote/res/layout/activity_reconnect.xml 
b/android/sdremote/res/layout/activity_reconnect.xml
index 8baa76d..0d2f8bb 100644
--- a/android/sdremote/res/layout/activity_reconnect.xml
+++ b/android/sdremote/res/layout/activity_reconnect.xml
@@ -40,7 +40,17 @@
             android:gravity="center_horizontal"
             android:text="@string/reconnect_description2"
             android:textAppearance="?android:attr/textAppearanceMedium" />
+        
+        <TextView
+            android:id="@+id/countDownTV"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginLeft="10dp"
+            android:layout_marginRight="10dp"
+            android:gravity="center_horizontal"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
 
     </LinearLayout>
 
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
diff --git a/android/sdremote/res/layout/dialog_addserver.xml 
b/android/sdremote/res/layout/dialog_addserver.xml
index 01ddba2..fdb984b 100644
--- a/android/sdremote/res/layout/dialog_addserver.xml
+++ b/android/sdremote/res/layout/dialog_addserver.xml
@@ -3,9 +3,20 @@
     android:id="@+id/addserver_root"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:padding="12dp"
     android:orientation="vertical" >
-
+    
     <TextView
+        android:id="@+id/wifiAlertMsg"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_margin="5dp"
+        android:text="@string/wifiAlertMsg"
+        android:textStyle="italic"
+        android:typeface="serif" />
+        
+    <TextView
+
         android:id="@+id/addserver_namelabel"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
@@ -43,4 +54,4 @@
         android:checked="true"
         android:text="@string/addserver_remember" />
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml
index a08edd1..84edffc 100644
--- a/android/sdremote/res/values/strings.xml
+++ b/android/sdremote/res/values/strings.xml
@@ -7,6 +7,7 @@
     <string name="presentation_ui_resizehandle">Handle to resize view.</string>
     <string name="presentation_blank_screen">Blank Screen</string>
     <string name="options">Options</string>
+    <string name="reconnect">Reconnect...</string>
     <string name="actionbar_timeformat">h:mmaa</string>
     <string name="actionbar_timerformat">mm:ss</string>
     <string name="clock_timer_start">Start</string>
@@ -15,6 +16,8 @@
     <string name="clock_timer_reset">Reset</string>
     <string name="clock_timer_resume">Resume</string>
     <string name="options_autodecline">Decline Calls</string>
+    <string name="help">Help</string>
+    <string name="ConnectionFailedHelp">#1 Verify Impress is running \n#2 For Bluetooth user, 
enable \"Preference\"-\"LibreOffice Impress\"-\"General\"-\"Enable remote control\"\n#3 For WiFi 
user, tick \"Preferece\"-\"LibreOffice\"-\"Advanced\"-\"Enable Experimental Features\" \n </string>
     <string name="options_description">Automatically decline all incoming calls.</string>
     <string name="options_volumeswitching">Volume Switching</string>
     <string name="options_volumeswitching_descripton">Change slides using volume buttons</string>
@@ -49,6 +52,7 @@
     <string name="addserver_add">Add</string>
     <string name="addserver_cancel">Cancel</string>
     <string name="reconnect_description1">Your connection has been dropped.</string>
-    <string name="reconnect_description2">Attempting to reconnect…</string>
+    <string name="reconnect_description2">Please try to reconnect</string>
+    <string name="wifiAlertMsg">This is still an experimental feature. You need to \"enable 
experimental features\" in \"Preference\"-\"LibreOffice\"-\"Advanced\" on your computer. \nThe use 
over Bluetooth is recommanded.</string>
 
 </resources>
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java 
b/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java
index f9e6c92..26f1b8e 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java
@@ -10,18 +10,25 @@
 
 import java.text.MessageFormat;
 
+import org.libreoffice.impressremote.communication.CommunicationService;
+import org.libreoffice.impressremote.communication.CommunicationService.State;
 import android.content.BroadcastReceiver;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.ServiceConnection;
 import android.os.Bundle;
+import android.os.IBinder;
 import android.support.v4.content.LocalBroadcastManager;
 import android.widget.TextView;
 
 import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.MenuItem;
 
 public class PairingActivity extends SherlockActivity {
     private ActivityChangeBroadcastProcessor mBroadcastProcessor;
+    private CommunicationService mCommunicationService;
 
     /** Called when the activity is first created. */
     @Override
@@ -29,8 +36,8 @@
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.activity_pairing);
-
-        mBroadcastProcessor = new ActivityChangeBroadcastProcessor(this);
+        bindService(new Intent(this, CommunicationService.class), mConnection,
+                Context.BIND_IMPORTANT);
 
         IntentFilter aFilter = new IntentFilter();
 
@@ -54,6 +61,22 @@
 
         getSupportActionBar().setTitle(aServerName);
     }
+    
+    @Override
+    public void onPause(){
+        super.onPause();
+        unbindService(mConnection);
+    }
+
+    @Override
+    public void onBackPressed() {
+        mCommunicationService.getClient().closeConnection();
+        
+        Intent aIntent = new Intent(this, SelectorActivity.class);
+        aIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        startActivity(aIntent);
+    }
+
 
     private BroadcastReceiver mListener = new BroadcastReceiver() {
 
@@ -63,6 +86,32 @@
         }
     };
 
+    private ServiceConnection mConnection = new ServiceConnection() {
+
+        @Override
+        public void onServiceConnected(ComponentName aClassName,
+                IBinder aService) {
+            mCommunicationService = ((CommunicationService.CBinder) aService)
+                    .getService();
+
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName aClassName) {
+            mCommunicationService = null;
+        }
+    };
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+        switch (item.getItemId()) {
+        case android.R.id.home:
+            onBackPressed();
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java 
b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
index 3b0f684..560e5d3 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
@@ -63,6 +63,8 @@
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_selector);
 
+        if (mCommunicationService != null)
+            mCommunicationService.disconnect();
         IntentFilter aFilter = new IntentFilter(
                         CommunicationService.MSG_SERVERLIST_CHANGED);
         aFilter.addAction(CommunicationService.STATUS_CONNECTION_FAILED);
@@ -223,26 +225,50 @@
                 if (mProgressDialog != null) {
                     mProgressDialog.dismiss();
 
-                    String aFormat = getResources().getString(
-                                    R.string.selector_dialog_connectionfailed);
-                    String aDialogText = MessageFormat.format(aFormat,
-                                    mCommunicationService
-                                                    .getPairingDeviceName());
+                    if (mCommunicationService != null) {
+                        String aFormat = getResources().getString(
+                                R.string.selector_dialog_connectionfailed);
+                        String aDialogText = MessageFormat.format(aFormat,
+                                mCommunicationService.getPairingDeviceName());
 
-                    AlertDialog.Builder builder = new AlertDialog.Builder(
-                                    SelectorActivity.this);
-                    builder.setMessage(aDialogText)
-                                    .setCancelable(false)
-                                    .setPositiveButton(
-                                                    R.string.selector_dialog_connectionfailed_ok,
-                                                    new DialogInterface.OnClickListener() {
-                                                        public void onClick(
-                                                                        DialogInterface dialog,
-                                                                        int id) {
-                                                            dialog.dismiss();
-                                                        }
-                                                    });
-                    builder.show();
+                        AlertDialog.Builder builder = new AlertDialog.Builder(
+                                SelectorActivity.this);
+                        builder.setMessage(aDialogText)
+                                .setCancelable(false)
+                                .setNeutralButton(R.string.help,
+                                        new DialogInterface.OnClickListener() {
+                                            public void onClick(
+                                                    DialogInterface dialog,
+                                                    int id) {
+                                                dialog.dismiss();
+                                                AlertDialog.Builder builder = new 
AlertDialog.Builder(
+                                                        SelectorActivity.this);
+                                                builder.setMessage(
+                                                        R.string.ConnectionFailedHelp)
+                                                        .setCancelable(false)
+                                                        .setPositiveButton(
+                                                                
R.string.selector_dialog_connectionfailed_ok,
+                                                                new 
DialogInterface.OnClickListener() {
+                                                                    public void onClick(
+                                                                            DialogInterface dialog,
+                                                                            int id) {
+                                                                        dialog.dismiss();
+                                                                    }
+                                                                });
+                                                builder.show();
+                                            }
+                                        })
+                                .setPositiveButton(
+                                        R.string.selector_dialog_connectionfailed_ok,
+                                        new DialogInterface.OnClickListener() {
+                                            public void onClick(
+                                                    DialogInterface dialog,
+                                                    int id) {
+                                                dialog.dismiss();
+                                            }
+                                        });
+                        builder.show();
+                    }
                 }
             }
             mBroadcastProcessor.onReceive(aContext, aIntent);
diff --git a/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java 
b/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java
index 44a3368..163b8fa 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java
@@ -10,6 +10,7 @@
 
 import org.libreoffice.impressremote.communication.CommunicationService;
 
+import android.app.AlertDialog;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
@@ -18,6 +19,7 @@
 import android.content.ServiceConnection;
 import android.os.Bundle;
 import android.os.IBinder;
+import android.support.v4.app.FragmentTransaction;
 import android.support.v4.content.LocalBroadcastManager;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -37,6 +39,7 @@
         bindService(new Intent(this, CommunicationService.class), mConnection,
                         Context.BIND_IMPORTANT);
 
+        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
         IntentFilter aFilter = new IntentFilter(
                         CommunicationService.MSG_SLIDESHOW_STARTED);
 
@@ -97,6 +100,18 @@
             mBroadcastProcessor.onReceive(aContext, aIntent);
         }
     };
+
+    @Override
+    public boolean onOptionsItemSelected(
+            com.actionbarsherlock.view.MenuItem item) {
+        switch (item.getItemId()) {
+        case android.R.id.home:
+            onBackPressed();
+            return true;
+        default:
+            return super.onOptionsItemSelected(item);
+        }
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java 
b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
index 07a626f..c2e7a61 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
@@ -58,6 +58,27 @@
 
         mSocket.connect();
         Log.i(Globals.TAG, "BluetoothClient: connected");
+    }
+
+    @Override
+    public void closeConnection() {
+        try {
+            if (mSocket != null)
+                mSocket.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    protected void onDisconnect() {
+        if (!mBluetoothWasEnabled) {
+            mAdapter.disable();
+        }
+    }
+
+    @Override
+    public void validating() throws IOException {
+        // TODO Auto-generated method stub
 
         mInputStream = mSocket.getInputStream();
         mReader = new BufferedReader(new InputStreamReader(mInputStream,
@@ -78,22 +99,6 @@
                         aIntent);
         startListening();
 
-    }
-
-    @Override
-    public void closeConnection() {
-        try {
-            if (mSocket != null)
-                mSocket.close();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    protected void onDisconnect() {
-        if (!mBluetoothWasEnabled) {
-            mAdapter.disable();
-        }
     }
 
 }
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java 
b/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
index 198b873..53706df 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
@@ -15,7 +15,11 @@
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 
+import org.libreoffice.impressremote.Globals;
+import org.libreoffice.impressremote.communication.CommunicationService.State;
+
 import android.content.Intent;
+import android.util.Log;
 
 /**
  * Generic Client for the remote control. To implement a Client for a specific
@@ -37,6 +41,7 @@
 
     public abstract void closeConnection();
 
+    public abstract void validating() throws IOException;
     private Receiver mReceiver;
 
     protected Server mServer;
@@ -75,11 +80,11 @@
                     aList.add(aTemp);
                 }
                 if (aTemp == null) {
-                    mCommunicationService.connectTo(mServer);
                     Intent aIntent = new Intent(
                                     mCommunicationService
                                                     .getApplicationContext(),
                                     ReconnectionActivity.class);
+                    aIntent.putExtra("server", mServer);                    
                     aIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                     mCommunicationService.getApplicationContext()
                                     .startActivity(aIntent);
diff --git 
a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java 
b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
index 8028f00..f7401fb 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
@@ -102,28 +102,34 @@
                             case NETWORK:
                                 mClient = new NetworkClient(mServerDesired,
                                                 this, mReceiver);
+                                mClient.validating();
                                 break;
                             case BLUETOOTH:
                                 mClient = new BluetoothClient(mServerDesired,
                                                 this, mReceiver,
                                                 mBluetoothPreviouslyEnabled);
+                                mClient.validating();
                                 break;
                             }
                             mTransmitter = new Transmitter(mClient);
                             mState = State.CONNECTED;
                         } catch (IOException e) {
                             Log.i(Globals.TAG, "CommunicationService.run: " + e);
-                            mClient = null;
-                            mState = State.DISCONNECTED;
-                            Intent aIntent = new Intent(
-                                            CommunicationService.STATUS_CONNECTION_FAILED);
-                            LocalBroadcastManager.getInstance(this)
-                                            .sendBroadcast(aIntent);
+                            connextionFailed();
                         }
                     }
                 }
+                Log.i(Globals.TAG, "CommunicationService.finished work");
             }
         }
+    }
+
+    private void connextionFailed() {
+        mClient = null;
+        mState = State.DISCONNECTED;
+        Intent aIntent = new Intent(
+                CommunicationService.STATUS_CONNECTION_FAILED);
+        LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent);
     }
 
     private boolean mBluetoothPreviouslyEnabled;
@@ -174,6 +180,7 @@
     }
 
     public void disconnect() {
+        Log.d(Globals.TAG, "Service Disconnected");
         synchronized (mConnectionVariableMutex) {
             mStateDesired = State.DISCONNECTED;
             synchronized (this) {
@@ -328,6 +335,10 @@
 
     }
 
+    public Client getClient() {
+        return mClient;
+    }
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java 
b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
index 2e88a17..fbd51fa 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
@@ -31,73 +31,38 @@
     private static final int PORT = 1599;
 
     private Socket mSocket;
+    private Intent mIntent;
+    private String mPin;
+    private Server mServer;
 
     public NetworkClient(Server aServer,
-                    CommunicationService aCommunicationService,
-                    Receiver aReceiver) throws UnknownHostException,
-                    IOException {
+            CommunicationService aCommunicationService, Receiver aReceiver)
+            throws UnknownHostException, IOException {
         super(aServer, aCommunicationService, aReceiver);
-        mSocket = new Socket(aServer.getAddress(), PORT);
+        mServer = aServer;
+        mSocket = new Socket(mServer.getAddress(), PORT);
         mInputStream = mSocket.getInputStream();
         mReader = new BufferedReader(new InputStreamReader(mInputStream,
-                        CHARSET));
+                CHARSET));
         mOutputStream = mSocket.getOutputStream();
+
         // Pairing.
-        String aPin = setupPin(aServer);
-        Intent aIntent = new Intent(CommunicationService.MSG_PAIRING_STARTED);
-        aIntent.putExtra("PIN", aPin);
-        mPin = aPin;
+        mPin = setupPin(mServer);
+        mIntent = new Intent(CommunicationService.MSG_PAIRING_STARTED);
+        mIntent.putExtra("PIN", mPin);
         LocalBroadcastManager.getInstance(mCommunicationService).sendBroadcast(
-                        aIntent);
+                mIntent);
         // Send out
-        String aName = CommunicationService.getDeviceName(); // TODO: get the proper name
-        sendCommand("LO_SERVER_CLIENT_PAIR\n" + aName + "\n" + aPin + "\n\n");
-
-        // Wait until we get the appropriate string back...
-        String aTemp = mReader.readLine();
-
-        if (aTemp == null) {
-            throw new IOException(
-                            "End of stream reached before any data received.");
-        }
-
-        while (!aTemp.equals("LO_SERVER_SERVER_PAIRED")) {
-            if (aTemp.equals("LO_SERVER_VALIDATING_PIN")) {
-                // Broadcast that we need a pin screen.
-                aIntent = new Intent(
-                                CommunicationService.STATUS_PAIRING_PINVALIDATION);
-                aIntent.putExtra("PIN", aPin);
-                aIntent.putExtra("SERVERNAME", aServer.getName());
-                mPin = aPin;
-                LocalBroadcastManager.getInstance(mCommunicationService)
-                                .sendBroadcast(aIntent);
-                while (mReader.readLine().length() != 0) {
-                    // Read off empty lines
-                }
-                aTemp = mReader.readLine();
-            } else {
-                return;
-            }
-        }
-
-        aIntent = new Intent(CommunicationService.MSG_PAIRING_SUCCESSFUL);
-        LocalBroadcastManager.getInstance(mCommunicationService).sendBroadcast(
-                        aIntent);
-
-        while (mReader.readLine().length() != 0) {
-            // Get rid of extra lines
-            Log.i(Globals.TAG, "NetworkClient: extra line");
-        }
-        Log.i(Globals.TAG, "NetworkClient: calling startListening");
-        startListening();
-
+        String aName = CommunicationService.getDeviceName(); // TODO: get the
+                                                             // proper name
+        sendCommand("LO_SERVER_CLIENT_PAIR\n" + aName + "\n" + mPin + "\n\n");
     }
 
     private String setupPin(Server aServer) {
         // Get settings
         SharedPreferences aPreferences = mCommunicationService
-                        .getSharedPreferences("sdremote_authorisedremotes",
-                                        android.content.Context.MODE_PRIVATE);
+                .getSharedPreferences("sdremote_authorisedremotes",
+                        android.content.Context.MODE_PRIVATE);
         if (aPreferences.contains(aServer.getName())) {
             return aPreferences.getString(aServer.getName(), "");
         } else {
@@ -132,6 +97,46 @@
         }
     }
 
+    @Override
+    public void validating() throws IOException {
+
+        // Wait until we get the appropriate string back...
+        String aTemp = mReader.readLine();
+
+        if (aTemp == null) {
+            throw new IOException(
+                    "End of stream reached before any data received.");
+        }
+
+        while (!aTemp.equals("LO_SERVER_SERVER_PAIRED")) {
+            if (aTemp.equals("LO_SERVER_VALIDATING_PIN")) {
+                // Broadcast that we need a pin screen.
+                mIntent = new Intent(
+                        CommunicationService.STATUS_PAIRING_PINVALIDATION);
+                mIntent.putExtra("PIN", mPin);
+                mIntent.putExtra("SERVERNAME", mServer.getName());
+                LocalBroadcastManager.getInstance(mCommunicationService)
+                        .sendBroadcast(mIntent);
+                while (mReader.readLine().length() != 0) {
+                    // Read off empty lines
+                }
+                aTemp = mReader.readLine();
+            } else {
+                return;
+            }
+        }
+
+        mIntent = new Intent(CommunicationService.MSG_PAIRING_SUCCESSFUL);
+        LocalBroadcastManager.getInstance(mCommunicationService).sendBroadcast(
+                mIntent);
+
+        while (mReader.readLine().length() != 0) {
+            // Get rid of extra lines
+            Log.i(Globals.TAG, "NetworkClient: extra line");
+        }
+        Log.i(Globals.TAG, "NetworkClient: calling startListening");
+        startListening();
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git 
a/android/sdremote/src/org/libreoffice/impressremote/communication/ReconnectionActivity.java 
b/android/sdremote/src/org/libreoffice/impressremote/communication/ReconnectionActivity.java
index 8417cde..8622737 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/ReconnectionActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ReconnectionActivity.java
@@ -8,18 +8,99 @@
  */
 package org.libreoffice.impressremote.communication;
 
+import org.libreoffice.impressremote.ActivityChangeBroadcastProcessor;
 import org.libreoffice.impressremote.R;
+import org.libreoffice.impressremote.SelectorActivity;
 
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
 import android.os.Bundle;
+import android.os.IBinder;
+import android.support.v4.content.LocalBroadcastManager;
 
 import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.MenuItem;
 
 public class ReconnectionActivity extends SherlockActivity {
+
+    private ActivityChangeBroadcastProcessor mBroadcastProcessor;
+    private CommunicationService mCommunicationService;
+
+    // private TextView mCountDownTextView;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_reconnect);
+        // mCountDownTextView = (TextView) findViewById(R.id.countDownTV);
+
+        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+        bindService(new Intent(this, CommunicationService.class), mConnection,
+                Context.BIND_IMPORTANT);
+
+        final Server desiredServer = getIntent().getParcelableExtra("server");
+
+        IntentFilter aFilter = new IntentFilter();
+
+        mBroadcastProcessor = new ActivityChangeBroadcastProcessor(this);
+        mBroadcastProcessor.addToFilter(aFilter);
+
+        LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
+                aFilter);
+
+        getSupportActionBar().setTitle(desiredServer.getName());
+
+        // TODO Connection to desired server
+        // Create a countdown clock for 10 seconds, then double the delay
+        // with every failure. Until it reaches 1min. Like Gmail retry
+
+    }
+
+    private BroadcastReceiver mListener = new BroadcastReceiver() {
+
+        @Override
+        public void onReceive(Context aContext, Intent aIntent) {
+            mBroadcastProcessor.onReceive(aContext, aIntent);
+        }
+    };
+
+    private ServiceConnection mConnection = new ServiceConnection() {
+
+        @Override
+        public void onServiceConnected(ComponentName aClassName,
+                IBinder aService) {
+            mCommunicationService = ((CommunicationService.CBinder) aService)
+                    .getService();
+
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName aClassName) {
+            mCommunicationService = null;
+        }
+    };
+
+    @Override
+    public void onBackPressed() {
+        Intent aIntent = new Intent(this, SelectorActivity.class);
+        aIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        startActivity(aIntent);
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+        switch (item.getItemId()) {
+        case android.R.id.home:
+            onBackPressed();
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
     }
 
 }
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Server.java 
b/android/sdremote/src/org/libreoffice/impressremote/communication/Server.java
index 77e6eb3..503f87a 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Server.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Server.java
@@ -8,7 +8,10 @@
  */
 package org.libreoffice.impressremote.communication;
 
-public class Server {
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class Server implements Parcelable {
 
     public enum Protocol {
         NETWORK, BLUETOOTH
@@ -56,6 +59,36 @@
     public String toString() {
         return getClass().getName() + '@' + Integer.toHexString(hashCode()) + ":{" + mAddress + 
"," + mName + "}";
     }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel out, int flags) {
+        out.writeString(mAddress);
+        out.writeString(mName);
+        out.writeString(mProtocol.name());
+        out.writeLong(mTimeDiscovered);
+    }
+
+    public static final Parcelable.Creator<Server> CREATOR = new Parcelable.Creator<Server>() {
+        public Server createFromParcel(Parcel in) {
+            return new Server(in);
+        }
+
+        public Server[] newArray(int size) {
+            return new Server[size];
+        }
+    };
+
+    private Server(Parcel in) {
+        mAddress = in.readString();
+        mName = in.readString();
+        mProtocol = Protocol.valueOf(in.readString());
+        mTimeDiscovered = in.readLong();
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

-- 
To view, visit https://gerrit.libreoffice.org/3366
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I424a470aa02b0c74b28cb9f9ba79489aa0d4ab1b
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Siqi LIU <me@siqi.fr>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.