diff options
author | Artur Dryomov <artur.dryomov@gmail.com> | 2013-07-13 01:16:34 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-07-25 18:01:54 +0100 |
commit | 5f6eb2d86da300416be13e63a7d3e863e32338d4 (patch) | |
tree | bf9a30ec17db5df34648324537746214855d4f0f /android | |
parent | c81c82f801e6e12454affb8c3f3946079c5ab688 (diff) |
Remove PAIRING_STARTED intent action.
Replace with PAIRING_VALIDATION. Probably it is better to rely on
protocol and server.
Change-Id: I5120fe1b2c3a5f48c294fb2c76334c1cd09285a1
Diffstat (limited to 'android')
4 files changed, 14 insertions, 31 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java index c3df6fed0668..20d8267f7477 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java @@ -126,8 +126,8 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv @Override public void onReceive(Context aContext, Intent aIntent) { - if (Intents.Actions.PAIRING_STARTED.equals(aIntent.getAction())) { - String aPin = aIntent.getStringExtra("PIN"); + if (Intents.Actions.PAIRING_VALIDATION.equals(aIntent.getAction())) { + String aPin = aIntent.getStringExtra(Intents.Extras.PIN); mComputerConnectionFragment.setUpPinValidationInstructions(aPin); @@ -148,7 +148,7 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv private IntentFilter buildIntentsReceiverFilter() { IntentFilter aIntentFilter = new IntentFilter(); - aIntentFilter.addAction(Intents.Actions.PAIRING_STARTED); + aIntentFilter.addAction(Intents.Actions.PAIRING_VALIDATION); aIntentFilter.addAction(Intents.Actions.PAIRING_SUCCESSFUL); aIntentFilter.addAction(Intents.Actions.CONNECTION_FAILED); diff --git a/android/sdremote/src/org/libreoffice/impressremote/Intents.java b/android/sdremote/src/org/libreoffice/impressremote/Intents.java index 055af77fbf25..cbb2b112d581 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/Intents.java +++ b/android/sdremote/src/org/libreoffice/impressremote/Intents.java @@ -15,7 +15,6 @@ public final class Intents { public static final String SERVERS_LIST_CHANGED = "SERVERS_LIST_CHANGED"; - public static final String PAIRING_STARTED = "PAIRING_STARTED"; public static final String PAIRING_SUCCESSFUL = "PAIRING_SUCCESSFUL"; public static final String PAIRING_VALIDATION = "PAIRING_VALIDATION"; @@ -37,7 +36,6 @@ public final class Intents { public static final String PIN = "PIN"; public static final String SERVER = "SERVER"; - public static final String SERVER_NAME = "SERVER_NAME"; public static final String SLIDE_INDEX = "SLIDE_INDEX"; } @@ -46,21 +44,13 @@ public final class Intents { return new Intent(Actions.SERVERS_LIST_CHANGED); } - public static Intent buildPairingStartedIntent(String aPin) { - Intent aIntent = new Intent(Actions.PAIRING_STARTED); - aIntent.putExtra(Extras.PIN, aPin); - - return aIntent; - } - public static Intent buildPairingSuccessfulIntent() { return new Intent(Actions.PAIRING_SUCCESSFUL); } - public static Intent buildPairingValidationIntent(String aPin, String aServerName) { + public static Intent buildPairingValidationIntent(String aPin) { Intent aIntent = new Intent(Actions.PAIRING_VALIDATION); aIntent.putExtra(Extras.PIN, aPin); - aIntent.putExtra(Extras.SERVER_NAME, aServerName); return aIntent; } diff --git a/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java index 45222c00e5df..4e921833864b 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java @@ -18,6 +18,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; +import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.support.v4.content.LocalBroadcastManager; @@ -50,7 +51,7 @@ public class PairingActivity extends SherlockActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); String aPin = getIntent().getStringExtra("PIN"); - String aServerName = getIntent().getStringExtra("SERVERNAME"); + String aServerName = Build.MODEL; ((TextView) findViewById(R.id.pairing_pin)).setText(aPin); ((TextView) findViewById(R.id.pairing_instruction2_deviceName)) diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index 1a24af517925..c819456b19bc 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -118,7 +118,9 @@ public class CommunicationService extends Service implements Runnable, MessagesL mMessagesReceiver = new MessagesReceiver(mServerConnection, this); mCommandsTransmitter = new CommandsTransmitter(mServerConnection); - pairWithServer(); + if (isPairingNecessary()) { + pair(); + } mState = State.CONNECTED; } @@ -136,19 +138,12 @@ public class CommunicationService extends Service implements Runnable, MessagesL } } - private void pairWithServer() { - if (mServerDesired.getProtocol() == Server.Protocol.BLUETOOTH) { - return; - } - - mCommandsTransmitter.pair(getDeviceName(), loadPin()); - - startPairingActivity(); + private boolean isPairingNecessary() { + return mServerDesired.getProtocol() == Server.Protocol.TCP; } - private void startPairingActivity() { - Intent aIntent = Intents.buildPairingStartedIntent(loadPin()); - LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); + private void pair() { + mCommandsTransmitter.pair(getDeviceName(), loadPin()); } private String loadPin() { @@ -268,10 +263,7 @@ public class CommunicationService extends Service implements Runnable, MessagesL @Override public void onPinValidation() { - String aPin = loadPin(); - String aServerName = mServerDesired.getName(); - - Intent aIntent = Intents.buildPairingValidationIntent(aPin, aServerName); + Intent aIntent = Intents.buildPairingValidationIntent(loadPin()); LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } |