summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorArtur Dryomov <artur.dryomov@gmail.com>2013-06-25 02:34:46 +0300
committerMichael Meeks <michael.meeks@suse.com>2013-07-25 18:01:47 +0100
commita4165981dc35d7b75645585753a08e78c5ee476d (patch)
treef9167bbb9bb8e605254fff4e3c0e1d2bd7281c5d /android
parentd0f3c74887d88cca9398b0109c911f9f1aeedef4 (diff)
Fix possible null pointer exception in the BluetoothClient.
Change-Id: Ib43458bd8cfa9624f6f43610db90686476d9865f
Diffstat (limited to 'android')
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java14
1 files changed, 6 insertions, 8 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
index 4fea91993581..8da48bb8dc63 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
@@ -26,7 +26,6 @@ public class BluetoothClient extends Client {
private final boolean mBluetoothWasEnabled;
- private final BluetoothAdapter mBluetoothAdapter;
private BluetoothSocket mSocket;
public BluetoothClient(Server aServer, CommunicationService aCommunicationService, Receiver aReceiver, boolean aBluetoothWasEnabled) {
@@ -34,10 +33,8 @@ public class BluetoothClient extends Client {
mBluetoothWasEnabled = aBluetoothWasEnabled;
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
-
if (!mBluetoothWasEnabled) {
- mBluetoothAdapter.enable();
+ BluetoothAdapter.getDefaultAdapter().enable();
}
}
@@ -48,10 +45,11 @@ public class BluetoothClient extends Client {
private BluetoothSocket buildServerConnection() {
try {
- BluetoothDevice aBluetoothServer = mBluetoothAdapter
+ BluetoothDevice aBluetoothServer = BluetoothAdapter
+ .getDefaultAdapter()
.getRemoteDevice(mServer.getAddress());
- mBluetoothAdapter.cancelDiscovery();
+ BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
BluetoothSocket aSocket = aBluetoothServer
.createRfcommSocketToServiceRecord(
@@ -61,7 +59,7 @@ public class BluetoothClient extends Client {
return aSocket;
} catch (IOException e) {
- throw new RuntimeException("Unable to connect to Bluetooth host");
+ throw new RuntimeException("Unable to connect to Bluetooth host.");
}
}
@@ -92,7 +90,7 @@ public class BluetoothClient extends Client {
protected void onDisconnect() {
if (!mBluetoothWasEnabled) {
- mBluetoothAdapter.disable();
+ BluetoothAdapter.getDefaultAdapter().disable();
}
}