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

Commit cc786225 authored by Wei Wang's avatar Wei Wang Committed by Android Git Automerger
Browse files

am 855afa3a: Merge "Use scanner for lagacy LE scan (2/2)." into lmp-dev

* commit '855afa3a':
  Use scanner for lagacy LE scan (2/2).
parents 11b8b227 855afa3a
Loading
Loading
Loading
Loading
+1 −8
Original line number Original line Diff line number Diff line
@@ -213,13 +213,6 @@ class AdvertiseManager {
            return numOfAdvtInstances - 1;
            return numOfAdvtInstances - 1;
        }
        }


        // Check whether all service uuids have been registered to GATT server.
        private boolean isAllServiceRegistered(AdvertiseClient client) {
            List<ParcelUuid> registeredUuids = mService.getRegisteredServiceUuids();
            return containsAll(registeredUuids, client.advertiseData) &&
                    containsAll(registeredUuids, client.scanResponse);
        }

        // Check whether the registeredUuids contains all uuids in advertiseData.
        // Check whether the registeredUuids contains all uuids in advertiseData.
        private boolean containsAll(List<ParcelUuid> registeredUuids, AdvertiseData advertiseData) {
        private boolean containsAll(List<ParcelUuid> registeredUuids, AdvertiseData advertiseData) {
            if (advertiseData == null) {
            if (advertiseData == null) {
@@ -321,7 +314,7 @@ class AdvertiseManager {
            if (data == null) {
            if (data == null) {
                return;
                return;
            }
            }
            boolean includeName = true;
            boolean includeName = data.getIncludeDeviceName();
            boolean includeTxPower = data.getIncludeTxPowerLevel();
            boolean includeTxPower = data.getIncludeTxPowerLevel();
            int appearance = 0;
            int appearance = 0;
            byte[] manufacturerData = data.getManufacturerSpecificData() == null ? new byte[0]
            byte[] manufacturerData = data.getManufacturerSpecificData() == null ? new byte[0]
+3 −34
Original line number Original line Diff line number Diff line
@@ -285,28 +285,12 @@ public class GattService extends ProfileService {
            service.unregisterClient(clientIf);
            service.unregisterClient(clientIf);
        }
        }


        public void startScan(int appIf, boolean isServer) {
            GattService service = getService();
            if (service == null) return;
            service.startScan(appIf, isServer);
        }

        public void startScanWithUuids(int appIf, boolean isServer, ParcelUuid[] ids) {
            GattService service = getService();
            if (service == null) return;
            UUID[] uuids = new UUID[ids.length];
            for(int i = 0; i != ids.length; ++i) {
                uuids[i] = ids[i].getUuid();
            }
            service.startScanWithUuids(appIf, isServer, uuids);
        }

        @Override
        @Override
        public void startScanWithFilters(int appIf, boolean isServer, ScanSettings settings,
        public void startScan(int appIf, boolean isServer, ScanSettings settings,
                List<ScanFilter> filters) {
                List<ScanFilter> filters) {
            GattService service = getService();
            GattService service = getService();
            if (service == null) return;
            if (service == null) return;
            service.startScanWithFilters(appIf, isServer, settings, filters);
            service.startScan(appIf, isServer, settings, filters);
        }
        }


        public void stopScan(int appIf, boolean isServer) {
        public void stopScan(int appIf, boolean isServer) {
@@ -1207,22 +1191,7 @@ public class GattService extends ProfileService {
        return deviceList;
        return deviceList;
    }
    }


    // TODO: Remove this and implement legacy scan using new logic.
    void startScan(int appIf, boolean isServer, ScanSettings settings,
    void startScan(int appIf, boolean isServer) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        configureScanParams(appIf);
        mScanManager.startScan(new ScanClient(appIf, false));
    }

    // TODO: Remove this and implement legacy scan using new logic.
    void startScanWithUuids(int appIf, boolean isServer, UUID[] uuids) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");

        configureScanParams(appIf);
        mScanManager.startScan(new ScanClient(appIf, false, uuids));
    }

    void startScanWithFilters(int appIf, boolean isServer, ScanSettings settings,
            List<ScanFilter> filters) {
            List<ScanFilter> filters) {
        if (DBG) Log.d(TAG, "start scan with filters ");
        if (DBG) Log.d(TAG, "start scan with filters ");
        enforceAdminPermission();
        enforceAdminPermission();
+1 −1
Original line number Original line Diff line number Diff line
@@ -23,7 +23,6 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Looper;
import android.os.Message;
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
@@ -356,6 +355,7 @@ public class ScanManager {
        }
        }


        private void removeScanFilters(int clientIf) {
        private void removeScanFilters(int clientIf) {
            logd("removeScanFilters, clientIf - " + clientIf);
            Deque<Integer> filterIndices = mClientFilterIndexMap.remove(clientIf);
            Deque<Integer> filterIndices = mClientFilterIndexMap.remove(clientIf);
            if (filterIndices != null) {
            if (filterIndices != null) {
                mFilterIndexStack.addAll(filterIndices);
                mFilterIndexStack.addAll(filterIndices);