Loading framework/java/android/bluetooth/BluetoothAdapter.java +38 −12 Original line number Diff line number Diff line Loading @@ -880,17 +880,44 @@ public final class BluetoothAdapter { } executor = mExecutor; callback = mCallback; // null out to allow garbage collection, prevent triggering callback more than once mExecutor = null; mCallback = null; } Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { if (info == null) { executor.execute(() -> callback.onBluetoothActivityEnergyInfoError( BluetoothStatusCodes.FEATURE_NOT_SUPPORTED)); } else { executor.execute(() -> callback.onBluetoothActivityEnergyInfoAvailable(info)); } } finally { Binder.restoreCallingIdentity(identity); } } /** * Framework only method that is called when the service can't be reached. */ public void onError(int errorCode) { Executor executor; OnBluetoothActivityEnergyInfoCallback callback; synchronized (mLock) { if (mExecutor == null || mCallback == null) { return; } executor = mExecutor; callback = mCallback; mExecutor = null; mCallback = null; } final long identity = Binder.clearCallingIdentity(); try { executor.execute(() -> callback.onBluetoothActivityEnergyInfoError( errorCode)); } finally { Binder.restoreCallingIdentity(identity); } } } Loading Loading @@ -2780,21 +2807,20 @@ public final class BluetoothAdapter { @NonNull OnBluetoothActivityEnergyInfoCallback callback) { requireNonNull(executor, "executor cannot be null"); requireNonNull(callback, "callback cannot be null"); OnBluetoothActivityEnergyInfoProxy proxy = new OnBluetoothActivityEnergyInfoProxy(executor, callback); try { mServiceLock.readLock().lock(); if (mService != null) { mService.requestActivityInfo( new OnBluetoothActivityEnergyInfoProxy(executor, callback), proxy, mAttributionSource); } else { executor.execute(() -> callback.onBluetoothActivityEnergyInfoError( BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND)); proxy.onError(BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND); } } catch (RemoteException e) { Log.e(TAG, "getControllerActivityEnergyInfoCallback: " + e); Binder.clearCallingIdentity(); executor.execute(() -> callback.onBluetoothActivityEnergyInfoError( BluetoothStatusCodes.ERROR_UNKNOWN)); proxy.onError(BluetoothStatusCodes.ERROR_UNKNOWN); } finally { mServiceLock.readLock().unlock(); } Loading Loading
framework/java/android/bluetooth/BluetoothAdapter.java +38 −12 Original line number Diff line number Diff line Loading @@ -880,17 +880,44 @@ public final class BluetoothAdapter { } executor = mExecutor; callback = mCallback; // null out to allow garbage collection, prevent triggering callback more than once mExecutor = null; mCallback = null; } Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { if (info == null) { executor.execute(() -> callback.onBluetoothActivityEnergyInfoError( BluetoothStatusCodes.FEATURE_NOT_SUPPORTED)); } else { executor.execute(() -> callback.onBluetoothActivityEnergyInfoAvailable(info)); } } finally { Binder.restoreCallingIdentity(identity); } } /** * Framework only method that is called when the service can't be reached. */ public void onError(int errorCode) { Executor executor; OnBluetoothActivityEnergyInfoCallback callback; synchronized (mLock) { if (mExecutor == null || mCallback == null) { return; } executor = mExecutor; callback = mCallback; mExecutor = null; mCallback = null; } final long identity = Binder.clearCallingIdentity(); try { executor.execute(() -> callback.onBluetoothActivityEnergyInfoError( errorCode)); } finally { Binder.restoreCallingIdentity(identity); } } } Loading Loading @@ -2780,21 +2807,20 @@ public final class BluetoothAdapter { @NonNull OnBluetoothActivityEnergyInfoCallback callback) { requireNonNull(executor, "executor cannot be null"); requireNonNull(callback, "callback cannot be null"); OnBluetoothActivityEnergyInfoProxy proxy = new OnBluetoothActivityEnergyInfoProxy(executor, callback); try { mServiceLock.readLock().lock(); if (mService != null) { mService.requestActivityInfo( new OnBluetoothActivityEnergyInfoProxy(executor, callback), proxy, mAttributionSource); } else { executor.execute(() -> callback.onBluetoothActivityEnergyInfoError( BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND)); proxy.onError(BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND); } } catch (RemoteException e) { Log.e(TAG, "getControllerActivityEnergyInfoCallback: " + e); Binder.clearCallingIdentity(); executor.execute(() -> callback.onBluetoothActivityEnergyInfoError( BluetoothStatusCodes.ERROR_UNKNOWN)); proxy.onError(BluetoothStatusCodes.ERROR_UNKNOWN); } finally { mServiceLock.readLock().unlock(); } Loading