Есть ли способ улучшить обнаружение маяков с помощью altbeacon при сканировании устройства на переднем плане? - PullRequest
0 голосов
/ 19 апреля 2019

У меня в приложении два фрагмента.Второй фрагмент имеет конфигурацию сканирования маяков на переднем плане, и я установил, что он должен связывать менеджер маяков в onResume () и отменять привязку onPause () с остановкой ранжирования и удалением уведомителя.Когда я перейду от первого фрагмента ко второму фрагменту, сканирование начнется, и он немедленно обнаружит маяки без какой-либо задержки.Однако иногда есть вероятность, что задержка произойдет примерно на 6 ~ 18 секунд с результатом сбора 0 маяков.Ранее я думал, что сообщение logcat «Не останавливать сканирование, потому что это Android N, и мы продолжаем сканирование минимум 6 секунд за раз».что-то связано с задержкой, но я снова провел тестирование и выяснил, что это не является причиной проблемы.Обычно проблема возникает, особенно когда я возвращаюсь к первому фрагменту, а затем снова перехожу ко второму фрагменту и повторяю те же шаги три или четыре раза так быстро и менее чем за 10 секунд, после чего проблема обнаружится, и она не обнаружитсялюбые маяки сразу.Я понимаю, что есть вероятность того, что один из циклов сканирования не обнаружит несколько соседних маяков, но я не думаю, что это связано с задержкой, потому что обычно я не вижу соседних маяков в течение одного или двух циклов, так как они близкимне.

Вот код конфигурации моего менеджера маяков для второго фрагмента:

@Override
public void onResume() {
    super.onResume();
    SystemRequirementsChecker.checkWithDefaultDialogs(getActivity());
    region = new Region("myRegion", Identifier.parse("1495B423-7D70-4D98-9885-51ED275B8378"), Identifier.fromInt(14650), Identifier.fromInt(4477));
    beaconManager1 = BeaconManager.getInstanceForApplication(getApplicationContext());
    beaconManager1.getBeaconParsers().clear();
    beaconManager1.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
    beaconManager1.setDebug(true);
    beaconManager1.bind(this);

}

@Override
public void onPause() {
    try {
        beaconManager1.stopRangingBeaconsInRegion(region);
    } catch (RemoteException e) {
        e.printStackTrace();
    }

    beaconManager1.unbind(this);
    beaconManager1.removeRangeNotifier(rangeNotifier);
    super.onPause();
}

@Override
public void onBeaconServiceConnect() {
    beaconManager1.removeAllRangeNotifiers();
    rangeNotifier = new RangeNotifier() {
        @Override
        public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
            Log.d("Collection: ", "size = " + collection.size());
            Log.d("GetRegion: ", region.getId1().toString());
            if (collection.size() > 0) {
                progressBar.setVisibility(View.GONE);
                btnViewAllItems.setVisibility(View.VISIBLE);
                Log.d("Collection: ", "size = " + collection.size());
                count = 0;
                userInsideHSC = true;
            } else {
                startCount();
            }
        }
    };

    try {
        beaconManager1.startRangingBeaconsInRegion(region);
        beaconManager1.addRangeNotifier(rangeNotifier);
    } catch (RemoteException e) {

    }
}

@Override
public Context getApplicationContext() {
    return getActivity().getApplicationContext();
}

@Override
public void unbindService(ServiceConnection serviceConnection) {
    getActivity().unbindService(serviceConnection);
}

@Override
public boolean bindService(Intent intent, ServiceConnection serviceConnection, int i) {
    return getActivity().bindService(intent, serviceConnection, i);
}

Я использую устройство Samsung Galaxy Note 8 под управлением Android 9 и версию altbeacon 2.16.1.

LogCat:

2019-04-20 12:15:13.172 11452-11452 D/ViewRootImpl@71ce719[NewHomeActivity]: ViewPostIme pointer 1
2019-04-20 12:15:13.186 11452-11452 D/ScrollView: initGoToTop
2019-04-20 12:15:13.218 11452-11452 D/BeaconParser: Parsing beacon layout: m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24
2019-04-20 12:15:13.219 11452-11452 W/BeaconManager: Disabling ScanJobs on Android 8+ may disable delivery of beacon callbacks in the background unless a foreground service is active.
2019-04-20 12:15:13.219 11452-11452 D/BeaconManager: This consumer is not bound.  Binding now: CategoryDetailsFragment{bb6c68a #13 id=0x7f080089}
2019-04-20 12:15:13.219 11452-11452 D/BeaconManager: Binding to service
2019-04-20 12:15:13.225 11452-11452 D/BeaconManager: consumer count is now: 1
2019-04-20 12:15:13.247 11452-11452 D/ViewRootImpl@71ce719[NewHomeActivity]: Relayout returned: old=[0,0][1440,2960] new=[0,0][1440,2960] result=0x1 surface={valid=true 488142176256} changed=false
2019-04-20 12:15:13.249 11452-11452 D/ScrollView:  onsize change changed 
2019-04-20 12:15:13.262 11452-11452 I/CycledLeScanner: Using Android O scanner
2019-04-20 12:15:13.263 11452-11452 I/BeaconService: beaconService version 2.16.1 is starting up on the main process
2019-04-20 12:15:13.263 11452-11452 D/BeaconLocalBroadcastProcessor: Register calls: global=12 instance=1
2019-04-20 12:15:13.269 11452-11452 D/ModelSpecificDistanceCalculator: Finding best distance calculator for 9, PPR1.180610.011, SM-N950F, samsung
2019-04-20 12:15:13.269 11452-11452 D/AndroidModel: Score is 0 for LGE;Nexus 4;KOT49H;4.4.2 compared to samsung;SM-N950F;PPR1.180610.011;9
2019-04-20 12:15:13.269 11452-11452 D/AndroidModel: Score is 0 for LGE;Nexus 5;LPV79;4.4.2 compared to samsung;SM-N950F;PPR1.180610.011;9
2019-04-20 12:15:13.270 11452-11452 D/AndroidModel: Score is 0 for XT1115;Moto X Pro;LXG22.67-7.1;5.0.2 compared to samsung;SM-N950F;PPR1.180610.011;9
2019-04-20 12:15:13.270 11452-11452 W/ModelSpecificDistanceCalculator: Cannot find match for this device.  Using default
2019-04-20 12:15:13.270 11452-11452 D/ModelSpecificDistanceCalculator: Finding best distance calculator for 9, PPR1.180610.011, SM-N950F, samsung
2019-04-20 12:15:13.270 11452-11452 D/AndroidModel: Score is 0 for LGE;Nexus 4;KOT49H;4.4.2 compared to samsung;SM-N950F;PPR1.180610.011;9
2019-04-20 12:15:13.270 11452-11452 D/AndroidModel: Score is 0 for LGE;Nexus 5;LPV79;4.4.2 compared to samsung;SM-N950F;PPR1.180610.011;9
2019-04-20 12:15:13.270 11452-11452 D/AndroidModel: Score is 0 for XT1115;Moto X Pro;LXG22.67-7.1;5.0.2 compared to samsung;SM-N950F;PPR1.180610.011;9
2019-04-20 12:15:13.270 11452-11452 W/ModelSpecificDistanceCalculator: Cannot find match for this device.  Using default
2019-04-20 12:15:13.271 11452-11452 D/BeaconService: No org.altbeacon.beacon.SimulatedScanData class exists.
2019-04-20 12:15:13.271 11452-11452 I/BeaconService: binding
2019-04-20 12:15:13.276 11452-11452 D/BeaconManager: we have a connection to the service now
2019-04-20 12:15:13.276 11452-11452 D/BeaconManager: Not synchronizing settings to service, as it is in the same process
2019-04-20 12:15:13.277 11452-11452 D/BeaconManager: updating background flag to false
2019-04-20 12:15:13.277 11452-11452 D/BeaconManager: updating scan period to 1100, 1000
2019-04-20 12:15:13.278 11452-11452 D/BeaconManager: callback packageName: com.hsc.gutech.hscapp
2019-04-20 12:15:13.279 11452-11452 I/BeaconService: set scan intervals received
2019-04-20 12:15:13.279 11452-11452 D/CycledLeScanner: Set scan periods called with 1100, 1000 Background mode must have changed.
2019-04-20 12:15:13.279 11452-11452 D/CycledLeScanner: We are not in the background.  Cancelling wakeup alarm
2019-04-20 12:15:13.279 11452-11452 D/CycledLeScanner: cancel wakeup alarm: null
2019-04-20 12:15:13.287 11452-11452 D/CycledLeScanner: Set a wakeup alarm to go off in 9223372036703844447 ms: PendingIntent{bd5e63a: android.os.BinderProxy@fb4241}
2019-04-20 12:15:13.288 11452-11452 I/BeaconService: start ranging received
2019-04-20 12:15:13.288 11452-11452 D/BeaconService: Currently ranging 1 regions.
2019-04-20 12:15:13.288 11452-11452 D/CycledLeScanner: start called
2019-04-20 12:15:13.288 11452-11452 D/CycledLeScanner: starting a new scan cycle
2019-04-20 12:15:13.289 11452-11452 D/CycledLeScanner: starting a new bluetooth le scan
2019-04-20 12:15:13.291 11452-11452 D/CycledLeScannerForLollipop: starting a scan in SCAN_MODE_LOW_LATENCY
2019-04-20 12:15:13.291 11452-11452 D/CycledLeScannerForLollipop: Using a non-empty scan filter since this is Samsung 8.1+
2019-04-20 12:15:13.291 11452-11452 D/ScanFilterUtils: Set up a scan filter: BluetoothLeScanFilter [mDeviceName=null, mDeviceAddress=null, mUuid=null, mUuidMask=null, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=4c, mManufacturerData=02 15, mManufacturerDataMask=FF FF]
2019-04-20 12:15:13.291 11452-11452 D/CycledLeScannerForLollipop: Making new Android L scanner
2019-04-20 12:15:13.292 11452-11452 D/BluetoothAdapter: STATE_ON
2019-04-20 12:15:13.292 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 1100 milliseconds
2019-04-20 12:15:13.292 11452-11452 D/CycledLeScanner: Scan started
2019-04-20 12:15:13.292 11452-11452 D/CycledLeScanner: Set scan periods called with 1100, 1000 Background mode must have changed.
2019-04-20 12:15:13.292 11452-11452 D/CycledLeScanner: We are not in the background.  Cancelling wakeup alarm
2019-04-20 12:15:13.292 11452-11452 D/CycledLeScanner: cancel wakeup alarm: PendingIntent{bd5e63a: android.os.BinderProxy@fb4241}
2019-04-20 12:15:13.293 11452-12036 D/BluetoothAdapter: STATE_ON
2019-04-20 12:15:13.295 11452-12036 D/BluetoothAdapter: STATE_ON
2019-04-20 12:15:13.295 11452-12036 D/BluetoothLeScanner: Start Scan with callback
2019-04-20 12:15:13.296 11452-11662 D/BluetoothLeScanner: onScannerRegistered() - status=6 scannerId=-1 mScannerId=0
2019-04-20 12:15:13.301 11452-11452 D/CycledLeScanner: Set a wakeup alarm to go off in 9223372036703844434 ms: PendingIntent{bd5e63a: android.os.BinderProxy@fb4241}
2019-04-20 12:15:14.293 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 99 milliseconds
2019-04-20 12:15:14.392 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 1 milliseconds
2019-04-20 12:15:14.393 11452-11452 D/CycledLeScanner: Done with scan cycle
2019-04-20 12:15:14.394 11452-11452 D/ScanHelper: Beacon simulator not enabled
2019-04-20 12:15:14.395 11452-11452 D/ScanHelper: Calling ranging callback
2019-04-20 12:15:14.395 11452-11452 D/Callback: attempting callback via local broadcast intent: org.altbeacon.beacon.range_notification
2019-04-20 12:15:14.401 11452-11452 D/CycledLeScanner: Not stopping scan because this is Android N and we keep scanning for a minimum of 6 seconds at a time. We will stop in 4894 millisconds.
2019-04-20 12:15:14.401 11452-11452 D/CycledLeScanner: Normalizing between scan period from 1000 to -274
2019-04-20 12:15:14.401 11452-11452 D/CycledLeScanner: starting a new scan cycle
2019-04-20 12:15:14.401 11452-11452 D/CycledLeScanner: We are already scanning and have been for 1111 millis
2019-04-20 12:15:14.402 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 1100 milliseconds
2019-04-20 12:15:14.402 11452-11452 D/CycledLeScanner: Scan started
2019-04-20 12:15:14.402 11452-11452 D/IntentHandler: got ranging data
2019-04-20 12:15:14.402 11452-11452 D/Collection:: size = 0
2019-04-20 12:15:14.403 11452-11452 D/GetRegion:: 1495b423-7d70-4d98-9885-51ed275b8378
2019-04-20 12:15:15.403 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 99 milliseconds
2019-04-20 12:15:15.502 11452-11452 D/CycledLeScanner: Done with scan cycle
2019-04-20 12:15:15.503 11452-11452 D/ScanHelper: Beacon simulator not enabled
2019-04-20 12:15:15.504 11452-11452 D/ScanHelper: Calling ranging callback
2019-04-20 12:15:15.504 11452-11452 D/Callback: attempting callback via local broadcast intent: org.altbeacon.beacon.range_notification
2019-04-20 12:15:15.508 11452-11452 D/CycledLeScanner: Not stopping scan because this is Android N and we keep scanning for a minimum of 6 seconds at a time. We will stop in 3784 millisconds.
2019-04-20 12:15:15.508 11452-11452 D/CycledLeScanner: Normalizing between scan period from 1000 to 719
2019-04-20 12:15:15.509 11452-11452 D/CycledLeScannerForLollipop: This is Android L, but we last saw a beacon only 2635 ago, so we will not keep scanning in background.
2019-04-20 12:15:15.509 11452-11452 D/CycledLeScannerForLollipop: Waiting to start full Bluetooth scan for another 719 milliseconds
2019-04-20 12:15:15.509 11452-11452 D/IntentHandler: got ranging data
2019-04-20 12:15:15.510 11452-11452 D/Collection:: size = 0
2019-04-20 12:15:15.510 11452-11452 D/GetRegion:: 1495b423-7d70-4d98-9885-51ed275b8378
2019-04-20 12:15:16.229 11452-11452 D/CycledLeScanner: starting a new scan cycle
2019-04-20 12:15:16.230 11452-11452 D/CycledLeScanner: We are already scanning and have been for 2939 millis
2019-04-20 12:15:16.230 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 1100 milliseconds
2019-04-20 12:15:16.230 11452-11452 D/CycledLeScanner: Scan started
2019-04-20 12:15:17.232 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 99 milliseconds
2019-04-20 12:15:17.331 11452-11452 D/CycledLeScanner: Done with scan cycle
2019-04-20 12:15:17.332 11452-11452 D/ScanHelper: Beacon simulator not enabled
2019-04-20 12:15:17.332 11452-11452 D/ScanHelper: Calling ranging callback
2019-04-20 12:15:17.333 11452-11452 D/Callback: attempting callback via local broadcast intent: org.altbeacon.beacon.range_notification
2019-04-20 12:15:17.338 11452-11452 D/CycledLeScanner: Not stopping scan because this is Android N and we keep scanning for a minimum of 6 seconds at a time. We will stop in 1955 millisconds.
2019-04-20 12:15:17.338 11452-11452 D/CycledLeScanner: Normalizing between scan period from 1000 to 989
2019-04-20 12:15:17.339 11452-11452 D/CycledLeScannerForLollipop: This is Android L, but we last saw a beacon only 4465 ago, so we will not keep scanning in background.
2019-04-20 12:15:17.339 11452-11452 D/CycledLeScannerForLollipop: Waiting to start full Bluetooth scan for another 989 milliseconds
2019-04-20 12:15:17.340 11452-11452 D/IntentHandler: got ranging data
2019-04-20 12:15:17.340 11452-11452 D/Collection:: size = 0
2019-04-20 12:15:17.341 11452-11452 D/GetRegion:: 1495b423-7d70-4d98-9885-51ed275b8378
2019-04-20 12:15:18.330 11452-11452 D/CycledLeScanner: starting a new scan cycle
2019-04-20 12:15:18.331 11452-11452 D/CycledLeScanner: We are already scanning and have been for 5041 millis
2019-04-20 12:15:18.331 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 1100 milliseconds
2019-04-20 12:15:18.331 11452-11452 D/CycledLeScanner: Scan started
2019-04-20 12:15:19.333 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 98 milliseconds
2019-04-20 12:15:19.431 11452-11452 D/CycledLeScanner: Done with scan cycle
2019-04-20 12:15:19.432 11452-11452 D/ScanHelper: Beacon simulator not enabled
2019-04-20 12:15:19.432 11452-11452 D/ScanHelper: Calling ranging callback
2019-04-20 12:15:19.433 11452-11452 D/Callback: attempting callback via local broadcast intent: org.altbeacon.beacon.range_notification
2019-04-20 12:15:19.436 11452-11452 D/CycledLeScanner: stopping bluetooth le scan
2019-04-20 12:15:19.436 11452-11452 D/CycledLeScannerForLollipop: Stopping scan
2019-04-20 12:15:19.438 11452-12036 D/CycledLeScannerForLollipop: Stopping LE scan on scan handler
2019-04-20 12:15:19.438 11452-11452 D/CycledLeScanner: Normalizing between scan period from 1000 to 989
2019-04-20 12:15:19.439 11452-11452 D/CycledLeScannerForLollipop: This is Android L, but we last saw a beacon only 6565 ago, so we will not keep scanning in background.
2019-04-20 12:15:19.439 11452-11452 D/CycledLeScannerForLollipop: Waiting to start full Bluetooth scan for another 989 milliseconds
2019-04-20 12:15:19.439 11452-11452 D/IntentHandler: got ranging data
2019-04-20 12:15:19.440 11452-11452 D/Collection:: size = 0
2019-04-20 12:15:19.440 11452-11452 D/GetRegion:: 1495b423-7d70-4d98-9885-51ed275b8378
2019-04-20 12:15:19.443 11452-12036 D/BluetoothAdapter: STATE_ON
2019-04-20 12:15:19.443 11452-12036 D/BluetoothLeScanner: could not find callback wrapper
2019-04-20 12:15:20.429 11452-11452 D/CycledLeScanner: starting a new scan cycle
2019-04-20 12:15:20.433 11452-11452 D/CycledLeScanner: starting a new bluetooth le scan
2019-04-20 12:15:20.438 11452-11452 D/CycledLeScannerForLollipop: starting a scan in SCAN_MODE_LOW_LATENCY
2019-04-20 12:15:20.438 11452-11452 D/CycledLeScannerForLollipop: Using a non-empty scan filter since this is Samsung 8.1+
2019-04-20 12:15:20.439 11452-11452 D/ScanFilterUtils: Set up a scan filter: BluetoothLeScanFilter [mDeviceName=null, mDeviceAddress=null, mUuid=null, mUuidMask=null, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=4c, mManufacturerData=02 15, mManufacturerDataMask=FF FF]
2019-04-20 12:15:20.440 11452-11452 D/CycledLeScanner: Waiting to stop scan cycle for another 1100 milliseconds
2019-04-20 12:15:20.440 11452-11452 D/CycledLeScanner: Scan started
2019-04-20 12:15:20.442 11452-12036 D/BluetoothAdapter: STATE_ON
2019-04-20 12:15:20.447 11452-12036 D/BluetoothAdapter: STATE_ON
2019-04-20 12:15:20.447 11452-12036 D/BluetoothLeScanner: Start Scan with callback
2019-04-20 12:15:20.456 11452-11662 D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=31 mScannerId=0
2019-04-20 12:15:20.558 11452-11452 D/CycledLeScannerForLollipop: got record
2019-04-20 12:15:20.562 11452-12039 D/BeaconParser: Ignoring pdu type 01
2019-04-20 12:15:20.563 11452-12039 D/BeaconParser: Processing pdu type FF: 0201061aff4c000215e1f54e021e2344e09c3d512eb56adec900640064b90000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29
2019-04-20 12:15:20.563 11452-12039 D/BeaconParser: This is a recognized beacon advertisement -- 02 15 seen
2019-04-20 12:15:20.564 11452-12039 D/BeaconParser: Bytes are: 0201061aff4c000215e1f54e021e2344e09c3d512eb56adec900640064b90000000000000000000000000000000000000000000000000000000000000000
2019-04-20 12:15:20.569 11452-12039 D/ScanHelper: Beacon packet detected for: id1: e1f54e02-1e23-44e0-9c3d-512eb56adec9 id2: 100 id3: 100 with rssi -73
2019-04-20 12:15:20.570 11452-12039 D/ScanHelper: beacon detected : id1: e1f54e02-1e23-44e0-9c3d-512eb56adec9 id2: 100 id3: 100
2019-04-20 12:15:20.571 11452-12039 D/ScanHelper: looking for ranging region matches for this beacon
2019-04-20 12:15:20.571 11452-12039 D/ScanHelper: This region (id1: 1495b423-7d70-4d98-9885-51ed275b8378 id2: 14650 id3: 4477) does not match beacon: id1: e1f54e02-1e23-44e0-9c3d-512eb56adec9 id2: 100 id3: 100
2019-04-20 12:15:20.579 11452-11452 D/CycledLeScannerForLollipop: got record
2019-04-20 12:15:20.584 11452-12040 D/BeaconParser: Ignoring pdu type 01
2019-04-20 12:15:20.585 11452-12040 D/BeaconParser: Processing pdu type FF: 0201061aff4c0002155d060e0d8b1643eb83e768d40cc36e99c3d18f2bc20000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29
2019-04-20 12:15:20.585 11452-12040 D/BeaconParser: This is a recognized beacon advertisement -- 02 15 seen
2019-04-20 12:15:20.586 11452-12040 D/BeaconParser: Bytes are: 0201061aff4c0002155d060e0d8b1643eb83e768d40cc36e99c3d18f2bc20000000000000000000000000000000000000000000000000000000000000000
2019-04-20 12:15:20.591 11452-12040 D/ScanHelper: Beacon packet detected for: id1: 5d060e0d-8b16-43eb-83e7-68d40cc36e99 id2: 50129 id3: 36651 with rssi -86
2019-04-20 12:15:20.592 11452-12040 D/ScanHelper: beacon detected : id1: 5d060e0d-8b16-43eb-83e7-68d40cc36e99 id2: 50129 id3: 36651
2019-04-20 12:15:20.594 11452-12040 D/ScanHelper: looking for ranging region matches for this beacon
2019-04-20 12:15:20.595 11452-12040 D/ScanHelper: This region (id1: 1495b423-7d70-4d98-9885-51ed275b8378 id2: 14650 id3: 4477) does not match beacon: id1: 5d060e0d-8b16-43eb-83e7-68d40cc36e99 id2: 50129 id3: 36651
2019-04-20 12:15:20.610 11452-11452 D/CycledLeScannerForLollipop: got record
2019-04-20 12:15:20.614 11452-12041 D/BeaconParser: Ignoring pdu type 01
2019-04-20 12:15:20.614 11452-12041 D/BeaconParser: Processing pdu type FF: 0201061aff4c0002156a032029db6525b912fad57af1ea8150e01758c0af0000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29
2019-04-20 12:15:20.616 11452-12041 D/BeaconParser: This is a recognized beacon advertisement -- 02 15 seen
2019-04-20 12:15:20.616 11452-12041 D/BeaconParser: Bytes are: 0201061aff4c0002156a032029db6525b912fad57af1ea8150e01758c0af0000000000000000000000000000000000000000000000000000000000000000
2019-04-20 12:15:20.620 11452-12041 D/ScanHelper: Beacon packet detected for: id1: 6a032029-db65-25b9-12fa-d57af1ea8150 id2: 57367 id3: 22720 with rssi -95
2019-04-20 12:15:20.621 11452-12041 D/ScanHelper: beacon detected : id1: 6a032029-db65-25b9-12fa-d57af1ea8150 id2: 57367 id3: 22720
2019-04-20 12:15:20.621 11452-12041 D/ScanHelper: looking for ranging region matches for this beacon
2019-04-20 12:15:20.622 11452-12041 D/ScanHelper: This region (id1: 1495b423-7d70-4d98-9885-51ed275b8378 id2: 14650 id3: 4477) does not match beacon: id1: 6a032029-db65-25b9-12fa-d57af1ea8150 id2: 57367 id3: 22720
2019-04-20 12:15:20.627 11452-11452 D/CycledLeScannerForLollipop: got record
2019-04-20 12:15:20.629 11452-12042 D/BeaconParser: Ignoring pdu type 01
2019-04-20 12:15:20.632 11452-12042 D/BeaconParser: Processing pdu type FF: 0201061aff4c0002156a032029db6525b912fad57af1ea81503e6184bdaf0000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29
2019-04-20 12:15:20.632 11452-12042 D/BeaconParser: This is a recognized beacon advertisement -- 02 15 seen
2019-04-20 12:15:20.633 11452-12042 D/BeaconParser: Bytes are: 0201061aff4c0002156a032029db6525b912fad57af1ea81503e6184bdaf0000000000000000000000000000000000000000000000000000000000000000
2019-04-20 12:15:20.641 11452-12042 D/ScanHelper: Beacon packet detected for: id1: 6a032029-db65-25b9-12fa-d57af1ea8150 id2: 15969 id3: 33981 with rssi -98
2019-04-20 12:15:20.642 11452-12042 D/ScanHelper: beacon detected : id1: 6a032029-db65-25b9-12fa-d57af1ea8150 id2: 15969 id3: 33981
2019-04-20 12:15:20.643 11452-12042 D/ScanHelper: looking for ranging region matches for this beacon
2019-04-20 12:15:20.643 11452-12042 D/ScanHelper: This region (id1: 1495b423-7d70-4d98-9885-51ed275b8378 id2: 14650 id3: 4477) does not match beacon: id1: 6a032029-db65-25b9-12fa-d57af1ea8150 id2: 15969 id3: 33981
2019-04-20 12:15:20.644 11452-11452 D/CycledLeScannerForLollipop: got record
2019-04-20 12:15:20.647 11452-12043 D/BeaconParser: Ignoring pdu type 01
2019-04-20 12:15:20.647 11452-12043 D/BeaconParser: Processing pdu type FF: 0201061aff4c00021591d7e4463ac0198f35194d7a7ac4c9a771f81c49c50000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29
2019-04-20 12:15:20.648 11452-12043 D/BeaconParser: This is a recognized beacon advertisement -- 02 15 seen
2019-04-20 12:15:20.648 11452-12043 D/BeaconParser: Bytes are: 0201061aff4c00021591d7e4463ac0198f35194d7a7ac4c9a771f81c49c50000000000000000000000000000000000000000000000000000000000000000
2019-04-20 12:15:20.652 11452-12043 D/ScanHelper: Beacon packet detected for: id1: 91d7e446-3ac0-198f-3519-4d7a7ac4c9a7 id2: 29176 id3: 7241 with rssi -76
2019-04-20 12:15:20.653 11452-12043 D/ScanHelper: beacon detected : id1: 91d7e446-3ac0-198f-3519-4d7a7ac4c9a7 id2: 29176 id3: 7241
2019-04-20 12:15:20.653 11452-12043 D/ScanHelper: looking for ranging region matches for this beacon
2019-04-20 12:15:20.654 11452-12043 D/ScanHelper: This region (id1: 1495b423-7d70-4d98-9885-51ed275b8378 id2: 14650 id3: 4477) does not match beacon: id1: 91d7e446-3ac0-198f-3519-4d7a7ac4c9a7 id2: 29176 id3: 7241
2019-04-20 12:15:20.670 11452-11452 D/CycledLeScannerForLollipop: got record
2019-04-20 12:15:20.673 11452-12044 D/BeaconParser: Ignoring pdu type 01
2019-04-20 12:15:20.674 11452-12044 D/BeaconParser: Processing pdu type FF: 0201061aff4c0002155d060e0d8b1643eb83e768d40cc36e995092e201c20000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29
2019-04-20 12:15:20.679 11452-12044 D/BeaconParser: This is a recognized beacon advertisement -- 02 15 seen
2019-04-20 12:15:20.679 11452-12044 D/BeaconParser: Bytes are: 0201061aff4c0002155d060e0d8b1643eb83e768d40cc36e995092e201c20000000000000000000000000000000000000000000000000000000000000000
2019-04-20 12:15:20.684 11452-12044 D/ScanHelper: Beacon packet detected for: id1: 5d060e0d-8b16-43eb-83e7-68d40cc36e99 id2: 20626 id3: 57857 with rssi -73
2019-04-20 12:15:20.685 11452-12044 D/ScanHelper: beacon detected : id1: 5d060e0d-8b16-43eb-83e7-68d40cc36e99 id2: 20626 id3: 57857
2019-04-20 12:15:20.685 11452-12044 D/ScanHelper: looking for ranging region matches for this beacon
2019-04-20 12:15:20.686 11452-12044 D/ScanHelper: This region (id1: 1495b423-7d70-4d98-9885-51ed275b8378 id2: 14650 id3: 4477) does not match beacon: id1: 5d060e0d-8b16-43eb-83e7-68d40cc36e99 id2: 20626 id3: 57857
2019-04-20 12:15:20.725 11452-11452 D/CycledLeScannerForLollipop: got record
2019-04-20 12:15:20.734 11452-11463 I/c.gutech.hscap: Background concurrent copying GC freed 130403(5MB) AllocSpace objects, 4(80KB) LOS objects, 70% free, 2MB/8MB, paused 341us total 105.955ms
2019-04-20 12:15:20.736 11452-11452 D/CycledLeScannerForLollipop: got record

1 Ответ

1 голос
/ 19 апреля 2019

В Android 8+ библиотека использует JobScheduler для планирования сканирования маяков.Если вы связываетесь с BeaconManager, когда приложение находится на переднем плане, оно планирует немедленный ScanJob.Если вы отмените привязку, это отменит это задание немедленного сканирования.В следующий раз, когда вы свяжете его, запланировано еще одно немедленное ScanJob.

Это дорогостоящий процесс, использующий большое количество телефонных ресурсов.По этой причине библиотека предназначена для подавления последующих попыток перезапустить ScanJob в течение 10 секунд.Если вы попытаетесь запустить ScanJob дважды за те же 10 секунд, следующий запуск будет отложен, что может привести к появлению симптомов, которые вы видите.

Если вы хотите разработать и приложение, которое быстро начинает сканирование при быстром перемещении между фрагментами, вы столкнетесь с этой проблемой.

Если вы не можете жить с задержкой, то самый простойРешение состоит в том, чтобы переместить начало / остановку сканирования на более высокий уровень вашего кода, чтобы он уже запускался при появлении фрагмента.Обычно это делается в пользовательском классе Application или в POJO, который реализует BeaconConsumer.Если вы выбираете маршрут POJO, не забудьте связать все методы BeaconConsumer с эквивалентными методами объекта контекста Android.

...