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

Commit 23ea34dc authored by Joe Onorato's avatar Joe Onorato
Browse files

Turn off logspam (Bluetooth)

For more information, see https://source.android.com/source/code-style#log-sparingly

Bug: 37252687
Test: development/tools/logblame/medium_idle_test
Change-Id: I8c839eff19fa0b00d1b6a04fbb554b39010884d9
parent ec45e25d
Loading
Loading
Loading
Loading
+33 −23
Original line number Original line Diff line number Diff line
@@ -58,7 +58,7 @@ class AdvertiseManager {
     * Constructor of {@link AdvertiseManager}.
     * Constructor of {@link AdvertiseManager}.
     */
     */
    AdvertiseManager(GattService service, AdapterService adapterService) {
    AdvertiseManager(GattService service, AdapterService adapterService) {
        logd("advertise manager created");
        if (DBG) Log.d(TAG, "advertise manager created");
        mService = service;
        mService = service;
        mAdapterService = adapterService;
        mAdapterService = adapterService;
    }
    }
@@ -74,7 +74,7 @@ class AdvertiseManager {
    }
    }


    void cleanup() {
    void cleanup() {
        logd("cleanup()");
        if (DBG) Log.d(TAG, "cleanup()");
        cleanupNative();
        cleanupNative();
        mAdvertisers.clear();
        mAdvertisers.clear();
        sTempRegistrationId = -1;
        sTempRegistrationId = -1;
@@ -136,9 +136,10 @@ class AdvertiseManager {


    void onAdvertisingSetStarted(int reg_id, int advertiser_id, int tx_power, int status)
    void onAdvertisingSetStarted(int reg_id, int advertiser_id, int tx_power, int status)
            throws Exception {
            throws Exception {
        if (DBG)
        if (DBG) {
            Log.d(TAG, "onAdvertisingSetStarted() - reg_id=" + reg_id + ", advertiser_id="
            Log.d(TAG, "onAdvertisingSetStarted() - reg_id=" + reg_id + ", advertiser_id="
                            + advertiser_id + ", status=" + status);
                            + advertiser_id + ", status=" + status);
        }


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(reg_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(reg_id);


@@ -163,8 +164,10 @@ class AdvertiseManager {
    }
    }


    void onAdvertisingEnabled(int advertiser_id, boolean enable, int status) throws Exception {
    void onAdvertisingEnabled(int advertiser_id, boolean enable, int status) throws Exception {
        logd("onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable=" + enable
        if (DBG) {
                + ", status=" + status);
            Log.d(TAG, "onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable="
                            + enable + ", status=" + status);
        }


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
        if (entry == null) {
@@ -197,14 +200,14 @@ class AdvertiseManager {
        int cb_id = --sTempRegistrationId;
        int cb_id = --sTempRegistrationId;
        mAdvertisers.put(binder, new AdvertiserInfo(cb_id, deathRecipient, callback));
        mAdvertisers.put(binder, new AdvertiserInfo(cb_id, deathRecipient, callback));


        logd("startAdvertisingSet() - reg_id=" + cb_id + ", callback: " + binder);
        if (DBG) Log.d(TAG, "startAdvertisingSet() - reg_id=" + cb_id + ", callback: " + binder);
        startAdvertisingSetNative(parameters, adv_data, scan_response, periodicParameters,
        startAdvertisingSetNative(parameters, adv_data, scan_response, periodicParameters,
                periodic_data, duration, maxExtAdvEvents, cb_id);
                periodic_data, duration, maxExtAdvEvents, cb_id);
    }
    }


    void onOwnAddressRead(int advertiser_id, int addressType, String address)
    void onOwnAddressRead(int advertiser_id, int addressType, String address)
            throws RemoteException {
            throws RemoteException {
        logd("onOwnAddressRead() advertiser_id=" + advertiser_id);
        if (DBG) Log.d(TAG, "onOwnAddressRead() advertiser_id=" + advertiser_id);


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
        if (entry == null) {
@@ -278,7 +281,10 @@ class AdvertiseManager {
    }
    }


    void onAdvertisingDataSet(int advertiser_id, int status) throws Exception {
    void onAdvertisingDataSet(int advertiser_id, int status) throws Exception {
        logd("onAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status);
        if (DBG) {
            Log.d(TAG,
                    "onAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status=" + status);
        }


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
        if (entry == null) {
@@ -291,7 +297,9 @@ class AdvertiseManager {
    }
    }


    void onScanResponseDataSet(int advertiser_id, int status) throws Exception {
    void onScanResponseDataSet(int advertiser_id, int status) throws Exception {
        logd("onScanResponseDataSet() advertiser_id=" + advertiser_id + ", status=" + status);
        if (DBG)
            Log.d(TAG, "onScanResponseDataSet() advertiser_id=" + advertiser_id + ", status="
                            + status);


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
        if (entry == null) {
@@ -305,8 +313,10 @@ class AdvertiseManager {


    void onAdvertisingParametersUpdated(int advertiser_id, int tx_power, int status)
    void onAdvertisingParametersUpdated(int advertiser_id, int tx_power, int status)
            throws Exception {
            throws Exception {
        logd("onAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", tx_power="
        if (DBG) {
                + tx_power + ", status=" + status);
            Log.d(TAG, "onAdvertisingParametersUpdated() advertiser_id=" + advertiser_id
                            + ", tx_power=" + tx_power + ", status=" + status);
        }


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
        if (entry == null) {
@@ -319,8 +329,10 @@ class AdvertiseManager {
    }
    }


    void onPeriodicAdvertisingParametersUpdated(int advertiser_id, int status) throws Exception {
    void onPeriodicAdvertisingParametersUpdated(int advertiser_id, int status) throws Exception {
        logd("onPeriodicAdvertisingParametersUpdated() advertiser_id=" + advertiser_id + ", status="
        if (DBG) {
                + status);
            Log.d(TAG, "onPeriodicAdvertisingParametersUpdated() advertiser_id=" + advertiser_id
                            + ", status=" + status);
        }


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
        if (entry == null) {
@@ -334,8 +346,10 @@ class AdvertiseManager {
    }
    }


    void onPeriodicAdvertisingDataSet(int advertiser_id, int status) throws Exception {
    void onPeriodicAdvertisingDataSet(int advertiser_id, int status) throws Exception {
        logd("onPeriodicAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status="
        if (DBG) {
            Log.d(TAG, "onPeriodicAdvertisingDataSet() advertiser_id=" + advertiser_id + ", status="
                            + status);
                            + status);
        }


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
        if (entry == null) {
@@ -349,8 +363,10 @@ class AdvertiseManager {


    void onPeriodicAdvertisingEnabled(int advertiser_id, boolean enable, int status)
    void onPeriodicAdvertisingEnabled(int advertiser_id, boolean enable, int status)
            throws Exception {
            throws Exception {
        logd("onPeriodicAdvertisingEnabled() advertiser_id=" + advertiser_id + ", status="
        if (DBG) {
            Log.d(TAG, "onPeriodicAdvertisingEnabled() advertiser_id=" + advertiser_id + ", status="
                            + status);
                            + status);
        }


        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
        if (entry == null) {
@@ -362,12 +378,6 @@ class AdvertiseManager {
        callback.onPeriodicAdvertisingEnabled(advertiser_id, enable, status);
        callback.onPeriodicAdvertisingEnabled(advertiser_id, enable, status);
    }
    }


    private void logd(String s) {
        if (DBG) {
            Log.d(TAG, s);
        }
    }

    static {
    static {
        classInitNative();
        classInitNative();
    }
    }
+18 −13
Original line number Original line Diff line number Diff line
@@ -716,13 +716,14 @@ public class GattService extends ProfileService {
    void onScanResult(int event_type, int address_type, String address, int primary_phy,
    void onScanResult(int event_type, int address_type, String address, int primary_phy,
            int secondary_phy, int advertising_sid, int tx_power, int rssi, int periodic_adv_int,
            int secondary_phy, int advertising_sid, int tx_power, int rssi, int periodic_adv_int,
            byte[] adv_data) {
            byte[] adv_data) {
        if (VDBG)
        if (VDBG) {
            Log.d(TAG, "onScanResult() - event_type=0x" + Integer.toHexString(event_type)
            Log.d(TAG, "onScanResult() - event_type=0x" + Integer.toHexString(event_type)
                            + ", address_type=" + address_type + ", address=" + address
                            + ", address_type=" + address_type + ", address=" + address
                            + ", primary_phy=" + primary_phy + ", secondary_phy=" + secondary_phy
                            + ", primary_phy=" + primary_phy + ", secondary_phy=" + secondary_phy
                            + ", advertising_sid=0x" + Integer.toHexString(advertising_sid)
                            + ", advertising_sid=0x" + Integer.toHexString(advertising_sid)
                            + ", tx_power=" + tx_power + ", rssi=" + rssi + ", periodic_adv_int=0x"
                            + ", tx_power=" + tx_power + ", rssi=" + rssi + ", periodic_adv_int=0x"
                            + Integer.toHexString(periodic_adv_int));
                            + Integer.toHexString(periodic_adv_int));
        }
        List<UUID> remoteUuids = parseUuids(adv_data);
        List<UUID> remoteUuids = parseUuids(adv_data);
        addScanResult();
        addScanResult();


@@ -1203,7 +1204,8 @@ public class GattService extends ProfileService {


    void onBatchScanStorageConfigured(int status, int clientIf) {
    void onBatchScanStorageConfigured(int status, int clientIf) {
        if (DBG) {
        if (DBG) {
            Log.d(TAG, "onBatchScanStorageConfigured() - clientIf="+ clientIf + ", status=" + status);
            Log.d(TAG,
                    "onBatchScanStorageConfigured() - clientIf=" + clientIf + ", status=" + status);
        }
        }
        mScanManager.callbackDone(clientIf, status);
        mScanManager.callbackDone(clientIf, status);
    }
    }
@@ -1321,7 +1323,7 @@ public class GattService extends ProfileService {
    }
    }


    private Set<ScanResult> parseFullResults(int numRecords, byte[] batchRecord) {
    private Set<ScanResult> parseFullResults(int numRecords, byte[] batchRecord) {
        Log.d(TAG, "Batch record : " + Arrays.toString(batchRecord));
        if (DBG) Log.d(TAG, "Batch record : " + Arrays.toString(batchRecord));
        Set<ScanResult> results = new HashSet<ScanResult>(numRecords);
        Set<ScanResult> results = new HashSet<ScanResult>(numRecords);
        int position = 0;
        int position = 0;
        long now = SystemClock.elapsedRealtimeNanos();
        long now = SystemClock.elapsedRealtimeNanos();
@@ -1350,7 +1352,7 @@ public class GattService extends ProfileService {
            System.arraycopy(advertiseBytes, 0, scanRecord, 0, advertisePacketLen);
            System.arraycopy(advertiseBytes, 0, scanRecord, 0, advertisePacketLen);
            System.arraycopy(scanResponseBytes, 0, scanRecord,
            System.arraycopy(scanResponseBytes, 0, scanRecord,
                    advertisePacketLen, scanResponsePacketLen);
                    advertisePacketLen, scanResponsePacketLen);
            Log.d(TAG, "ScanRecord : " + Arrays.toString(scanRecord));
            if (DBG) Log.d(TAG, "ScanRecord : " + Arrays.toString(scanRecord));
            results.add(new ScanResult(device, ScanRecord.parseFromBytes(scanRecord),
            results.add(new ScanResult(device, ScanRecord.parseFromBytes(scanRecord),
                    rssi, timestampNanos));
                    rssi, timestampNanos));
        }
        }
@@ -1432,9 +1434,11 @@ public class GattService extends ProfileService {
                                ScanSettings.CALLBACK_TYPE_MATCH_LOST, client);
                                ScanSettings.CALLBACK_TYPE_MATCH_LOST, client);
                    }
                    }
                } else {
                } else {
                    if (DBG) {
                        Log.d(TAG, "Not reporting onlost/onfound : " + advertiserState
                        Log.d(TAG, "Not reporting onlost/onfound : " + advertiserState
                                + " scannerId = " + client.scannerId
                                        + " scannerId = " + client.scannerId + " callbackType "
                                + " callbackType " + settings.getCallbackType());
                                        + settings.getCallbackType());
                    }
                }
                }
            }
            }
        }
        }
@@ -1446,7 +1450,7 @@ public class GattService extends ProfileService {
            Log.e(TAG, "Advertise app or callback is null");
            Log.e(TAG, "Advertise app or callback is null");
            return;
            return;
        }
        }
        Log.d(TAG, "onScanParamSetupCompleted : " + status);
        if (DBG) Log.d(TAG, "onScanParamSetupCompleted : " + status);
    }
    }


    // callback from ScanManager for dispatch of errors apps.
    // callback from ScanManager for dispatch of errors apps.
@@ -1791,9 +1795,10 @@ public class GattService extends ProfileService {
    void clientConnect(int clientIf, String address, boolean isDirect, int transport, int phy) {
    void clientConnect(int clientIf, String address, boolean isDirect, int transport, int phy) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");


        if (DBG)
        if (DBG) {
            Log.d(TAG, "clientConnect() - address=" + address + ", isDirect=" + isDirect + ", phy= "
            Log.d(TAG, "clientConnect() - address=" + address + ", isDirect=" + isDirect + ", phy= "
                            + phy);
                            + phy);
        }
        gattClientConnectNative(clientIf, address, isDirect, transport, phy);
        gattClientConnectNative(clientIf, address, isDirect, transport, phy);
    }
    }


@@ -1811,7 +1816,7 @@ public class GattService extends ProfileService {


        Integer connId = mClientMap.connIdByAddress(clientIf, address);
        Integer connId = mClientMap.connIdByAddress(clientIf, address);
        if (connId == null) {
        if (connId == null) {
            Log.d(TAG, "clientSetPreferredPhy() - no connection to " + address);
            if (DBG) Log.d(TAG, "clientSetPreferredPhy() - no connection to " + address);
            return;
            return;
        }
        }


@@ -1824,7 +1829,7 @@ public class GattService extends ProfileService {


        Integer connId = mClientMap.connIdByAddress(clientIf, address);
        Integer connId = mClientMap.connIdByAddress(clientIf, address);
        if (connId == null) {
        if (connId == null) {
            Log.d(TAG, "clientReadPhy() - no connection to " + address);
            if (DBG) Log.d(TAG, "clientReadPhy() - no connection to " + address);
            return;
            return;
        }
        }


@@ -2362,7 +2367,7 @@ public class GattService extends ProfileService {


        Integer connId = mServerMap.connIdByAddress(serverIf, address);
        Integer connId = mServerMap.connIdByAddress(serverIf, address);
        if (connId == null) {
        if (connId == null) {
            Log.d(TAG, "serverSetPreferredPhy() - no connection to " + address);
            if (DBG) Log.d(TAG, "serverSetPreferredPhy() - no connection to " + address);
            return;
            return;
        }
        }


@@ -2375,7 +2380,7 @@ public class GattService extends ProfileService {


        Integer connId = mServerMap.connIdByAddress(serverIf, address);
        Integer connId = mServerMap.connIdByAddress(serverIf, address);
        if (connId == null) {
        if (connId == null) {
            Log.d(TAG, "serverReadPhy() - no connection to " + address);
            if (DBG) Log.d(TAG, "serverReadPhy() - no connection to " + address);
            return;
            return;
        }
        }


+1 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@ package com.android.bluetooth.gatt;
 * GattService configuration.
 * GattService configuration.
 */
 */
/*package*/ class GattServiceConfig {
/*package*/ class GattServiceConfig {
    public static final boolean DBG = true;
    public static final boolean DBG = false;
    public static final boolean VDBG = false;
    public static final boolean VDBG = false;
    public static final String TAG_PREFIX = "BtGatt.";
    public static final String TAG_PREFIX = "BtGatt.";
    public static final boolean DEBUG_ADMIN = true;
    public static final boolean DEBUG_ADMIN = true;
+10 −14
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ class PeriodicScanManager {
     * Constructor of {@link SyncManager}.
     * Constructor of {@link SyncManager}.
     */
     */
    PeriodicScanManager(AdapterService adapterService) {
    PeriodicScanManager(AdapterService adapterService) {
        logd("advertise manager created");
        if (DBG) Log.d(TAG, "advertise manager created");
        mAdapterService = adapterService;
        mAdapterService = adapterService;
    }
    }


@@ -62,7 +62,7 @@ class PeriodicScanManager {
    }
    }


    void cleanup() {
    void cleanup() {
        logd("cleanup()");
        if (DBG) Log.d(TAG, "cleanup()");
        cleanupNative();
        cleanupNative();
        mSyncs.clear();
        mSyncs.clear();
        sTempRegistrationId = -1;
        sTempRegistrationId = -1;
@@ -114,8 +114,10 @@ class PeriodicScanManager {


    void onSyncStarted(int reg_id, int sync_handle, int sid, int address_type, String address,
    void onSyncStarted(int reg_id, int sync_handle, int sid, int address_type, String address,
            int phy, int interval, int status) throws Exception {
            int phy, int interval, int status) throws Exception {
        logd("onSyncStarted() - reg_id=" + reg_id + ", sync_handle=" + sync_handle + ", status="
        if (DBG) {
                + status);
            Log.d(TAG, "onSyncStarted() - reg_id=" + reg_id + ", sync_handle=" + sync_handle
                            + ", status=" + status);
        }


        Map.Entry<IBinder, SyncInfo> entry = findSync(reg_id);
        Map.Entry<IBinder, SyncInfo> entry = findSync(reg_id);
        if (entry == null) {
        if (entry == null) {
@@ -140,7 +142,7 @@ class PeriodicScanManager {


    void onSyncReport(int sync_handle, int tx_power, int rssi, int data_status, byte[] data)
    void onSyncReport(int sync_handle, int tx_power, int rssi, int data_status, byte[] data)
            throws Exception {
            throws Exception {
        logd("onSyncReport() - sync_handle=" + sync_handle);
        if (DBG) Log.d(TAG, "onSyncReport() - sync_handle=" + sync_handle);


        Map.Entry<IBinder, SyncInfo> entry = findSync(sync_handle);
        Map.Entry<IBinder, SyncInfo> entry = findSync(sync_handle);
        if (entry == null) {
        if (entry == null) {
@@ -155,7 +157,7 @@ class PeriodicScanManager {
    }
    }


    void onSyncLost(int sync_handle) throws Exception {
    void onSyncLost(int sync_handle) throws Exception {
        logd("onSyncLost() - sync_handle=" + sync_handle);
        if (DBG) Log.d(TAG, "onSyncLost() - sync_handle=" + sync_handle);


        Map.Entry<IBinder, SyncInfo> entry = findSync(sync_handle);
        Map.Entry<IBinder, SyncInfo> entry = findSync(sync_handle);
        if (entry == null) {
        if (entry == null) {
@@ -184,13 +186,13 @@ class PeriodicScanManager {
        int cb_id = --sTempRegistrationId;
        int cb_id = --sTempRegistrationId;
        mSyncs.put(binder, new SyncInfo(cb_id, deathRecipient, callback));
        mSyncs.put(binder, new SyncInfo(cb_id, deathRecipient, callback));


        logd("startSync() - reg_id=" + cb_id + ", callback: " + binder);
        if (DBG) Log.d(TAG, "startSync() - reg_id=" + cb_id + ", callback: " + binder);
        startSyncNative(sid, address, skip, timeout, cb_id);
        startSyncNative(sid, address, skip, timeout, cb_id);
    }
    }


    void stopSync(IPeriodicAdvertisingCallback callback) {
    void stopSync(IPeriodicAdvertisingCallback callback) {
        IBinder binder = toBinder(callback);
        IBinder binder = toBinder(callback);
        logd("stopSync() " + binder);
        if (DBG) Log.d(TAG, "stopSync() " + binder);


        SyncInfo sync = mSyncs.remove(binder);
        SyncInfo sync = mSyncs.remove(binder);
        if (sync == null) {
        if (sync == null) {
@@ -210,12 +212,6 @@ class PeriodicScanManager {
        stopSyncNative(sync_handle);
        stopSyncNative(sync_handle);
    }
    }


    private void logd(String s) {
        if (DBG) {
            Log.d(TAG, s);
        }
    }

    static {
    static {
        classInitNative();
        classInitNative();
    }
    }
+33 −25
Original line number Original line Diff line number Diff line
@@ -173,7 +173,7 @@ public class ScanManager {
    }
    }


    void callbackDone(int scannerId, int status) {
    void callbackDone(int scannerId, int status) {
        logd("callback done for scannerId - " + scannerId + " status - " + status);
        if (DBG) Log.d(TAG, "callback done for scannerId - " + scannerId + " status - " + status);
        if (status == 0) {
        if (status == 0) {
            mLatch.countDown();
            mLatch.countDown();
        }
        }
@@ -223,7 +223,7 @@ public class ScanManager {


        void handleStartScan(ScanClient client) {
        void handleStartScan(ScanClient client) {
            Utils.enforceAdminPermission(mService);
            Utils.enforceAdminPermission(mService);
            logd("handling starting scan");
            if (DBG) Log.d(TAG, "handling starting scan");


            if (!isScanSupported(client)) {
            if (!isScanSupported(client)) {
                Log.e(TAG, "Scan settings not supported");
                Log.e(TAG, "Scan settings not supported");
@@ -272,7 +272,7 @@ public class ScanManager {
                mScanNative.stopBatchScan(client);
                mScanNative.stopBatchScan(client);
            }
            }
            if (client.appDied) {
            if (client.appDied) {
                logd("app died, unregister scanner - " + client.scannerId);
                if (DBG) Log.d(TAG, "app died, unregister scanner - " + client.scannerId);
                mService.unregisterScanner(client.scannerId);
                mService.unregisterScanner(client.scannerId);
            }
            }
        }
        }
@@ -440,15 +440,19 @@ public class ScanManager {
        }
        }


        void configureRegularScanParams() {
        void configureRegularScanParams() {
            logd("configureRegularScanParams() - queue=" + mRegularScanClients.size());
            if (DBG) {
                Log.d(TAG, "configureRegularScanParams() - queue=" + mRegularScanClients.size());
            }
            int curScanSetting = Integer.MIN_VALUE;
            int curScanSetting = Integer.MIN_VALUE;
            ScanClient client = getAggressiveClient(mRegularScanClients);
            ScanClient client = getAggressiveClient(mRegularScanClients);
            if (client != null) {
            if (client != null) {
                curScanSetting = client.settings.getScanMode();
                curScanSetting = client.settings.getScanMode();
            }
            }


            logd("configureRegularScanParams() - ScanSetting Scan mode=" + curScanSetting +
            if (DBG) {
                    " mLastConfiguredScanSetting=" + mLastConfiguredScanSetting);
                Log.d(TAG, "configureRegularScanParams() - ScanSetting Scan mode=" + curScanSetting
                                + " mLastConfiguredScanSetting=" + mLastConfiguredScanSetting);
            }


            if (curScanSetting != Integer.MIN_VALUE &&
            if (curScanSetting != Integer.MIN_VALUE &&
                    curScanSetting != ScanSettings.SCAN_MODE_OPPORTUNISTIC) {
                    curScanSetting != ScanSettings.SCAN_MODE_OPPORTUNISTIC) {
@@ -459,15 +463,18 @@ public class ScanManager {
                    scanWindow = Utils.millsToUnit(scanWindow);
                    scanWindow = Utils.millsToUnit(scanWindow);
                    scanInterval = Utils.millsToUnit(scanInterval);
                    scanInterval = Utils.millsToUnit(scanInterval);
                    gattClientScanNative(false);
                    gattClientScanNative(false);
                    logd("configureRegularScanParams - scanInterval = " + scanInterval +
                    if (DBG) {
                        "configureRegularScanParams - scanWindow = " + scanWindow);
                        Log.d(TAG, "configureRegularScanParams - scanInterval = " + scanInterval
                                        + "configureRegularScanParams - scanWindow = "
                                        + scanWindow);
                    }
                    gattSetScanParametersNative(client.scannerId, scanInterval, scanWindow);
                    gattSetScanParametersNative(client.scannerId, scanInterval, scanWindow);
                    gattClientScanNative(true);
                    gattClientScanNative(true);
                    mLastConfiguredScanSetting = curScanSetting;
                    mLastConfiguredScanSetting = curScanSetting;
                }
                }
            } else {
            } else {
                mLastConfiguredScanSetting = curScanSetting;
                mLastConfiguredScanSetting = curScanSetting;
                logd("configureRegularScanParams() - queue emtpy, scan stopped");
                if (DBG) Log.d(TAG, "configureRegularScanParams() - queue emtpy, scan stopped");
            }
            }
        }
        }


@@ -539,7 +546,7 @@ public class ScanManager {
            BatchScanParams batchScanParams = getBatchScanParams();
            BatchScanParams batchScanParams = getBatchScanParams();
            // Stop batch if batch scan params changed and previous params is not null.
            // Stop batch if batch scan params changed and previous params is not null.
            if (mBatchScanParms != null && (!mBatchScanParms.equals(batchScanParams))) {
            if (mBatchScanParms != null && (!mBatchScanParms.equals(batchScanParams))) {
                logd("stopping BLe Batch");
                if (DBG) Log.d(TAG, "stopping BLe Batch");
                resetCountDownLatch();
                resetCountDownLatch();
                gattClientStopBatchScanNative(scannerId);
                gattClientStopBatchScanNative(scannerId);
                waitForCallback();
                waitForCallback();
@@ -550,11 +557,11 @@ public class ScanManager {
            // Start batch if batchScanParams changed and current params is not null.
            // Start batch if batchScanParams changed and current params is not null.
            if (batchScanParams != null && (!batchScanParams.equals(mBatchScanParms))) {
            if (batchScanParams != null && (!batchScanParams.equals(mBatchScanParms))) {
                int notifyThreshold = 95;
                int notifyThreshold = 95;
                logd("Starting BLE batch scan");
                if (DBG) Log.d(TAG, "Starting BLE batch scan");
                int resultType = getResultType(batchScanParams);
                int resultType = getResultType(batchScanParams);
                int fullScanPercent = getFullScanStoragePercent(resultType);
                int fullScanPercent = getFullScanStoragePercent(resultType);
                resetCountDownLatch();
                resetCountDownLatch();
                logd("configuring batch scan storage, appIf " + client.scannerId);
                if (DBG) Log.d(TAG, "configuring batch scan storage, appIf " + client.scannerId);
                gattClientConfigBatchScanStorageNative(client.scannerId, fullScanPercent,
                gattClientConfigBatchScanStorageNative(client.scannerId, fullScanPercent,
                        100 - fullScanPercent, notifyThreshold);
                        100 - fullScanPercent, notifyThreshold);
                waitForCallback();
                waitForCallback();
@@ -667,7 +674,7 @@ public class ScanManager {
            }
            }
            mRegularScanClients.remove(client);
            mRegularScanClients.remove(client);
            if (numRegularScanClients() == 0) {
            if (numRegularScanClients() == 0) {
                logd("stop scan");
                if (DBG) Log.d(TAG, "stop scan");
                gattClientScanNative(false);
                gattClientScanNative(false);
            }
            }
            removeScanFilters(client.scannerId);
            removeScanFilters(client.scannerId);
@@ -684,7 +691,7 @@ public class ScanManager {
            // The scan should continue for background scans
            // The scan should continue for background scans
            configureRegularScanParams();
            configureRegularScanParams();
            if (numRegularScanClients() == 0) {
            if (numRegularScanClients() == 0) {
                logd("stop scan");
                if (DBG) Log.d(TAG, "stop scan");
                gattClientScanNative(false);
                gattClientScanNative(false);
            }
            }
        }
        }
@@ -719,7 +726,7 @@ public class ScanManager {
        }
        }


        void flushBatchResults(int scannerId) {
        void flushBatchResults(int scannerId) {
            logd("flushPendingBatchResults - scannerId = " + scannerId);
            if (DBG) Log.d(TAG, "flushPendingBatchResults - scannerId = " + scannerId);
            if (mBatchScanParms.fullScanscannerId != -1) {
            if (mBatchScanParms.fullScanscannerId != -1) {
                resetCountDownLatch();
                resetCountDownLatch();
                gattClientReadScanReportsNative(mBatchScanParms.fullScanscannerId,
                gattClientReadScanReportsNative(mBatchScanParms.fullScanscannerId,
@@ -898,10 +905,10 @@ public class ScanManager {


        private void addFilterToController(int scannerId, ScanFilterQueue.Entry entry,
        private void addFilterToController(int scannerId, ScanFilterQueue.Entry entry,
                int filterIndex) {
                int filterIndex) {
            logd("addFilterToController: " + entry.type);
            if (DBG) Log.d(TAG, "addFilterToController: " + entry.type);
            switch (entry.type) {
            switch (entry.type) {
                case ScanFilterQueue.TYPE_DEVICE_ADDRESS:
                case ScanFilterQueue.TYPE_DEVICE_ADDRESS:
                    logd("add address " + entry.address);
                    if (DBG) Log.d(TAG, "add address " + entry.address);
                    gattClientScanFilterAddNative(scannerId, entry.type, filterIndex, 0, 0, 0, 0, 0,
                    gattClientScanFilterAddNative(scannerId, entry.type, filterIndex, 0, 0, 0, 0, 0,
                            0,
                            0,
                            "", entry.address, (byte) entry.addr_type, new byte[0], new byte[0]);
                            "", entry.address, (byte) entry.addr_type, new byte[0], new byte[0]);
@@ -924,7 +931,7 @@ public class ScanManager {
                    break;
                    break;


                case ScanFilterQueue.TYPE_LOCAL_NAME:
                case ScanFilterQueue.TYPE_LOCAL_NAME:
                    logd("adding filters: " + entry.name);
                    if (DBG) Log.d(TAG, "adding filters: " + entry.name);
                    gattClientScanFilterAddNative(scannerId, entry.type, filterIndex, 0, 0, 0, 0, 0,
                    gattClientScanFilterAddNative(scannerId, entry.type, filterIndex, 0, 0, 0, 0, 0,
                            0,
                            0,
                            entry.name, "", (byte) 0, new byte[0], new byte[0]);
                            entry.name, "", (byte) 0, new byte[0], new byte[0]);
@@ -963,8 +970,10 @@ public class ScanManager {
            int onLostTimeout = getOnFoundOnLostTimeoutMillis(settings, false);
            int onLostTimeout = getOnFoundOnLostTimeoutMillis(settings, false);
            int onFoundCount = getOnFoundOnLostSightings(settings);
            int onFoundCount = getOnFoundOnLostSightings(settings);
            onLostTimeout = 10000;
            onLostTimeout = 10000;
            logd("configureFilterParamter " + onFoundTimeout + " " + onLostTimeout + " "
            if (DBG) {
                Log.d(TAG, "configureFilterParamter " + onFoundTimeout + " " + onLostTimeout + " "
                                + onFoundCount + " " + numOfTrackingEntries);
                                + onFoundCount + " " + numOfTrackingEntries);
            }
            FilterParams FiltValue = new FilterParams(scannerId, filterIndex, featureSelection,
            FilterParams FiltValue = new FilterParams(scannerId, filterIndex, featureSelection,
                    LIST_LOGIC_TYPE, FILTER_LOGIC_TYPE, rssiThreshold, rssiThreshold, deliveryMode,
                    LIST_LOGIC_TYPE, FILTER_LOGIC_TYPE, rssiThreshold, rssiThreshold, deliveryMode,
                    onFoundTimeout, onLostTimeout, onFoundCount, numOfTrackingEntries);
                    onFoundTimeout, onLostTimeout, onFoundCount, numOfTrackingEntries);
@@ -1064,7 +1073,10 @@ public class ScanManager {
                    break;
                    break;
                default:
                default:
                    val = 1;
                    val = 1;
                    logd("Invalid setting for getNumOfMatches() " + settings.getNumOfMatches());
                    if (DBG) {
                        Log.d(TAG, "Invalid setting for getNumOfMatches() "
                                        + settings.getNumOfMatches());
                    }
            }
            }
            return val;
            return val;
        }
        }
@@ -1144,8 +1156,4 @@ public class ScanManager {


        private native void gattClientReadScanReportsNative(int client_if, int scan_type);
        private native void gattClientReadScanReportsNative(int client_if, int scan_type);
    }
    }

    private void logd(String s) {
        if (DBG) Log.d(TAG, s);
    }
}
}