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

Commit eeaa8763 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Turn off logspam (Bluetooth)"

parents c4d77bf9 04a34b54
Loading
Loading
Loading
Loading
+33 −23
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class AdvertiseManager {
     * Constructor of {@link AdvertiseManager}.
     */
    AdvertiseManager(GattService service, AdapterService adapterService) {
        logd("advertise manager created");
        if (DBG) Log.d(TAG, "advertise manager created");
        mService = service;
        mAdapterService = adapterService;
    }
@@ -74,7 +74,7 @@ class AdvertiseManager {
    }

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

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

        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 {
        logd("onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable=" + enable
                + ", status=" + status);
        if (DBG) {
            Log.d(TAG, "onAdvertisingSetEnabled() - advertiser_id=" + advertiser_id + ", enable="
                            + enable + ", status=" + status);
        }

        Map.Entry<IBinder, AdvertiserInfo> entry = findAdvertiser(advertiser_id);
        if (entry == null) {
@@ -197,14 +200,14 @@ class AdvertiseManager {
        int cb_id = --sTempRegistrationId;
        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,
                periodic_data, duration, maxExtAdvEvents, cb_id);
    }

    void onOwnAddressRead(int advertiser_id, int addressType, String address)
            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);
        if (entry == null) {
@@ -284,7 +287,10 @@ class AdvertiseManager {
    }

    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);
        if (entry == null) {
@@ -297,7 +303,9 @@ class AdvertiseManager {
    }

    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);
        if (entry == null) {
@@ -311,8 +319,10 @@ class AdvertiseManager {

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

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

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

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

    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);
        }

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

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

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

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

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

@@ -1134,7 +1135,8 @@ public class GattService extends ProfileService {

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

    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);
        int position = 0;
        long now = SystemClock.elapsedRealtimeNanos();
@@ -1255,7 +1257,7 @@ public class GattService extends ProfileService {
            System.arraycopy(advertiseBytes, 0, scanRecord, 0, advertisePacketLen);
            System.arraycopy(scanResponseBytes, 0, scanRecord,
                    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),
                    rssi, timestampNanos));
        }
@@ -1327,9 +1329,11 @@ public class GattService extends ProfileService {
                                        & ScanSettings.CALLBACK_TYPE_MATCH_LOST) != 0)) {
                    app.callback.onFoundOrLost(false, result);
                } else {
                    if (DBG) {
                        Log.d(TAG, "Not reporting onlost/onfound : " + advertiserState
                                + " scannerId = " + client.scannerId
                                + " callbackType " + settings.getCallbackType());
                                        + " scannerId = " + client.scannerId + " callbackType "
                                        + settings.getCallbackType());
                    }
                }
            }
        }
@@ -1341,7 +1345,7 @@ public class GattService extends ProfileService {
            Log.e(TAG, "Advertise app or callback is null");
            return;
        }
        Log.d(TAG, "onScanParamSetupCompleted : " + status);
        if (DBG) Log.d(TAG, "onScanParamSetupCompleted : " + status);
    }

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

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

@@ -1636,7 +1641,7 @@ public class GattService extends ProfileService {

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

@@ -1649,7 +1654,7 @@ public class GattService extends ProfileService {

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

@@ -2187,7 +2192,7 @@ public class GattService extends ProfileService {

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

@@ -2200,7 +2205,7 @@ public class GattService extends ProfileService {

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

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

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

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

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

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

    void onSyncReport(int sync_handle, int tx_power, int rssi, int data_status, byte[] data)
            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);
        if (entry == null) {
@@ -155,7 +157,7 @@ class PeriodicScanManager {
    }

    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);
        if (entry == null) {
@@ -184,13 +186,13 @@ class PeriodicScanManager {
        int cb_id = --sTempRegistrationId;
        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);
    }

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

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

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

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

    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) {
            mLatch.countDown();
        }
@@ -223,7 +223,7 @@ public class ScanManager {

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

            if (!isScanSupported(client)) {
                Log.e(TAG, "Scan settings not supported");
@@ -272,7 +272,7 @@ public class ScanManager {
                mScanNative.stopBatchScan(client);
            }
            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);
            }
        }
@@ -440,15 +440,19 @@ public class ScanManager {
        }

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

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

            if (curScanSetting != Integer.MIN_VALUE &&
                    curScanSetting != ScanSettings.SCAN_MODE_OPPORTUNISTIC) {
@@ -459,15 +463,18 @@ public class ScanManager {
                    scanWindow = Utils.millsToUnit(scanWindow);
                    scanInterval = Utils.millsToUnit(scanInterval);
                    gattClientScanNative(false);
                    logd("configureRegularScanParams - scanInterval = " + scanInterval +
                        "configureRegularScanParams - scanWindow = " + scanWindow);
                    if (DBG) {
                        Log.d(TAG, "configureRegularScanParams - scanInterval = " + scanInterval
                                        + "configureRegularScanParams - scanWindow = "
                                        + scanWindow);
                    }
                    gattSetScanParametersNative(client.scannerId, scanInterval, scanWindow);
                    gattClientScanNative(true);
                    mLastConfiguredScanSetting = curScanSetting;
                }
            } else {
                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();
            // Stop batch if batch scan params changed and previous params is not null.
            if (mBatchScanParms != null && (!mBatchScanParms.equals(batchScanParams))) {
                logd("stopping BLe Batch");
                if (DBG) Log.d(TAG, "stopping BLe Batch");
                resetCountDownLatch();
                gattClientStopBatchScanNative(scannerId);
                waitForCallback();
@@ -550,11 +557,11 @@ public class ScanManager {
            // Start batch if batchScanParams changed and current params is not null.
            if (batchScanParams != null && (!batchScanParams.equals(mBatchScanParms))) {
                int notifyThreshold = 95;
                logd("Starting BLE batch scan");
                if (DBG) Log.d(TAG, "Starting BLE batch scan");
                int resultType = getResultType(batchScanParams);
                int fullScanPercent = getFullScanStoragePercent(resultType);
                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,
                        100 - fullScanPercent, notifyThreshold);
                waitForCallback();
@@ -667,7 +674,7 @@ public class ScanManager {
            }
            mRegularScanClients.remove(client);
            if (numRegularScanClients() == 0) {
                logd("stop scan");
                if (DBG) Log.d(TAG, "stop scan");
                gattClientScanNative(false);
            }
            removeScanFilters(client.scannerId);
@@ -685,7 +692,7 @@ public class ScanManager {
            // The scan should continue for background scans
            configureRegularScanParams();
            if (numRegularScanClients() == 0) {
                logd("stop scan");
                if (DBG) Log.d(TAG, "stop scan");
                gattClientScanNative(false);
            }
        }
@@ -720,7 +727,7 @@ public class ScanManager {
        }

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

        private void addFilterToController(int scannerId, ScanFilterQueue.Entry entry,
                int filterIndex) {
            logd("addFilterToController: " + entry.type);
            if (DBG) Log.d(TAG, "addFilterToController: " + entry.type);
            switch (entry.type) {
                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,
                            0,
                            "", entry.address, (byte) entry.addr_type, new byte[0], new byte[0]);
@@ -931,7 +938,7 @@ public class ScanManager {
                    break;

                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,
                            0,
                            entry.name, "", (byte) 0, new byte[0], new byte[0]);
@@ -970,8 +977,10 @@ public class ScanManager {
            int onLostTimeout = getOnFoundOnLostTimeoutMillis(settings, false);
            int onFoundCount = getOnFoundOnLostSightings(settings);
            onLostTimeout = 10000;
            logd("configureFilterParamter " + onFoundTimeout + " " + onLostTimeout + " "
            if (DBG) {
                Log.d(TAG, "configureFilterParamter " + onFoundTimeout + " " + onLostTimeout + " "
                                + onFoundCount + " " + numOfTrackingEntries);
            }
            FilterParams FiltValue = new FilterParams(scannerId, filterIndex, featureSelection,
                    LIST_LOGIC_TYPE, FILTER_LOGIC_TYPE, rssiThreshold, rssiThreshold, deliveryMode,
                    onFoundTimeout, onLostTimeout, onFoundCount, numOfTrackingEntries);
@@ -1071,7 +1080,10 @@ public class ScanManager {
                    break;
                default:
                    val = 1;
                    logd("Invalid setting for getNumOfMatches() " + settings.getNumOfMatches());
                    if (DBG) {
                        Log.d(TAG, "Invalid setting for getNumOfMatches() "
                                        + settings.getNumOfMatches());
                    }
            }
            return val;
        }
@@ -1151,8 +1163,4 @@ public class ScanManager {

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

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