diff options
author | Jack He <siyuanh@google.com> | 2017-09-06 00:53:03 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-09-06 00:53:03 +0000 |
commit | 979ad80543b27c464a4395989bfc347041828f8c (patch) | |
tree | dffcb5f35d1055eab767caf0822d9cc4e90c53df /framework/java/android/bluetooth/BluetoothPbap.java | |
parent | 8a537758694f68d49dffb0f1b3265e2de64b6f11 (diff) | |
parent | 52bd129ba515fd794d98b24420627e7bb43dcbb4 (diff) |
Merge "Bluetooth: Thread-safe binder invocation" am: 2c9db622d2 am: 52bd129ba5
am: 9a68d78b44
Change-Id: I08808aaec456fbb53126fcf0130c02afac82f29b
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothPbap.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothPbap.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/framework/java/android/bluetooth/BluetoothPbap.java b/framework/java/android/bluetooth/BluetoothPbap.java index 78b7c7b7a7..19f5198ca7 100644 --- a/framework/java/android/bluetooth/BluetoothPbap.java +++ b/framework/java/android/bluetooth/BluetoothPbap.java @@ -68,7 +68,7 @@ public class BluetoothPbap { public static final String PBAP_STATE_CHANGED_ACTION = "android.bluetooth.pbap.intent.action.PBAP_STATE_CHANGED"; - private IBluetoothPbap mService; + private volatile IBluetoothPbap mService; private final Context mContext; private ServiceListener mServiceListener; private BluetoothAdapter mAdapter; @@ -214,9 +214,10 @@ public class BluetoothPbap { */ public int getState() { if (VDBG) log("getState()"); - if (mService != null) { + final IBluetoothPbap service = mService; + if (service != null) { try { - return mService.getState(); + return service.getState(); } catch (RemoteException e) { Log.e(TAG, e.toString()); } @@ -235,9 +236,10 @@ public class BluetoothPbap { */ public BluetoothDevice getClient() { if (VDBG) log("getClient()"); - if (mService != null) { + final IBluetoothPbap service = mService; + if (service != null) { try { - return mService.getClient(); + return service.getClient(); } catch (RemoteException e) { Log.e(TAG, e.toString()); } @@ -255,9 +257,10 @@ public class BluetoothPbap { */ public boolean isConnected(BluetoothDevice device) { if (VDBG) log("isConnected(" + device + ")"); - if (mService != null) { + final IBluetoothPbap service = mService; + if (service != null) { try { - return mService.isConnected(device); + return service.isConnected(device); } catch (RemoteException e) { Log.e(TAG, e.toString()); } @@ -275,9 +278,10 @@ public class BluetoothPbap { */ public boolean disconnect() { if (DBG) log("disconnect()"); - if (mService != null) { + final IBluetoothPbap service = mService; + if (service != null) { try { - mService.disconnect(); + service.disconnect(); return true; } catch (RemoteException e) { Log.e(TAG, e.toString()); |