// Path: library/src/main/java/com/reelyactive/blesdk/support/ble/util/Clock.java
// public interface Clock {
// 
//   /**
//    * @return current time in milliseconds
//    */
//   public long currentTimeMillis();
// 
//   /**
//    * @return time since the device was booted, in nanoseconds
//    */
//   public long elapsedRealtimeNanos();
// 
// }
// 
// 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.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.reelyactive.blesdk.support.ble.util.Clock;
import com.reelyactive.blesdk.support.ble.util.Logger;
import com.reelyactive.blesdk.support.ble.util.SystemClock;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
package com.reelyactive.blesdk.support.ble;
/*
 * Copyright 2014 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */




/**
 * Implements Bluetooth LE scan related API on top of {@link android.os.Build.VERSION_CODES#LOLLIPOP}
 * and later.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
class LBluetoothLeScannerCompat extends BluetoothLeScannerCompat {

    private final Map<String, ScanResult> recentScanResults = new ConcurrentHashMap<>();
    private final Map<ScanCallback, ScanClient> callbacksMap = new ConcurrentHashMap<>();
    private final android.bluetooth.le.BluetoothLeScanner osScanner;

    /**
     * Package-protected constructor, used by {@link BluetoothLeScannerCompatProvider}.
     * <p>
     * Cannot be called from emulated devices that don't implement a BluetoothAdapter.
     */
    LBluetoothLeScannerCompat(Context context, BluetoothManager manager, AlarmManager alarmManager) {
        this(
                manager,
                alarmManager,
                new SystemClock(),
                PendingIntent.getBroadcast(
                        context,
                        0 /* requestCode */,
                        new Intent(context, ScanWakefulBroadcastReceiver.class).putExtra(ScanWakefulService.EXTRA_USE_LOLLIPOP_API, true),
                        0 /* flags */
                )
        );
    }

    LBluetoothLeScannerCompat(BluetoothManager manager, AlarmManager alarmManager,
                              Clock clock, PendingIntent alarmIntent) {
        super(clock, alarmManager, alarmIntent);
// Path: library/src/main/java/com/reelyactive/blesdk/support/ble/util/Clock.java
// public interface Clock {
// 
//   /**
//    * @return current time in milliseconds
//    */
//   public long currentTimeMillis();
// 
//   /**
//    * @return time since the device was booted, in nanoseconds
//    */
//   public long elapsedRealtimeNanos();
// 
// }
// 
// 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/LBluetoothLeScannerCompat.java
import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.reelyactive.blesdk.support.ble.util.Clock;
import com.reelyactive.blesdk.support.ble.util.Logger;
import com.reelyactive.blesdk.support.ble.util.SystemClock;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

package com.reelyactive.blesdk.support.ble;
/*
 * Copyright 2014 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */




/**
 * Implements Bluetooth LE scan related API on top of {@link android.os.Build.VERSION_CODES#LOLLIPOP}
 * and later.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
class LBluetoothLeScannerCompat extends BluetoothLeScannerCompat {

    private final Map<String, ScanResult> recentScanResults = new ConcurrentHashMap<>();
    private final Map<ScanCallback, ScanClient> callbacksMap = new ConcurrentHashMap<>();
    private final android.bluetooth.le.BluetoothLeScanner osScanner;

    /**
     * Package-protected constructor, used by {@link BluetoothLeScannerCompatProvider}.
     * <p>
     * Cannot be called from emulated devices that don't implement a BluetoothAdapter.
     */
    LBluetoothLeScannerCompat(Context context, BluetoothManager manager, AlarmManager alarmManager) {
        this(
                manager,
                alarmManager,
                new SystemClock(),
                PendingIntent.getBroadcast(
                        context,
                        0 /* requestCode */,
                        new Intent(context, ScanWakefulBroadcastReceiver.class).putExtra(ScanWakefulService.EXTRA_USE_LOLLIPOP_API, true),
                        0 /* flags */
                )
        );
    }

    LBluetoothLeScannerCompat(BluetoothManager manager, AlarmManager alarmManager,
                              Clock clock, PendingIntent alarmIntent) {
        super(clock, alarmManager, alarmIntent);
        Logger.logDebug("BLE 'L' hardware access layer activated");