summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Deqiang Chen <deqiangc@google.com> 2019-03-14 15:53:21 -0700
committer android-build-merger <android-build-merger@google.com> 2019-03-14 15:53:21 -0700
commit8a4e2f3aebbde591e23c1d76c174e0588c243f4e (patch)
treeeb90bda8a221d656d32477af21217f5fb9c74e10
parenta2d4a163db4132e5de9a7af9cc7abdef78494d3d (diff)
parent787e52045f05b19a45124843d7130b9b170c59ea (diff)
Merge "Avoid IllegalArgumentException when bluetooth is disabled" am: 2a1bdd2429
am: 787e52045f Change-Id: I3f55d6e7b56170ee4cafaf60e7ef8b908080c182
-rw-r--r--core/java/android/bluetooth/BluetoothA2dp.java6
-rw-r--r--core/java/android/bluetooth/BluetoothHidHost.java6
-rw-r--r--core/java/android/bluetooth/BluetoothPbap.java6
3 files changed, 12 insertions, 6 deletions
diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java
index 171c2f5b1a08..9faa1d675d8d 100644
--- a/core/java/android/bluetooth/BluetoothA2dp.java
+++ b/core/java/android/bluetooth/BluetoothA2dp.java
@@ -224,8 +224,10 @@ public final class BluetoothA2dp implements BluetoothProfile {
if (VDBG) Log.d(TAG, "Unbinding service...");
try {
mServiceLock.writeLock().lock();
- mService = null;
- mContext.unbindService(mConnection);
+ if (mService != null) {
+ mService = null;
+ mContext.unbindService(mConnection);
+ }
} catch (Exception re) {
Log.e(TAG, "", re);
} finally {
diff --git a/core/java/android/bluetooth/BluetoothHidHost.java b/core/java/android/bluetooth/BluetoothHidHost.java
index 0ca39f169a72..289e769a99ef 100644
--- a/core/java/android/bluetooth/BluetoothHidHost.java
+++ b/core/java/android/bluetooth/BluetoothHidHost.java
@@ -232,8 +232,10 @@ public final class BluetoothHidHost implements BluetoothProfile {
if (VDBG) Log.d(TAG, "Unbinding service...");
synchronized (mConnection) {
try {
- mService = null;
- mContext.unbindService(mConnection);
+ if (mService != null) {
+ mService = null;
+ mContext.unbindService(mConnection);
+ }
} catch (Exception re) {
Log.e(TAG, "", re);
}
diff --git a/core/java/android/bluetooth/BluetoothPbap.java b/core/java/android/bluetooth/BluetoothPbap.java
index ae264e19bb7c..b303c34ee0ae 100644
--- a/core/java/android/bluetooth/BluetoothPbap.java
+++ b/core/java/android/bluetooth/BluetoothPbap.java
@@ -120,8 +120,10 @@ public class BluetoothPbap implements BluetoothProfile {
log("Unbinding service...");
synchronized (mConnection) {
try {
- mService = null;
- mContext.unbindService(mConnection);
+ if (mService != null) {
+ mService = null;
+ mContext.unbindService(mConnection);
+ }
} catch (Exception re) {
Log.e(TAG, "", re);
}