diff options
| author | Lee Shombert <shombert@google.com> | 2020-04-08 21:02:22 +0000 |
|---|---|---|
| committer | Tim Murray <timmurray@google.com> | 2020-04-08 21:12:52 +0000 |
| commit | 2a8802d2ca8ca6f1902d2c40ffaacc11c40e9e44 (patch) | |
| tree | bc618c21793146565b3a82e4e4c4fe5410c4b595 /core/java/android/bluetooth/BluetoothAdapter.java | |
| parent | 81a3e1c578b5618bf02968a9b4402e70592b7b9b (diff) | |
Revert "Fix exception handling in getState() binder cache"
This reverts commit 81a3e1c578b5618bf02968a9b4402e70592b7b9b.
Bug: b/153505953
Change-Id: I58c46e534ccadf332d10fff8f99c85ad24340c27
Diffstat (limited to 'core/java/android/bluetooth/BluetoothAdapter.java')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothAdapter.java | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index fc48e7f18f5f..f216db6fc717 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -979,14 +979,17 @@ public final class BluetoothAdapter { 8, BLUETOOTH_GET_STATE_CACHE_PROPERTY) { @Override protected Integer recompute(Void query) { - // This function must be called while holding the - // mServiceLock, and with mService not null. The public - // getState() method makes this guarantee. try { - return mService.getState(); + mServiceLock.readLock().lock(); + if (mService != null) { + return mService.getState(); + } } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); + Log.e(TAG, "", e); + } finally { + mServiceLock.readLock().unlock(); } + return BluetoothAdapter.STATE_OFF; } }; @@ -1013,24 +1016,7 @@ public final class BluetoothAdapter { @RequiresPermission(Manifest.permission.BLUETOOTH) @AdapterState public int getState() { - int state = BluetoothAdapter.STATE_OFF; - - try { - mServiceLock.readLock().lock(); - // The test for mService must either be outside the cache, or - // the cache must be invalidated when mService changes. - if (mService != null) { - state = mBluetoothGetStateCache.query(null); - } - } catch (RuntimeException e) { - if (e.getCause() instanceof RemoteException) { - Log.e(TAG, "", e.getCause()); - } else { - throw e; - } - } finally { - mServiceLock.readLock().unlock(); - } + int state = mBluetoothGetStateCache.query(null); // Consider all internal states as OFF if (state == BluetoothAdapter.STATE_BLE_ON || state == BluetoothAdapter.STATE_BLE_TURNING_ON |
