Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebd94d7c authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Merge "Merge "Bluetooth: Fix startAdvertisingSet error handling" am:...

Merge "Merge "Bluetooth: Fix startAdvertisingSet error handling" am: ed12213b am: e9fe9957 am: 94cd5b22 am: b7758172" into oc-mr1-dev-plus-aosp
am: 0374973a

Change-Id: I862b5e5048c225f84494b8329f3b85fbaa754c20
parents 433d3ab9 0374973a
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -415,7 +415,8 @@ public final class BluetoothLeAdvertiser {
          gatt = mBluetoothManager.getBluetoothGatt();
        } catch (RemoteException e) {
          Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
          throw new IllegalStateException("Failed to get Bluetooth");
          postStartSetFailure(handler, callback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
          return;
        }

        IAdvertisingSetCallback wrapped = wrap(callback, handler);
@@ -429,7 +430,8 @@ public final class BluetoothLeAdvertiser {
                                     periodicData, duration, maxExtendedAdvertisingEvents, wrapped);
        } catch (RemoteException e) {
          Log.e(TAG, "Failed to start advertising set - ", e);
          throw new IllegalStateException("Failed to start advertising set");
          postStartSetFailure(handler, callback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
          return;
        }
    }

@@ -648,6 +650,16 @@ public final class BluetoothLeAdvertiser {
        };
    }

    private void postStartSetFailure(Handler handler, final AdvertisingSetCallback callback,
        final int error) {
        handler.post(new Runnable() {
              @Override
              public void run() {
                  callback.onAdvertisingSetStarted(null, 0, error);
              }
          });
    }

    private void postStartFailure(final AdvertiseCallback callback, final int error) {
        mHandler.post(new Runnable() {
            @Override