package g.f.c.b.tea;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.usb.UsbDevice;
import android.util.Log;
import com.cvte.va.sdk.mica.api.VolumeManager;
import com.cvte.va.sdk.mica.receiver.UsbChangeReceiver;
import com.ifpdos.udi.service.tea.AccessTypeEnum;
import com.ifpdos.udi.service.tea.DeviceTypeEnum;
import com.ifpdos.udi.service.tea.PlugNotify;
import com.ifpdos.udi.service.tea.UsbDeviceTypeEnum;
import g.f.c.b.tea.BM50Dongle;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import kotlin.Metadata;
import kotlin.jvm.internal.o;

/* JADX INFO: renamed from: g.f.c.b.i.b0, reason: from Kotlin metadata */
/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0002\u0018\u0000 \u00182\u00020\u0001:\u0001\u0018B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u0016\u001a\u00020\u0017H\u0002R\u0014\u0010\u0005\u001a\u00020\u0006X\u0094\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\t\u001a\u00020\nX\u0094\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR\u0016\u0010\r\u001a\n \u000f*\u0004\u0018\u00010\u000e0\u000eX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0011X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0012\u001a\u00020\u0013X\u0094\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0014\u0010\u0015¨\u0006\u0019"}, d2 = {"Lcom/ifpdos/udi/service/tea/BM50Dongle;", "Lcom/ifpdos/udi/service/tea/BaseDevice;", "context", "Landroid/content/Context;", "(Landroid/content/Context;)V", "accessType", "Lcom/ifpdos/udi/service/tea/AccessTypeEnum;", "getAccessType", "()Lcom/ifpdos/udi/service/tea/AccessTypeEnum;", "deviceType", "Lcom/ifpdos/udi/service/tea/DeviceTypeEnum;", "getDeviceType", "()Lcom/ifpdos/udi/service/tea/DeviceTypeEnum;", "executor", "Ljava/util/concurrent/ScheduledExecutorService;", "kotlin.jvm.PlatformType", "usbBroadcastReceiver", "Landroid/content/BroadcastReceiver;", "usbDeviceType", "Lcom/ifpdos/udi/service/tea/UsbDeviceTypeEnum;", "getUsbDeviceType", "()Lcom/ifpdos/udi/service/tea/UsbDeviceTypeEnum;", "registerBroadcastReceiver", "", "Companion", "tea_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class BM50Dongle extends BaseDevice {
    public final Context a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final DeviceTypeEnum f4650b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final UsbDeviceTypeEnum f4651c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final AccessTypeEnum f4652d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final ScheduledExecutorService f4653e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final BroadcastReceiver f4654f;

    /* JADX INFO: renamed from: g.f.c.b.i.b0$a */
    @Metadata(d1 = {"\u0000#\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u0018\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tH\u0016R\u0014\u0010\u0002\u001a\b\u0012\u0002\b\u0003\u0018\u00010\u0003X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\n"}, d2 = {"com/ifpdos/udi/service/tea/BM50Dongle$usbBroadcastReceiver$1", "Landroid/content/BroadcastReceiver;", "notifyPlugOutLater", "Ljava/util/concurrent/ScheduledFuture;", "onReceive", "", "context", "Landroid/content/Context;", "intent", "Landroid/content/Intent;", "tea_release"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class a extends BroadcastReceiver {
        public ScheduledFuture<?> a;

        public a() {
        }

        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            String action;
            o.f(context, "context");
            o.f(intent, "intent");
            final UsbDevice usbDevice = (UsbDevice) intent.getParcelableExtra("device");
            if (usbDevice == null || !DeviceHid.a.f(usbDevice) || (action = intent.getAction()) == null) {
                return;
            }
            if (!o.a(action, UsbChangeReceiver.f974b)) {
                if (o.a(action, UsbChangeReceiver.f975c)) {
                    StringBuilder sbF = g.a.a.a.a.F("BM50Dongle detached: (");
                    sbF.append(usbDevice.getProductId());
                    sbF.append(", ");
                    sbF.append(usbDevice.getVendorId());
                    sbF.append(')');
                    Log.d("BM50Dongle", sbF.toString());
                    ScheduledFuture<?> scheduledFuture = this.a;
                    if (scheduledFuture != null) {
                        scheduledFuture.cancel(false);
                    }
                    VolumeManager.getInstance().setEnableMvChangeVol(false);
                    this.a = BM50Dongle.this.f4653e.schedule(new Runnable() { // from class: g.f.c.b.i.a
                        @Override // java.lang.Runnable
                        public final void run() {
                            UsbDevice usbDevice2 = usbDevice;
                            BM50Dongle.a aVar = this;
                            o.f(usbDevice2, "$device");
                            o.f(aVar, "this$0");
                            PeripheralDevicePlugApi peripheralDevicePlugApi = PeripheralDevicePlugApi.a;
                            String deviceName = usbDevice2.getDeviceName();
                            o.e(deviceName, "device.deviceName");
                            PeripheralDevicePlugApi.a(new PlugNotify(deviceName, false, DeviceTypeEnum.BM50, AccessTypeEnum.DONGLE));
                            aVar.a = null;
                        }
                    }, 5L, TimeUnit.SECONDS);
                    return;
                }
                return;
            }
            StringBuilder sbF2 = g.a.a.a.a.F("BM50Dongle attached: (");
            sbF2.append(usbDevice.getProductId());
            sbF2.append(", ");
            sbF2.append(usbDevice.getVendorId());
            sbF2.append(')');
            Log.d("BM50Dongle", sbF2.toString());
            VolumeManager.getInstance().setEnableMvChangeVol(true);
            ScheduledFuture<?> scheduledFuture2 = this.a;
            if (scheduledFuture2 != null) {
                if (scheduledFuture2 != null) {
                    scheduledFuture2.cancel(false);
                }
            } else {
                PeripheralDevicePlugApi peripheralDevicePlugApi = PeripheralDevicePlugApi.a;
                String deviceName = usbDevice.getDeviceName();
                o.e(deviceName, "device.deviceName");
                PeripheralDevicePlugApi.a(new PlugNotify(deviceName, true, DeviceTypeEnum.BM50, AccessTypeEnum.DONGLE));
            }
        }
    }

    public BM50Dongle(Context context) {
        o.f(context, "context");
        this.a = context;
        this.f4650b = DeviceTypeEnum.BM50;
        this.f4651c = UsbDeviceTypeEnum.BM50_DONGLE;
        this.f4652d = AccessTypeEnum.DONGLE;
        this.f4653e = Executors.newSingleThreadScheduledExecutor();
        a aVar = new a();
        this.f4654f = aVar;
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(UsbChangeReceiver.f974b);
        intentFilter.addAction(UsbChangeReceiver.f975c);
        context.registerReceiver(aVar, intentFilter);
    }

    @Override // g.f.c.b.tea.BaseDevice
    /* JADX INFO: renamed from: a, reason: from getter */
    public AccessTypeEnum getF4652d() {
        return this.f4652d;
    }

    @Override // g.f.c.b.tea.BaseDevice
    /* JADX INFO: renamed from: c, reason: from getter */
    public DeviceTypeEnum getF4650b() {
        return this.f4650b;
    }

    @Override // g.f.c.b.tea.BaseDevice
    /* JADX INFO: renamed from: e, reason: from getter */
    public UsbDeviceTypeEnum getF4651c() {
        return this.f4651c;
    }
}
