package com.dss.ups.sp51a.ble.manager;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.util.Log;
import g.a.a.a.a;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import kotlin.Metadata;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes.dex */
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0005\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\f\u0010\rJ\r\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0003\u0010\u0004J\u0013\u0010\u0007\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005¢\u0006\u0004\b\u0007\u0010\bR\u0016\u0010\n\u001a\u00020\t8\u0002@\u0002X\u0082T¢\u0006\u0006\n\u0004\b\n\u0010\u000b¨\u0006\u000e"}, d2 = {"Lcom/dss/ups/sp51a/ble/manager/BleUtils;", "", "", "getBluetoothState", "()Z", "", "Landroid/bluetooth/BluetoothDevice;", "getPairAndConnectDevice", "()Ljava/util/List;", "", "TAG", "Ljava/lang/String;", "<init>", "()V", "lib_release"}, k = 1, mv = {1, 5, 1})
public final class BleUtils {
    public static final BleUtils INSTANCE = new BleUtils();
    private static final String TAG = "BleUtils";

    private BleUtils() {
    }

    public final boolean getBluetoothState() {
        return BluetoothAdapter.getDefaultAdapter().isEnabled();
    }

    public final List<BluetoothDevice> getPairAndConnectDevice() {
        ArrayList arrayList = new ArrayList();
        Set<BluetoothDevice> bondedDevices = BluetoothAdapter.getDefaultAdapter().getBondedDevices();
        o.e(bondedDevices, "myPairedDevices");
        if (!bondedDevices.isEmpty()) {
            for (BluetoothDevice bluetoothDevice : bondedDevices) {
                o.e(bluetoothDevice, "myPairedDevices");
                BluetoothDevice bluetoothDevice2 = bluetoothDevice;
                StringBuilder sbF = a.F("address:");
                sbF.append((Object) bluetoothDevice2.getAddress());
                sbF.append(", name:");
                sbF.append((Object) bluetoothDevice2.getName());
                sbF.append(", type:");
                sbF.append(bluetoothDevice2.getType());
                Log.d("BleUtils", sbF.toString());
                boolean zBooleanValue = false;
                try {
                    Method method = BluetoothDevice.class.getMethod("isConnected", new Class[0]);
                    o.e(method, "BluetoothDevice::class.java.getMethod(\"isConnected\")");
                    method.setAccessible(true);
                    Object objInvoke = method.invoke(bluetoothDevice2, new Object[0]);
                    if (objInvoke == null) {
                        throw new NullPointerException("null cannot be cast to non-null type kotlin.Boolean");
                    }
                    zBooleanValue = ((Boolean) objInvoke).booleanValue();
                } catch (Exception e2) {
                    Log.e("BleUtils", "Get Pair And Connect Device failed", e2);
                }
                if (zBooleanValue) {
                    arrayList.add(bluetoothDevice2);
                }
                Log.d("BleUtils", o.l("isConnect: ", Boolean.valueOf(zBooleanValue)));
            }
        } else {
            Log.e("BleUtils", "没有找到蓝牙设备");
        }
        return arrayList;
    }
}
