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

Commit 9fb1791e authored by Wei Wang's avatar Wei Wang
Browse files

Implement batch scan API

Change-Id: Ibb527280a221fbdd0fc6b805a7527c29079294b4
parent b93ccca6
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.bluetooth.le.BluetoothLeAdvertiser;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanResult;
import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
@@ -37,6 +38,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -504,13 +506,7 @@ public final class BluetoothAdapter {
     */
    public BluetoothLeAdvertiser getBluetoothLeAdvertiser() {
        // TODO: Return null if this feature is not supported by hardware.
        try {
            IBluetoothGatt iGatt = mManagerService.getBluetoothGatt();
            return new BluetoothLeAdvertiser(iGatt);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to get BluetoothLeAdvertiser, error: " + e);
            return null;
        }
        return new BluetoothLeAdvertiser(mManagerService);
    }

    /**
@@ -518,13 +514,7 @@ public final class BluetoothAdapter {
     */
    public BluetoothLeScanner getBluetoothLeScanner() {
        // TODO: Return null if BLE scan is not supported by hardware.
        try {
            IBluetoothGatt iGatt = mManagerService.getBluetoothGatt();
            return new BluetoothLeScanner(iGatt);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to get BluetoothLeScanner, error: " + e);
            return null;
        }
        return new BluetoothLeScanner(mManagerService);
    }

    /**
@@ -2137,5 +2127,10 @@ public final class BluetoothAdapter {
        public void onConnectionCongested(String address, boolean congested) {
            // no op
        }

        @Override
        public void onBatchScanResults(List<ScanResult> results) {
            // no op
        }
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.bluetooth;

import android.bluetooth.le.ScanResult;
import android.content.Context;
import android.os.ParcelUuid;
import android.os.RemoteException;
@@ -627,6 +628,11 @@ public final class BluetoothGatt implements BluetoothProfile {
                    Log.w(TAG, "Unhandled exception in callback", ex);
                }
            }

            @Override
            public void onBatchScanResults(List<ScanResult> results) {
                // no op
            }
        };

    /*package*/ BluetoothGatt(Context context, IBluetoothGatt iGatt, BluetoothDevice device,
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ interface IBluetoothGatt {
    void startScanWithFilters(in int appIf, in boolean isServer,
                              in ScanSettings settings, in List<ScanFilter> filters);
    void stopScan(in int appIf, in boolean isServer);
    void flushPendingBatchResults(in int appIf, in boolean isServer);
    void startMultiAdvertising(in int appIf,
                               in AdvertisementData advertiseData,
                               in AdvertisementData scanResponse,
+2 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
package android.bluetooth;

import android.os.ParcelUuid;

import android.bluetooth.le.ScanResult;

/**
 * Callback definitions for interacting with BLE / GATT
@@ -27,6 +27,7 @@ oneway interface IBluetoothGattCallback {
    void onClientConnectionState(in int status, in int clientIf,
                                 in boolean connected, in String address);
    void onScanResult(in String address, in int rssi, in byte[] advData);
    void onBatchScanResults(in List<ScanResult> batchResults);
    void onGetService(in String address, in int srvcType, in int srvcInstId,
                      in ParcelUuid srvcUuid);
    void onGetIncludedService(in String address, in int srvcType, in int srvcInstId,
+6 −0
Original line number Diff line number Diff line
@@ -51,6 +51,12 @@ public abstract class AdvertiseCallback {
     */
    public static final int ADVERTISE_FAILED_CONTROLLER_FAILURE = 5;

    /**
     * Operation fails due to GATT service failure.
     * @hide
     */
    public static final int ADVERTISE_FAILED_GATT_SERVICE_FAILURE = 6;

    /**
     * Callback when advertising operation succeeds.
     *
Loading