本文整理汇总了Java中org.altbeacon.beacon.logging.LogManager类的典型用法代码示例。如果您正苦于以下问题:Java LogManager类的具体用法?Java LogManager怎么用?Java LogManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LogManager类属于org.altbeacon.beacon.logging包,在下文中一共展示了LogManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onServiceConnected
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
public void onServiceConnected(ComponentName className, IBinder service) {
LogManager.d(TAG, "we have a connection to the service now");
if (mScannerInSameProcess == null) {
mScannerInSameProcess = false;
}
serviceMessenger = new Messenger(service);
// This will sync settings to the scanning service if it is in a different process
applySettings();
synchronized(consumers) {
Iterator<Map.Entry<BeaconConsumer, ConsumerInfo>> iter = consumers.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<BeaconConsumer, ConsumerInfo> entry = iter.next();
if (!entry.getValue().isConnected) {
entry.getKey().onBeaconServiceConnect();
entry.getValue().isConnected = true;
}
}
}
}
示例2: crashDetected
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
public void crashDetected() {
if (android.os.Build.VERSION.SDK_INT < 18) {
LogManager.d(TAG, "Ignoring crashes before API 18, because BLE is unsupported.");
return;
}
LogManager.w(TAG, "BluetoothService crash detected");
if (distinctBluetoothAddresses.size() > 0) {
LogManager.d(TAG, "Distinct Bluetooth devices seen at crash: %s",
distinctBluetoothAddresses.size());
}
long nowTimestamp = SystemClock.elapsedRealtime();
lastBluetoothCrashDetectionTime = nowTimestamp;
detectedCrashCount++;
if (recoveryInProgress) {
LogManager.d(TAG, "Ignoring Bluetooth crash because recovery is already in progress.");
}
else {
startRecovery();
}
processStateChange();
}
示例3: cancelDiscovery
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
private void cancelDiscovery() {
try {
Thread.sleep(TIME_TO_LET_DISCOVERY_RUN_MILLIS);
if (!discoveryStartConfirmed) {
LogManager.w(TAG, "BluetoothAdapter.ACTION_DISCOVERY_STARTED never received. Recovery may fail.");
}
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter.isDiscovering()) {
LogManager.d(TAG, "Cancelling discovery");
adapter.cancelDiscovery();
}
else {
LogManager.d(TAG, "Discovery not running. Won't cancel it");
}
} catch (InterruptedException e) {
LogManager.d(TAG, "DiscoveryCanceller sleep interrupted.");
}
}
示例4: stopAdvertising
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
/**
* Stops this beacon from advertising
*/
public void stopAdvertising() {
if (!mStarted) {
LogManager.d(TAG, "Skipping stop advertising -- not started");
return;
}
LogManager.d(TAG, "Stopping advertising with object %s", mBluetoothLeAdvertiser);
mAdvertisingClientCallback = null;
try {
mBluetoothLeAdvertiser.stopAdvertising(getAdvertiseCallback());
}
catch (IllegalStateException e) {
LogManager.w(TAG, "Bluetooth is turned off. Transmitter stop call failed.");
}
mStarted = false;
}
示例5: onBeaconServiceConnect
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
/**
* Method reserved for system use
*/
@Override
public void onBeaconServiceConnect() {
LogManager.d(TAG, "Activating background region monitoring");
beaconManager.addMonitorNotifier(application);
serviceConnected = true;
try {
for (Region region : regions) {
LogManager.d(TAG, "Background region monitoring activated for region %s", region);
beaconManager.startMonitoringBeaconsInRegion(region);
if (beaconManager.isBackgroundModeUninitialized()) {
beaconManager.setBackgroundMode(true);
}
}
} catch (RemoteException e) {
LogManager.e(e, TAG, "Can't set up bootstrap regions");
}
}
示例6: stopRangingBeaconsInRegion
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
/**
* Tells the <code>BeaconService</code> to stop looking for beacons that match the passed
* <code>Region</code> object and providing mDistance information for them.
*
* @param region
* @see #setMonitorNotifier(MonitorNotifier notifier)
* @see #startMonitoringBeaconsInRegion(Region region)
* @see MonitorNotifier
* @see Region
*/
@TargetApi(18)
public void stopRangingBeaconsInRegion(@NonNull Region region) throws RemoteException {
if (!isBleAvailable()) {
LogManager.w(TAG, "Method invocation will be ignored.");
return;
}
if (determineIfCalledFromSeparateScannerProcess()) {
return;
}
synchronized (rangedRegions) {
Region regionToRemove = null;
for (Region rangedRegion : rangedRegions) {
if (region.getUniqueId().equals(rangedRegion.getUniqueId())) {
regionToRemove = rangedRegion;
}
}
rangedRegions.remove(regionToRemove);
}
applyChangesToServices(BeaconService.MSG_STOP_RANGING, region);
}
示例7: onCycleEnd
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
public void onCycleEnd() {
mMonitoringStatus.updateNewlyOutside();
processRangeData();
if (BeaconManager.getBeaconSimulator() != null) {
// if simulatedScanData is provided, it will be seen every scan cycle. *in addition* to anything actually seen in the air
// it will not be used if we are not in debug mode
if (BeaconManager.getBeaconSimulator().getBeacons() != null) {
if (0 != (mService.getApplicationContext().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
for (Beacon beacon : BeaconManager.getBeaconSimulator().getBeacons()) {
processBeaconFromScan(beacon);
}
} else {
LogManager.w(TAG, "Beacon simulations provided, but ignored because we are not running in debug mode. Please remove beacon simulations for production.");
}
} else {
LogManager.w(TAG, "getBeacons is returning null. No simulated beacons to report.");
}
}
}
示例8: stopAndroidOBackgroundScan
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.O)
void stopAndroidOBackgroundScan() {
try {
final BluetoothManager bluetoothManager =
(BluetoothManager) mContext.getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
if (bluetoothAdapter == null) {
LogManager.w(TAG, "Failed to construct a BluetoothAdapter");
} else if (!bluetoothAdapter.isEnabled()) {
LogManager.w(TAG, "BluetoothAdapter is not enabled");
} else {
BluetoothLeScanner scanner = bluetoothAdapter.getBluetoothLeScanner();
if (scanner != null) {
scanner.stopScan(getScanCallbackIntent());
}
}
} catch (SecurityException e) {
LogManager.e(TAG, "SecurityException stopping Android O background scanner");
}
}
示例9: scheduleAfterBackgroundWakeup
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
public void scheduleAfterBackgroundWakeup(Context context, List<ScanResult> scanResults) {
if (scanResults != null) {
mBackgroundScanResultQueue.addAll(scanResults);
}
synchronized (this) {
// We typically get a bunch of calls in a row here, separated by a few millis. Only do this once.
if (System.currentTimeMillis() - mScanJobScheduleTime > MIN_MILLIS_BETWEEN_SCAN_JOB_SCHEDULING) {
LogManager.d(TAG, "scheduling an immediate scan job because last did "+(System.currentTimeMillis() - mScanJobScheduleTime)+"seconds ago.");
mScanJobScheduleTime = System.currentTimeMillis();
}
else {
LogManager.d(TAG, "Not scheduling an immediate scan job because we just did recently.");
return;
}
}
ScanState scanState = ScanState.restore(context);
schedule(context, scanState, true);
}
示例10: startMonitoringBeaconsInRegion
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
/**
* Tells the <code>BeaconService</code> to start looking for beacons that match the passed
* <code>Region</code> object. Note that the Region's unique identifier must be retained to
* later call the stopMonitoringBeaconsInRegion method.
*
* @param region
* @see BeaconManager#setMonitorNotifier(MonitorNotifier)
* @see BeaconManager#stopMonitoringBeaconsInRegion(Region region)
* @see MonitorNotifier
* @see Region
*/
@TargetApi(18)
public void startMonitoringBeaconsInRegion(@NonNull Region region) throws RemoteException {
if (!isBleAvailable()) {
LogManager.w(TAG, "Method invocation will be ignored.");
return;
}
if (determineIfCalledFromSeparateScannerProcess()) {
return;
}
if (mScheduledScanJobsEnabled) {
MonitoringStatus.getInstanceForApplication(mContext).addRegion(region, new Callback(callbackPackageName()));
}
applyChangesToServices(BeaconService.MSG_START_MONITORING, region);
if (isScannerInDifferentProcess()) {
MonitoringStatus.getInstanceForApplication(mContext).addLocalRegion(region);
}
this.requestStateForRegion(region);
}
示例11: startPassiveScanIfNeeded
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
private void startPassiveScanIfNeeded() {
LogManager.d(TAG, "Checking to see if we need to start a passive scan");
boolean insideAnyRegion = false;
// Clone the collection before iterating to prevent ConcurrentModificationException per #577
List<Region> regions = new ArrayList<>(mScanState.getMonitoringStatus().regions());
for (Region region : regions) {
RegionMonitoringState state = mScanState.getMonitoringStatus().stateOf(region);
if (state != null && state.getInside()) {
insideAnyRegion = true;
}
}
if (insideAnyRegion) {
// TODO: Set up a scan filter for not detecting a beacon pattern
LogManager.i(TAG, "We are inside a beacon region. We will not scan between cycles.");
}
else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mScanHelper.startAndroidOBackgroundScan(mScanState.getBeaconParsers());
}
else {
LogManager.d(TAG, "This is not Android O. No scanning between cycles when using ScanJob");
}
}
}
示例12: restartScanning
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
private boolean restartScanning() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mScanHelper.stopAndroidOBackgroundScan();
}
long scanPeriod = mScanState.getBackgroundMode() ? mScanState.getBackgroundScanPeriod() : mScanState.getForegroundScanPeriod();
long betweenScanPeriod = mScanState.getBackgroundMode() ? mScanState.getBackgroundBetweenScanPeriod() : mScanState.getForegroundBetweenScanPeriod();
mScanHelper.getCycledScanner().setScanPeriods(scanPeriod,
betweenScanPeriod,
mScanState.getBackgroundMode());
mInitialized = true;
if (scanPeriod <= 0) {
LogManager.w(TAG, "Starting scan with scan period of zero. Exiting ScanJob.");
mScanHelper.getCycledScanner().stop();
return false;
}
if (mScanHelper.getRangedRegionState().size() > 0 || mScanHelper.getMonitoringStatus().regions().size() > 0) {
mScanHelper.getCycledScanner().start();
return true;
}
else {
mScanHelper.getCycledScanner().stop();
return false;
}
}
示例13: getScanJobRuntimeMillis
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
public int getScanJobRuntimeMillis() {
long scanPeriodMillis;
LogManager.d(TAG, "ScanState says background mode for ScanJob is "+getBackgroundMode());
if (getBackgroundMode()) {
scanPeriodMillis = getBackgroundScanPeriod();
}
else {
scanPeriodMillis = getForegroundScanPeriod();
}
if (!getBackgroundMode()) {
// if we are in the foreground, we keep the scan job going for the minimum interval
if (scanPeriodMillis < MIN_SCAN_JOB_INTERVAL_MILLIS) {
return MIN_SCAN_JOB_INTERVAL_MILLIS;
}
}
return (int) scanPeriodMillis;
}
示例14: calculateRssi
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
@Override
public double calculateRssi() {
refreshMeasurements();
int size = mMeasurements.size();
int startIndex = 0;
int endIndex = size -1;
if (size > 2) {
startIndex = size/10+1;
endIndex = size-size/10-2;
}
double sum = 0;
for (int i = startIndex; i <= endIndex; i++) {
sum += mMeasurements.get(i).rssi;
}
double runningAverage = sum/(endIndex-startIndex+1);
LogManager.d(TAG, "Running average mRssi based on %s measurements: %s",
size, runningAverage);
return runningAverage;
}
示例15: deferScanIfNeeded
import org.altbeacon.beacon.logging.LogManager; //导入依赖的package包/类
@Override
protected boolean deferScanIfNeeded() {
long millisecondsUntilStart = mNextScanCycleStartTime - SystemClock.elapsedRealtime();
if (millisecondsUntilStart > 0) {
LogManager.d(TAG, "Waiting to start next Bluetooth scan for another %s milliseconds",
millisecondsUntilStart);
// Don't actually wait until the next scan time -- only wait up to 1 second. This
// allows us to start scanning sooner if a consumer enters the foreground and expects
// results more quickly.
if (mBackgroundFlag) {
setWakeUpAlarm();
}
mHandler.postDelayed(new Runnable() {
@MainThread
@Override
public void run() {
scanLeDevice(true);
}
}, millisecondsUntilStart > 1000 ? 1000 : millisecondsUntilStart);
return true;
}
return false;
}