// Path: library/src/main/java/com/reelyactive/blesdk/support/ble/util/Logger.java
// public class Logger {
// 
//   public static final String TAG = "BleScanCompatLib";
// 
//   public static void logVerbose(String message) {
//     if (Log.isLoggable(TAG, Log.VERBOSE)) {
//       Log.v(TAG, message);
//     }
//   }
// 
//   public static void logWarning(String message) {
//     if (Log.isLoggable(TAG, Log.WARN)) {
//       Log.w(TAG, message);
//     }
//   }
// 
//   public static void logDebug(String message) {
//     if (Log.isLoggable(TAG, Log.DEBUG)) {
//       Log.d(TAG, message);
//     }
//   }
// 
//   public static void logInfo(String message) {
//     if (Log.isLoggable(TAG, Log.INFO)) {
//       Log.i(TAG, message);
//     }
//   }
// 
//   public static void logError(String message, Exception... e) {
//     if (Log.isLoggable(TAG, Log.ERROR)) {
//       if (e == null || e.length == 0) {
//         Log.e(TAG, message);
//       } else {
//         Log.e(TAG, message, e[0]);
//       }
//     }
//   }
// }
// 
// Path: library/src/main/java/com/reelyactive/blesdk/support/ble/util/SystemClock.java
// public class SystemClock implements Clock {
// 
//   /**
//    * @return current time in milliseconds
//    */
//   @Override
//   public long currentTimeMillis() {
//     return System.currentTimeMillis();
//   }
// 
//   /**
//    * @return time since the device was booted, in nanoseconds
//    */
//   @Override
//   @TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
//   public long elapsedRealtimeNanos() {
//     return android.os.SystemClock.elapsedRealtimeNanos();
//   }
// }


import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import com.reelyactive.blesdk.support.ble.util.Logger;
import com.reelyactive.blesdk.support.ble.util.SystemClock;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
package com.reelyactive.blesdk.support.ble;




/**
 * Created by saiimons on 16-03-17.
 */
public class NoBluetoothLeScannerCompat extends BluetoothLeScannerCompat {

    private final Map<ScanCallback, ScanSettings> callbacksMap = new ConcurrentHashMap<>();

    public NoBluetoothLeScannerCompat(Context context, AlarmManager alarmManager) {
        super(
                new SystemClock(),
                alarmManager,
                PendingIntent.getBroadcast(
                        context,
                        0,
                        new Intent(context, ScanWakefulBroadcastReceiver.class).putExtra(ScanWakefulService.EXTRA_USE_LOLLIPOP_API, false), 0)
        );
    }

    @Override
    public boolean startScan(List<ScanFilter> filters, ScanSettings settings, ScanCallback callback) {
        if (callback != null) {
            try {
                callbacksMap.put(callback, settings);
                updateRepeatingAlarm();
                return true;
            } catch (Exception e) {
// Path: library/src/main/java/com/reelyactive/blesdk/support/ble/util/Logger.java
// public class Logger {
// 
//   public static final String TAG = "BleScanCompatLib";
// 
//   public static void logVerbose(String message) {
//     if (Log.isLoggable(TAG, Log.VERBOSE)) {
//       Log.v(TAG, message);
//     }
//   }
// 
//   public static void logWarning(String message) {
//     if (Log.isLoggable(TAG, Log.WARN)) {
//       Log.w(TAG, message);
//     }
//   }
// 
//   public static void logDebug(String message) {
//     if (Log.isLoggable(TAG, Log.DEBUG)) {
//       Log.d(TAG, message);
//     }
//   }
// 
//   public static void logInfo(String message) {
//     if (Log.isLoggable(TAG, Log.INFO)) {
//       Log.i(TAG, message);
//     }
//   }
// 
//   public static void logError(String message, Exception... e) {
//     if (Log.isLoggable(TAG, Log.ERROR)) {
//       if (e == null || e.length == 0) {
//         Log.e(TAG, message);
//       } else {
//         Log.e(TAG, message, e[0]);
//       }
//     }
//   }
// }
// 
// Path: library/src/main/java/com/reelyactive/blesdk/support/ble/util/SystemClock.java
// public class SystemClock implements Clock {
// 
//   /**
//    * @return current time in milliseconds
//    */
//   @Override
//   public long currentTimeMillis() {
//     return System.currentTimeMillis();
//   }
// 
//   /**
//    * @return time since the device was booted, in nanoseconds
//    */
//   @Override
//   @TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
//   public long elapsedRealtimeNanos() {
//     return android.os.SystemClock.elapsedRealtimeNanos();
//   }
// }


// Path: library/src/main/java/com/reelyactive/blesdk/support/ble/NoBluetoothLeScannerCompat.java
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import com.reelyactive.blesdk.support.ble.util.Logger;
import com.reelyactive.blesdk.support.ble.util.SystemClock;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

package com.reelyactive.blesdk.support.ble;




/**
 * Created by saiimons on 16-03-17.
 */
public class NoBluetoothLeScannerCompat extends BluetoothLeScannerCompat {

    private final Map<ScanCallback, ScanSettings> callbacksMap = new ConcurrentHashMap<>();

    public NoBluetoothLeScannerCompat(Context context, AlarmManager alarmManager) {
        super(
                new SystemClock(),
                alarmManager,
                PendingIntent.getBroadcast(
                        context,
                        0,
                        new Intent(context, ScanWakefulBroadcastReceiver.class).putExtra(ScanWakefulService.EXTRA_USE_LOLLIPOP_API, false), 0)
        );
    }

    @Override
    public boolean startScan(List<ScanFilter> filters, ScanSettings settings, ScanCallback callback) {
        if (callback != null) {
            try {
                callbacksMap.put(callback, settings);
                updateRepeatingAlarm();
                return true;
            } catch (Exception e) {
                Logger.logError(e.getMessage(), e);