diff options
author | Michael Meeks <michael.meeks@suse.com> | 2013-08-01 15:35:41 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-08-01 15:36:10 +0200 |
commit | 687b62f4812f88c9aef3bdd864358282850aa2ec (patch) | |
tree | 73be40a75a10b71dac97e9739f9ded5bef066e0a /android | |
parent | b042a78d9847753d95560749dab2159d9cfbd7ae (diff) |
android: don't mess with the system bluetooth setting unless we have to.
Diffstat (limited to 'android')
3 files changed, 13 insertions, 3 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServerConnection.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServerConnection.java index 6ecaabe299d5..fe5834d9a8a2 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServerConnection.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServerConnection.java @@ -6,6 +6,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + package org.libreoffice.impressremote.communication; import java.io.IOException; diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java index a236ac59fa9a..35be694d17f7 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java @@ -27,7 +27,7 @@ import org.libreoffice.impressremote.util.Intents; import org.libreoffice.impressremote.communication.Server.Protocol; class BluetoothServersFinder extends BroadcastReceiver implements ServersFinder, Runnable { - private static final int SEARCH_DELAY_IN_MILLISECONDS = 1000 * 10; + private static final int SEARCH_DELAY_IN_MILLISECONDS = 1000 * 5; private final Context mContext; diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index 6041190f5857..8ded38f64fef 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -37,6 +37,8 @@ public class CommunicationService extends Service implements Runnable, MessagesL private IBinder mBinder; private ServersManager mServersManager; + private static boolean gWasBluetoothEnabled = false; + private static boolean gWasBluetoothEnabledFetched = false; private ServerConnection mServerConnection; @@ -162,7 +164,13 @@ public class CommunicationService extends Service implements Runnable, MessagesL mState = State.SEARCHING; if (BluetoothAdapter.getDefaultAdapter() != null) { - BluetoothAdapter.getDefaultAdapter().enable(); + if (!gWasBluetoothEnabledFetched) { + gWasBluetoothEnabled = BluetoothAdapter.getDefaultAdapter().isEnabled(); + gWasBluetoothEnabledFetched = true; + + if (!gWasBluetoothEnabled) + BluetoothAdapter.getDefaultAdapter().enable(); + } } mServersManager.startServersSearch(); @@ -172,7 +180,8 @@ public class CommunicationService extends Service implements Runnable, MessagesL mServersManager.stopServersSearch(); if (BluetoothAdapter.getDefaultAdapter() != null) { - BluetoothAdapter.getDefaultAdapter().disable(); + if (!gWasBluetoothEnabled) + BluetoothAdapter.getDefaultAdapter().disable(); } } |