Android 如何抑制BluetoothLeScanner日志?

Android 如何抑制BluetoothLeScanner日志?,android,bluetooth,Android,Bluetooth,我正试图摆脱那些讨厌的日志 11-17 09:56:46.102 24862-29194/my.app D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=68:F7:F1:66:7F:58, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=null, mManufacturerSpecificData={76=[12, 14, 0, -33, 112, -93, -

我正试图摆脱那些讨厌的日志

11-17 09:56:46.102 24862-29194/my.app D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=68:F7:F1:66:7F:58, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=null, mManufacturerSpecificData={76=[12, 14, 0, -33, 112, -93, -94, 51, 81, -23, 24, 31, -110, 121, 116, -12]}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=null], mRssi=-59, mTimestampNanos=7365019329223}
查看
BluetoothLeScanner
内部,可以发现这种行为是通过DBG变量控制的

    /**
     * Callback reporting an LE scan result.
     *
     * @hide
     */
    @Override
    public void onScanResult(final ScanResult scanResult) {
        if (DBG) Log.d(TAG, "onScanResult() - " + scanResult.toString());

        // Check null in case the scan has been stopped
        synchronized (this) {
            if (mClientIf <= 0) return;
        }
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES, scanResult);
            }
        });

    }

但这看起来毫无效果。事件调试器无法命中
onScanResult
方法中的断点。有人知道为什么这不起作用吗?我自己的怀疑是,这段代码可能是在与主应用程序不同的类加载器或进程中执行的。

您可以使用正则表达式过滤器将它们隐藏在logcat@TimCastelijns使用正则表达式来白名单/黑名单logcat是一个开发人员hell@Odys如果你有更好的解决方案,一定要给出
try {
        Field dbg = BluetoothLeScanner.class.getDeclaredField("DBG");
        dbg.setAccessible(true);
        System.out.println("dbg = " + dbg.getBoolean(null));
        dbg.setBoolean(null, false);

        Field vdbg = BluetoothLeScanner.class.getDeclaredField("VDBG");
        vdbg.setAccessible(true);
        System.out.println("vdbg = " + vdbg.getBoolean(null));
        vdbg.setBoolean(null, false);

    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }