summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jakub Pawlowski <jpawlowski@google.com> 2017-04-27 07:04:15 -0700
committer Andre Eisenbach <eisenbach@google.com> 2017-04-27 19:37:35 +0000
commit0e4ac75f2e291305a493796186d44a081926f3a8 (patch)
treed9eefbed609552d4907b4d50e4ea8c2969531592
parent4898b704de5f726b513f17e1368960044c880b4c (diff)
Fix NPE when accessing mCallback in BluetoothGatt
This issue was introduced in commit 4eab49652e48159fd37f827d30b822f2f187551e. Bug: 37710354 Test: none Change-Id: I2d985ce97c44d4e096713e156e57437f44ea3ddb
-rw-r--r--core/java/android/bluetooth/BluetoothGatt.java63
1 files changed, 47 insertions, 16 deletions
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java
index 7806e31c418e..40f10a8edd22 100644
--- a/core/java/android/bluetooth/BluetoothGatt.java
+++ b/core/java/android/bluetooth/BluetoothGatt.java
@@ -159,8 +159,10 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onConnectionStateChange(BluetoothGatt.this, GATT_FAILURE,
- BluetoothProfile.STATE_DISCONNECTED);
+ if (mCallback != null) {
+ mCallback.onConnectionStateChange(BluetoothGatt.this, GATT_FAILURE,
+ BluetoothProfile.STATE_DISCONNECTED);
+ }
}
});
@@ -192,7 +194,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onPhyUpdate(BluetoothGatt.this, txPhy, rxPhy, status);
+ if (mCallback != null) {
+ mCallback.onPhyUpdate(BluetoothGatt.this, txPhy, rxPhy, status);
+ }
}
});
}
@@ -212,7 +216,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onPhyRead(BluetoothGatt.this, txPhy, rxPhy, status);
+ if (mCallback != null) {
+ mCallback.onPhyRead(BluetoothGatt.this, txPhy, rxPhy, status);
+ }
}
});
}
@@ -235,7 +241,10 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onConnectionStateChange(BluetoothGatt.this, status, profileState);
+ if (mCallback != null) {
+ mCallback.onConnectionStateChange(BluetoothGatt.this, status,
+ profileState);
+ }
}
});
@@ -294,7 +303,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onServicesDiscovered(BluetoothGatt.this, status);
+ if (mCallback != null) {
+ mCallback.onServicesDiscovered(BluetoothGatt.this, status);
+ }
}
});
}
@@ -344,7 +355,10 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onCharacteristicRead(BluetoothGatt.this, characteristic, status);
+ if (mCallback != null) {
+ mCallback.onCharacteristicRead(BluetoothGatt.this, characteristic,
+ status);
+ }
}
});
}
@@ -390,7 +404,10 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onCharacteristicWrite(BluetoothGatt.this, characteristic, status);
+ if (mCallback != null) {
+ mCallback.onCharacteristicWrite(BluetoothGatt.this, characteristic,
+ status);
+ }
}
});
}
@@ -416,7 +433,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onCharacteristicChanged(BluetoothGatt.this, characteristic);
+ if (mCallback != null) {
+ mCallback.onCharacteristicChanged(BluetoothGatt.this, characteristic);
+ }
}
});
}
@@ -461,7 +480,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onDescriptorRead(BluetoothGatt.this, descriptor, status);
+ if (mCallback != null) {
+ mCallback.onDescriptorRead(BluetoothGatt.this, descriptor, status);
+ }
}
});
}
@@ -505,7 +526,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onDescriptorWrite(BluetoothGatt.this, descriptor, status);
+ if (mCallback != null) {
+ mCallback.onDescriptorWrite(BluetoothGatt.this, descriptor, status);
+ }
}
});
}
@@ -529,7 +552,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onReliableWriteCompleted(BluetoothGatt.this, status);
+ if (mCallback != null) {
+ mCallback.onReliableWriteCompleted(BluetoothGatt.this, status);
+ }
}
});
}
@@ -548,7 +573,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onReadRemoteRssi(BluetoothGatt.this, rssi, status);
+ if (mCallback != null) {
+ mCallback.onReadRemoteRssi(BluetoothGatt.this, rssi, status);
+ }
}
});
}
@@ -568,7 +595,9 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onMtuChanged(BluetoothGatt.this, mtu, status);
+ if (mCallback != null) {
+ mCallback.onMtuChanged(BluetoothGatt.this, mtu, status);
+ }
}
});
}
@@ -590,8 +619,10 @@ public final class BluetoothGatt implements BluetoothProfile {
mHandler.post(new Runnable() {
@Override
public void run() {
- mCallback.onConnectionUpdated(BluetoothGatt.this, interval, latency,
- timeout, status);
+ if (mCallback != null) {
+ mCallback.onConnectionUpdated(BluetoothGatt.this, interval, latency,
+ timeout, status);
+ }
}
});
}