diff options
4 files changed, 7 insertions, 57 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServerConnection.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServerConnection.java index 1056b7dfe116..d58460aaa8f0 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServerConnection.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServerConnection.java @@ -14,11 +14,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.UUID; +import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; -import org.libreoffice.impressremote.util.BluetoothOperator; - class BluetoothServerConnection implements ServerConnection { // Standard UUID for the Serial Port Profile. // https://www.bluetooth.org/en-us/specification/assigned-numbers-overview/service-discovery @@ -32,7 +31,7 @@ class BluetoothServerConnection implements ServerConnection { private BluetoothSocket buildServerConnection(Server aServer) { try { - BluetoothDevice aBluetoothServer = BluetoothOperator.getAdapter() + BluetoothDevice aBluetoothServer = BluetoothAdapter.getDefaultAdapter() .getRemoteDevice(aServer.getAddress()); return aBluetoothServer.createRfcommSocketToServiceRecord( diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index a8aa85f48970..cea50e53c7ab 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -16,7 +16,6 @@ import android.os.Binder; import android.os.IBinder; import android.support.v4.content.LocalBroadcastManager; -import org.libreoffice.impressremote.util.BluetoothOperator; import org.libreoffice.impressremote.util.Intents; public class CommunicationService extends Service implements Runnable, MessagesListener, Timer.TimerListener { diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java b/android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java index f5f4fe4f88fb..53d85d86378f 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java @@ -8,13 +8,15 @@ */ package org.libreoffice.impressremote.communication; +import android.bluetooth.BluetoothAdapter; import android.content.Context; import android.os.Build; -import org.libreoffice.impressremote.util.BluetoothOperator; import org.libreoffice.impressremote.util.Preferences; final class PairingProvider { + private static final BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); + private final Preferences mAuthorizedServersPreferences; private PairingProvider(Context aContext) { @@ -58,15 +60,11 @@ final class PairingProvider { } private String getPairingDeviceName() { - if (!BluetoothOperator.isAvailable()) { - return Build.MODEL; - } - - if (BluetoothOperator.getAdapter().getName() == null) { + if (btAdapter == null || btAdapter.getName() == null) { return Build.MODEL; } - return BluetoothOperator.getAdapter().getName(); + return btAdapter.getName(); } } diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java b/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java deleted file mode 100644 index 95228388d501..000000000000 --- a/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * 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.util; - -import android.bluetooth.BluetoothAdapter; - -public final class BluetoothOperator { - private BluetoothOperator() { - } - - public static boolean isAvailable() { - return getAdapter() != null; - } - - public static BluetoothAdapter getAdapter() { - // TODO: should be acquired other way on Jelly Bean MR2 - // Look at the BluetoothAdapter’s docs for details. - // It will require to use the latest version of SDK to get needed constant. - - return BluetoothAdapter.getDefaultAdapter(); - } - - public static void enable() { - if (!isAvailable()) { - return; - } - - getAdapter().enable(); - } - - public static void disable() { - if (!isAvailable()) { - return; - } - - getAdapter().disable(); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |