// Path: android/app/src/main/java/org/mozilla/magnet/permissions/PermissionChecker.java
// public class PermissionChecker implements PermissionCheckListener {
//     private static Map<Integer,PermissionCheck> checksAwaitingResponse = new HashMap<>();
//     private Stack<PermissionCheck> checks = new Stack<>();
//     private PermissionCheckerCallback mCallback;
//     private boolean mChecking = false;
// 
//     public void check(Activity activity, PermissionCheckerCallback callback) {
//         if (mChecking) return;
//         mChecking = true;
//         mCallback = callback;
// 
//         checks.add(new PermissionCheckBluetooth(this, activity));
//         checks.add(new PermissionCheckGooglePlayServices(this, activity));
//         checks.add(new PermissionCheckLocation(this, activity));
// 
//         checkNext();
//     }
// 
//     private void checkNext() {
//         if (checks.size() > 0) {
//             checks.pop().check();
//             return;
//         }
// 
//         mChecking = false;
//         mCallback.onPermissionChecksComplete();
//     }
// 
//     @Override
//     public void onCheckDone(PermissionCheck check) {
//         checkNext();
//     }
// 
//     @Override
//     public void onCheckAwaitingResponse(PermissionCheck check) {
//         checksAwaitingResponse.put(check.getId(), check);
//     }
// 
//     public static void onResponse(int checkId, int response) {
//         PermissionCheck check = checksAwaitingResponse.get(checkId);
//         if (check == null) return;
//         checksAwaitingResponse.remove(checkId);
//         check.onResponse(response);
//     }
// }
// 
// Path: android/app/src/main/java/org/mozilla/magnet/permissions/PermissionCheckerCallback.java
// public interface PermissionCheckerCallback {
//     void onPermissionChecksComplete();
//     void onPermissionChecksError(Error error);
// }


import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import com.facebook.react.bridge.ActivityEventListener;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import org.mozilla.magnet.permissions.PermissionChecker;
import org.mozilla.magnet.permissions.PermissionCheckerCallback;
import org.mozilla.magnet.scanner.MagnetScanner;
import org.mozilla.magnet.scanner.MagnetScannerItem;
import org.mozilla.magnet.scanner.MagnetScannerListener;
import java.util.concurrent.TimeUnit;
package org.mozilla.magnet;





class MagnetScannerReact extends ReactContextBaseJavaModule implements MagnetScannerListener, LifecycleEventListener, ActivityEventListener {
    private final static String TAG = "MagnetScannerReact";
    private static final long MIN_TIME_BETWEEN_CHECKS = TimeUnit.SECONDS.toMillis(10);
    private ReactApplicationContext mContext;
    private MagnetScanner mMagnetScanner;
    private boolean mStarted = false;
    private boolean mStarting = false;
    private PermissionChecker mPermissionChecker;
    private long mLastPermissionsCheck = 0;

    MagnetScannerReact(ReactApplicationContext context) {
        super(context);
        mContext = context;

        context.addLifecycleEventListener(this);
        context.addActivityEventListener(this);

// Path: android/app/src/main/java/org/mozilla/magnet/permissions/PermissionChecker.java
// public class PermissionChecker implements PermissionCheckListener {
//     private static Map<Integer,PermissionCheck> checksAwaitingResponse = new HashMap<>();
//     private Stack<PermissionCheck> checks = new Stack<>();
//     private PermissionCheckerCallback mCallback;
//     private boolean mChecking = false;
// 
//     public void check(Activity activity, PermissionCheckerCallback callback) {
//         if (mChecking) return;
//         mChecking = true;
//         mCallback = callback;
// 
//         checks.add(new PermissionCheckBluetooth(this, activity));
//         checks.add(new PermissionCheckGooglePlayServices(this, activity));
//         checks.add(new PermissionCheckLocation(this, activity));
// 
//         checkNext();
//     }
// 
//     private void checkNext() {
//         if (checks.size() > 0) {
//             checks.pop().check();
//             return;
//         }
// 
//         mChecking = false;
//         mCallback.onPermissionChecksComplete();
//     }
// 
//     @Override
//     public void onCheckDone(PermissionCheck check) {
//         checkNext();
//     }
// 
//     @Override
//     public void onCheckAwaitingResponse(PermissionCheck check) {
//         checksAwaitingResponse.put(check.getId(), check);
//     }
// 
//     public static void onResponse(int checkId, int response) {
//         PermissionCheck check = checksAwaitingResponse.get(checkId);
//         if (check == null) return;
//         checksAwaitingResponse.remove(checkId);
//         check.onResponse(response);
//     }
// }
// 
// Path: android/app/src/main/java/org/mozilla/magnet/permissions/PermissionCheckerCallback.java
// public interface PermissionCheckerCallback {
//     void onPermissionChecksComplete();
//     void onPermissionChecksError(Error error);
// }


// Path: android/app/src/main/java/org/mozilla/magnet/MagnetScannerReact.java
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import com.facebook.react.bridge.ActivityEventListener;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import org.mozilla.magnet.permissions.PermissionChecker;
import org.mozilla.magnet.permissions.PermissionCheckerCallback;
import org.mozilla.magnet.scanner.MagnetScanner;
import org.mozilla.magnet.scanner.MagnetScannerItem;
import org.mozilla.magnet.scanner.MagnetScannerListener;
import java.util.concurrent.TimeUnit;

package org.mozilla.magnet;





class MagnetScannerReact extends ReactContextBaseJavaModule implements MagnetScannerListener, LifecycleEventListener, ActivityEventListener {
    private final static String TAG = "MagnetScannerReact";
    private static final long MIN_TIME_BETWEEN_CHECKS = TimeUnit.SECONDS.toMillis(10);
    private ReactApplicationContext mContext;
    private MagnetScanner mMagnetScanner;
    private boolean mStarted = false;
    private boolean mStarting = false;
    private PermissionChecker mPermissionChecker;
    private long mLastPermissionsCheck = 0;

    MagnetScannerReact(ReactApplicationContext context) {
        super(context);
        mContext = context;

        context.addLifecycleEventListener(this);
        context.addActivityEventListener(this);

        mPermissionChecker = new PermissionChecker();