diff options
author | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2013-12-15 16:44:12 +0100 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-01-16 15:46:40 +0000 |
commit | 4d6244cc80f1a384d571af2efd539bd3fa3f9291 (patch) | |
tree | 0d645642744e8ea7dd9035ad22484a9258a7a7b2 /android/sdremote | |
parent | f5d14e0234effd16a570ec3f32349f53c1b469f0 (diff) |
remove BluetoothOperator wrapper
it is just another obfuscating layer of one-command-function calles that
can as well be called directly.
If you really want to get the path to aquire the bluetooth adapter
differently, based on a runtime check, a single method to retrieve the
adapter is enough in any of the classes. No need to wrap the whole
adapter's api in your own class.
Change-Id: I2c631321dcf8ef143fe58a0a8246e010169409ac
Diffstat (limited to 'android/sdremote')
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: */ |