package ai.advance.core;

import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Build;
import com.facebook.login.LoginStatusClient;
import com.facebook.places.PlaceManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import K.K.ʬ.C2358;
import K.K.ῲ.C2363;
import K.K.K.ʬ.C2369;

public abstract class WifiAndBLEScanService extends LServiceParent {

    /* renamed from: ᕣ  reason: contains not printable characters */
    public List<ScanResult> f38;

    /* renamed from: 㑃  reason: contains not printable characters */
    public List<BluetoothDevice> f39;

    /* renamed from: 䁗  reason: contains not printable characters */
    public BroadcastReceiver f40 = new C0011();

    /* renamed from: ai.advance.core.WifiAndBLEScanService$K  reason: contains not printable characters */
    public class C0011 extends BroadcastReceiver {
        public C0011() {
        }

        @SuppressLint({"MissingPermission"})
        public void onReceive(Context context, Intent intent) {
            try {
                WifiAndBLEScanService.this.f38 = WifiAndBLEScanService.m46(WifiAndBLEScanService.this).getScanResults();
            } catch (Exception unused) {
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static /* synthetic */ WifiManager m46(WifiAndBLEScanService wifiAndBLEScanService) {
        return (WifiManager) wifiAndBLEScanService.getApplicationContext().getSystemService(PlaceManager.PARAM_WIFI);
    }

    @Override // androidx.core.app.JobIntentService, ai.advance.core.LServiceParent
    public void onDestroy() {
        try {
            unregisterReceiver(this.f40);
        } catch (Exception unused) {
        }
        super.onDestroy();
    }

    /* renamed from: Ԕ  reason: contains not printable characters */
    public abstract String m47();

    @Override // ai.advance.core.LServiceParent
    /* renamed from: ඓ  reason: contains not printable characters */
    public void m48() {
    }

    /* renamed from: ᕣ  reason: contains not printable characters */
    public abstract String m49();

    @Override // ai.advance.core.LServiceParent
    /* renamed from: K  reason: contains not printable characters */
    public String m50(String str, String str2) {
        return null;
    }

    /* renamed from: 㑃  reason: contains not printable characters */
    public Map<String, Object> m52() {
        return null;
    }

    /* renamed from: 㳳  reason: contains not printable characters */
    public final WifiManager m53() {
        return (WifiManager) getApplicationContext().getSystemService(PlaceManager.PARAM_WIFI);
    }

    @Override // ai.advance.core.LServiceParent
    /* renamed from: 㴹  reason: contains not printable characters */
    public JSONArray m54() {
        return null;
    }

    /* renamed from: 䁗  reason: contains not printable characters */
    public long m55() {
        return LoginStatusClient.DEFAULT_TOAST_DURATION_MS;
    }

    @Override // androidx.core.app.JobIntentService, ai.advance.core.LServiceParent
    /* renamed from: K  reason: contains not printable characters */
    public void m51(Intent intent) {
        boolean z = false;
        try {
            registerReceiver(this.f40, new IntentFilter("android.net.wifi.SCAN_RESULTS"));
            WifiManager r1 = m53();
            if (C2369.m6286(getApplicationContext(), "android.permission.CHANGE_WIFI_STATE")) {
                z = r1.startScan();
            }
        } catch (Exception unused) {
        }
        this.f39 = new ArrayList();
        if (C2369.m6286(getApplicationContext(), "android.permission.BLUETOOTH")) {
            try {
                int i = Build.VERSION.SDK_INT;
                BluetoothAdapter adapter = ((BluetoothManager) getSystemService(PlaceManager.PARAM_BLUETOOTH)).getAdapter();
                if (adapter.isEnabled()) {
                    int i2 = Build.VERSION.SDK_INT;
                    adapter.getBluetoothLeScanner().startScan(new C2363(this));
                }
            } catch (Exception unused2) {
            }
        }
        if (z) {
            try {
                Thread.sleep(m55());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        C2358 r0 = new C2358(getApplicationContext(), m49(), m47());
        Map<String, Object> r12 = m52();
        if (r12 != null) {
            for (String str : r12.keySet()) {
                r0.m6188(str, r12.get(str));
            }
        }
        r0.m6189(this.f39);
        r0.m6187(this.f38);
        intent.putExtra("eventInfo", r0.m6190().toString());
        super.m37(intent);
    }
}
