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

Commit 6ec2c2d1 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Propagate Bluetooth 5 scan result properties

Bug: 30622771
Test: manual tests
Change-Id: Icbb353aa3435a97035c81384fc9031175a934239
parent 48027b3f
Loading
Loading
Loading
Loading
+33 −21
Original line number Original line Diff line number Diff line
@@ -90,6 +90,8 @@ public class GattService extends ProfileService {
    private static final int ADVT_STATE_ONFOUND = 0;
    private static final int ADVT_STATE_ONFOUND = 0;
    private static final int ADVT_STATE_ONLOST = 1;
    private static final int ADVT_STATE_ONLOST = 1;


    private static final int ET_LEGACY_MASK = 0x10;

    private static final UUID[] HID_UUIDS = {
    private static final UUID[] HID_UUIDS = {
        UUID.fromString("00002A4A-0000-1000-8000-00805F9B34FB"),
        UUID.fromString("00002A4A-0000-1000-8000-00805F9B34FB"),
        UUID.fromString("00002A4B-0000-1000-8000-00805F9B34FB"),
        UUID.fromString("00002A4B-0000-1000-8000-00805F9B34FB"),
@@ -618,21 +620,33 @@ public class GattService extends ProfileService {
            }
            }


            ScannerMap.App app = mScannerMap.getById(client.scannerId);
            ScannerMap.App app = mScannerMap.getById(client.scannerId);
            if (app != null) {
            if (app == null) {
                BluetoothDevice device = BluetoothAdapter.getDefaultAdapter()
                continue;
                        .getRemoteDevice(address);
            }
                ScanResult result = new ScanResult(device, ScanRecord.parseFromBytes(adv_data),

                        rssi, SystemClock.elapsedRealtimeNanos());
            BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address);
            ScanResult result = new ScanResult(device, event_type, primary_phy, secondary_phy,
                    advertising_sid, tx_power, rssi, periodic_adv_int,
                    ScanRecord.parseFromBytes(adv_data), SystemClock.elapsedRealtimeNanos());
            // Do no report if location mode is OFF or the client has no location permission
            // Do no report if location mode is OFF or the client has no location permission
            // PEERS_MAC_ADDRESS permission holders always get results
            // PEERS_MAC_ADDRESS permission holders always get results
                if (hasScanResultPermission(client) && matchesFilters(client, result)) {
            if (!hasScanResultPermission(client) || !matchesFilters(client, result)) {
                    try {
                continue;
            }

            ScanSettings settings = client.settings;
            ScanSettings settings = client.settings;
                        if ((settings.getCallbackType() &
            if ((settings.getCallbackType() & ScanSettings.CALLBACK_TYPE_ALL_MATCHES) == 0) {
                                ScanSettings.CALLBACK_TYPE_ALL_MATCHES) != 0) {
                continue;
            }

            // if this is legacy scan, return only legacy scan results
            if (settings.getLegacy() && ((event_type & ET_LEGACY_MASK) == 0)) {
                continue;
            }

            try {
                app.appScanStats.addResult();
                app.appScanStats.addResult();
                app.callback.onScanResult(result);
                app.callback.onScanResult(result);
                        }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "Exception: " + e);
                Log.e(TAG, "Exception: " + e);
                mScannerMap.remove(client.scannerId);
                mScannerMap.remove(client.scannerId);
@@ -640,8 +654,6 @@ public class GattService extends ProfileService {
            }
            }
        }
        }
    }
    }
        }
    }


    void onScannerRegistered(int status, int scannerId, long uuidLsb, long uuidMsb)
    void onScannerRegistered(int status, int scannerId, long uuidLsb, long uuidMsb)
            throws RemoteException {
            throws RemoteException {