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

Commit 347a882d authored by Wei Wang's avatar Wei Wang Committed by Android (Google) Code Review
Browse files

Merge "Clean up advertise and scan clients upon bluetooth down." into lmp-dev

parents d4eb10a8 ee80922c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1428,6 +1428,9 @@ public final class BluetoothAdapter {
                if (VDBG) Log.d(TAG, "onBluetoothServiceDown: " + mService);
                synchronized (mManagerCallback) {
                    mService = null;
                    mLeScanClients.clear();
                    if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup();
                    if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup();
                    for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){
                        try {
                            if (cb != null) {
+9 −0
Original line number Diff line number Diff line
@@ -175,6 +175,15 @@ public final class BluetoothLeAdvertiser {
        }
    }

    /**
     * Cleans up advertise clients. Should be called when bluetooth is down.
     *
     * @hide
     */
    public void cleanup() {
        mLeAdvertisers.clear();
    }

    // Compute the size of the advertise data.
    private int totalBytes(AdvertiseData data) {
        if (data == null) {
+9 −0
Original line number Diff line number Diff line
@@ -208,6 +208,15 @@ public final class BluetoothLeScanner {
        startScan(scanFilters, settings, callback, scanStorages);
    }

    /**
     * Cleans up scan clients. Should be called when bluetooth is down.
     *
     * @hide
     */
    public void cleanup() {
        mLeScanClients.clear();
    }

    /**
     * Bluetooth GATT interface callbacks
     */
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public class Utils {
        StringBuilder buffer = new StringBuilder();
        buffer.append('{');
        for (int i = 0; i < array.size(); ++i) {
            buffer.append(array.keyAt(i)).append("=").append(array.valueAt(i));
            buffer.append(array.keyAt(i)).append("=").append(Arrays.toString(array.valueAt(i)));
        }
        buffer.append('}');
        return buffer.toString();