package com.epson.mobilephone.common.wifidirect;

import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Handler;
import java.lang.ref.WeakReference;

public class WiFiScanner {
    private static final int INTERVAL_SCAN = 30;
    private static Handler wifiScannerHandler;
    private static Object wifiScannerToken;
    /* access modifiers changed from: private */
    public String TAG = "WiFiScanner";
    /* access modifiers changed from: private */
    public WeakReference<WifiManager> refWiFiManager = null;

    private boolean startScan(WifiManager wifiManager) {
        if (Build.VERSION.SDK_INT >= 28) {
            if (wifiScannerHandler == null) {
                wifiScannerHandler = new Handler();
                wifiScannerToken = new Object();
            }
            wifiScannerHandler.removeCallbacksAndMessages(wifiScannerToken);
            this.refWiFiManager = new WeakReference<>(wifiManager);
            wifiScannerHandler.postDelayed(new Runnable() {
                public void run() {
                    WifiManager wifiManager = (WifiManager) WiFiScanner.this.refWiFiManager.get();
                    if (WiFiScanner.this.refWiFiManager != null) {
                        EPLog.m86d(WiFiScanner.this.TAG, "Started Delayed startScan()");
                        if (!wifiManager.startScan()) {
                            EPLog.m87e(WiFiScanner.this.TAG, "Failed Delayed startScan()");
                        }
                    }
                }
            }, wifiScannerToken, 30000);
            return true;
        } else if (wifiManager.startScan()) {
            return true;
        } else {
            EPLog.m87e(this.TAG, "Failed startScan()");
            return false;
        }
    }
}
