package com.tencent.api;

import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import com.tencent.common.ITEAInsideDeviceConnectStateUpdateCbDelegate;
import com.tencent.common.ITEAInsideDevicePortAttachStateUpdateCbDelegate;
import com.tencent.common.ITEAMediaFrameUploadCb;
import com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb;
import com.tencent.common.ITEATeaDevEventMsgCb;
import com.tencent.common.ITEAThirdPartyDevEventMsgCb;
import com.tencent.common.TEAMediaFrame;
import com.tencent.usb.UsbHidDevice;
import com.tencent.usb.a;
import com.tencent.usb.b;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/* JADX INFO: loaded from: classes.dex */
public class TEANativeInsideApi {
    public static final int ALL_UPLOAD_AUDIO_CHANNEL_MASK = 4095;
    private static final String API_TAG = "TEA_API";
    public static final int CHECK_VERSION_RETRY_INIT_CNT = 1;
    public static final int DEFAULT_UPLOAD_AUDIO_CHANNEL_MASK = 783;
    private static final int EVENT_MSG_DEVICE_CONNECT_STATE_UPDATE = 402;
    private static final int EVENT_MSG_DEVICE_CONNECT_STATE_UPDATE_END = 500;
    private static final int EVENT_MSG_DEVICE_CONNECT_STATE_UPDATE_START = 401;
    private static final int EVENT_MSG_DEVICE_PORT_ATTACH_STATE_UPDATE = 502;
    private static final int EVENT_MSG_DEVICE_PORT_ATTACH_STATE_UPDATE_END = 600;
    private static final int EVENT_MSG_DEVICE_PORT_ATTACH_STATE_UPDATE_START = 501;
    private static final int EVENT_MSG_TEA_DEVICE_API_END = 100;
    private static final int EVENT_MSG_TEA_DEVICE_API_START = 0;
    private static final int EVENT_MSG_TEA_DEVICE_ATTACH = 103;
    private static final int EVENT_MSG_TEA_DEVICE_AUDIO_DUMP_DONE = 5;
    private static final int EVENT_MSG_TEA_DEVICE_CHECK_VERSION_IF_CB_SUCCESS = 102;
    private static final int EVENT_MSG_TEA_DEVICE_CTRL_CMD_RESULT = 8;
    private static final int EVENT_MSG_TEA_DEVICE_DETACH = 104;
    private static final int EVENT_MSG_TEA_DEVICE_DOA_ANGLE = 3;
    private static final int EVENT_MSG_TEA_DEVICE_DUMP_SYNC_DONE = 13;
    private static final int EVENT_MSG_TEA_DEVICE_LOG_DUMP_DONE = 4;
    private static final int EVENT_MSG_TEA_DEVICE_LOG_SYNC_DONE = 12;
    private static final int EVENT_MSG_TEA_DEVICE_MODE_STATE = 7;
    private static final int EVENT_MSG_TEA_DEVICE_OTA_RESULT = 2;
    private static final int EVENT_MSG_TEA_DEVICE_OTA_STATE = 1;
    private static final int EVENT_MSG_TEA_DEVICE_REBOOT_RESULT = 11;
    private static final int EVENT_MSG_TEA_DEVICE_SELECT = 105;
    private static final int EVENT_MSG_TEA_DEVICE_STREAM_MUTE_STATE = 6;
    private static final int EVENT_MSG_TEA_DEVICE_ULTRA_FILE_PUSH_RESULT = 9;
    private static final int EVENT_MSG_TEA_DEVICE_ULTRA_STOP_RESULT = 10;
    private static final int EVENT_MSG_TEA_USB_ACTION_END = 200;
    private static final int EVENT_MSG_TEA_USB_ACTION_START = 101;
    private static final int EVENT_MSG_THIRDPARTY_DEVICE_API_END = 300;
    private static final int EVENT_MSG_THIRDPARTY_DEVICE_API_START = 201;
    private static final int EVENT_MSG_THIRDPARTY_DEVICE_CTRL_CMD_RESULT = 204;
    private static final int EVENT_MSG_THIRDPARTY_DEVICE_UPGRADE_RESULT = 203;
    private static final int EVENT_MSG_THIRDPARTY_DEVICE_UPGRADE_STATE = 202;
    private static final int EVENT_MSG_USER_STATE_MIC_MUTE = 302;
    private static final int EVENT_MSG_USER_STATE_OFF_HOOK = 304;
    private static final int EVENT_MSG_USER_STATE_SPEAKER_VOLUME = 303;
    private static final int EVENT_MSG_USER_STATE_UPDATE_END = 400;
    private static final int EVENT_MSG_USER_STATE_UPDATE_START = 301;
    private static final int EVENT_MSG_USER_STATE_VOLUME_UP = 305;
    private static final byte HID_MUTE_BIT_MASK = 16;
    private static final byte HID_OFFHOOK_BIT_MASK = 1;
    private static final int PLATFORM_ANDROID = 0;
    private ITEAUsbEventCb mConnectCb;
    private Context mContext;
    private EventHandler mEventHandler;
    private long mNativeContext;
    private a mUsbMonitor;
    private UsbHidDevice mUsbDevice = null;
    private boolean mHasInit = false;
    private boolean mStartUploadDevicePcm = false;
    private int mPid = 16388;
    private int mVid = 10071;
    private ITEAAudioUploadCb mAudioUploadCb = null;
    private Lock mAudioUploadCblock = new ReentrantLock();
    private ITEANativeInsideTeaDevEventCb mTeaInsideTeaDevEventCb = null;
    private ITEANativeInsideThirdPartyDevEventCb mTeaInsideThirdPartyDevEventCb = null;
    private ITEANativeInsideTeaUserStateUpdateEventCb mTeaInsideUserStateUpdateCb = null;
    private ITEAInsideDeviceConnectStateUpdateCbDelegate mTeaInsideDeviceConnectStateUpdateCb = null;
    private ITEAInsideDevicePortAttachStateUpdateCbDelegate mTeaInsideDevicePortAttachStateUpdateCb = null;
    private Lock mTeaInsideEventCbLock = new ReentrantLock();
    private int mCheckDeviceVersionRetryInit = 1;
    private Map<String, String> mDeviceList = new HashMap();
    private AtomicBoolean mWaitOtaResultCb = new AtomicBoolean(false);
    private AtomicBoolean mWaitLogDumpResultCb = new AtomicBoolean(false);
    private AtomicBoolean mWaitAudioDumpResultCb = new AtomicBoolean(false);
    private AtomicBoolean mIsSync = new AtomicBoolean(false);
    private a.InterfaceC0014a mUsgStateChangeCb = new a.InterfaceC0014a() { // from class: com.tencent.api.TEANativeInsideApi.1
        @Override // com.tencent.usb.a.InterfaceC0014a
        public void onAttach() {
            Log.i(TEANativeInsideApi.API_TAG, "TeaApi layer detect usb attached");
            UsbHidDevice usbHidDeviceInsertDevice = UsbHidDevice.InsertDevice(TEANativeInsideApi.this.mContext);
            if (usbHidDeviceInsertDevice == null) {
                Log.i(TEANativeInsideApi.API_TAG, "InsertDevice return null");
                return;
            }
            usbHidDeviceInsertDevice.open(TEANativeInsideApi.this.mContext, new b() { // from class: com.tencent.api.TEANativeInsideApi.1.1
                @Override // com.tencent.usb.b
                public void onUsbHidDeviceConnectFailed(UsbHidDevice usbHidDevice) {
                    Log.e(TEANativeInsideApi.API_TAG, "[Open]Open hid device failed");
                }

                @Override // com.tencent.usb.b
                public void onUsbHidDeviceConnected(UsbHidDevice usbHidDevice) {
                    Log.i(TEANativeInsideApi.API_TAG, "[Open]Open java hid device success");
                    if (TEANativeInsideApi.this.insertNativeHidDevice(usbHidDevice) == 0) {
                        Log.i(TEANativeInsideApi.API_TAG, "[Open]Open native hid device success, request permission: Yes, check version");
                        TEANativeInsideApi.this.postCheckDeviceIfCallbackSuccessMsg(true, usbHidDevice);
                        if (TEANativeInsideApi.this.mUsbDevice == null) {
                            UsbHidDevice[] hidDeviceList = UsbHidDevice.getHidDeviceList();
                            TEANativeInsideApi.this.usbDeviceSelect(hidDeviceList[0].getDeviceName());
                            TEANativeInsideApi.this.sendDeviceSelectMsg(hidDeviceList[0].getDeviceName());
                        }
                    }
                }
            });
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = usbHidDeviceInsertDevice.getDeviceVid();
            eventMsgInfo.iVar1 = usbHidDeviceInsertDevice.getDevicePid();
            eventMsgInfo.string0 = usbHidDeviceInsertDevice.getDeviceName();
            TEANativeInsideApi.this.sendMessage(103, eventMsgInfo);
        }

        @Override // com.tencent.usb.a.InterfaceC0014a
        public void onDetach(UsbDevice usbDevice) {
            Log.i(TEANativeInsideApi.API_TAG, "TeaApi layer detect usb detached");
            UsbHidDevice.RemoveDevice(usbDevice.getDeviceName());
            if (TEANativeInsideApi.this.isCurrentDevice(usbDevice)) {
                if (TEANativeInsideApi.this.mWaitOtaResultCb.get()) {
                    Log.i(TEANativeInsideApi.API_TAG, "TeaApi layer check ota result NOT cb, cb ota error");
                    TEANativeInsideApi.this.mWaitOtaResultCb.set(false);
                    EventMsgInfo eventMsgInfo = new EventMsgInfo();
                    eventMsgInfo.iVar0 = -1;
                    TEANativeInsideApi.this.sendMessage(2, eventMsgInfo);
                }
                if (TEANativeInsideApi.this.mWaitLogDumpResultCb.get()) {
                    Log.i(TEANativeInsideApi.API_TAG, "TeaApi layer check log dump result NOT cb, cb log dump error");
                    TEANativeInsideApi.this.mWaitLogDumpResultCb.set(false);
                    EventMsgInfo eventMsgInfo2 = new EventMsgInfo();
                    eventMsgInfo2.iVar0 = -1;
                    TEANativeInsideApi.this.sendMessage(4, eventMsgInfo2);
                }
                if (TEANativeInsideApi.this.mWaitAudioDumpResultCb.get()) {
                    Log.i(TEANativeInsideApi.API_TAG, "TeaApi layer check audio dump result NOT cb, cb audio dump error");
                    TEANativeInsideApi.this.mWaitAudioDumpResultCb.set(false);
                    EventMsgInfo eventMsgInfo3 = new EventMsgInfo();
                    eventMsgInfo3.iVar0 = -1;
                    TEANativeInsideApi.this.sendMessage(5, eventMsgInfo3);
                }
                TEANativeInsideApi.this.mCheckDeviceVersionRetryInit = 1;
                TEANativeInsideApi.this.stopUploadDeviceAudioPcm();
                if (UsbHidDevice.getHidDeviceList().length > 0) {
                    TEANativeInsideApi.this.usbDeviceSelect(UsbHidDevice.getHidDeviceList()[0].getDeviceName());
                    TEANativeInsideApi.this.sendDeviceSelectMsg(UsbHidDevice.getHidDeviceList()[0].getDeviceName());
                }
            }
            EventMsgInfo eventMsgInfo4 = new EventMsgInfo();
            eventMsgInfo4.string0 = usbDevice.getDeviceName();
            eventMsgInfo4.iVar0 = usbDevice.getVendorId();
            eventMsgInfo4.iVar1 = usbDevice.getProductId();
            TEANativeInsideApi.this.sendMessage(104, eventMsgInfo4);
            TEANativeInsideApi.this.removeNativeHidDevice(usbDevice.getDeviceName());
            if (UsbHidDevice.getHidDeviceList().length == 0) {
                TEANativeInsideApi.this.mUsbDevice = null;
            }
        }
    };
    private ITEAMediaFrameUploadCb mMediaFrameUpoadCb = new ITEAMediaFrameUploadCb() { // from class: com.tencent.api.TEANativeInsideApi.2
        @Override // com.tencent.common.ITEAMediaFrameUploadCb
        public void onMediaFrameUpload(TEAMediaFrame tEAMediaFrame) {
            TEANativeInsideApi.this.mAudioUploadCblock.lock();
            if (TEANativeInsideApi.this.mAudioUploadCb != null) {
                TEANativeInsideApi.this.mAudioUploadCb.onAudioUploadData(new TEAAudioFrame(tEAMediaFrame));
            }
            TEANativeInsideApi.this.mAudioUploadCblock.unlock();
        }
    };
    private ITEAThirdPartyDevEventMsgCb mThirdPartyDevEventMsgCb = new ITEAThirdPartyDevEventMsgCb() { // from class: com.tencent.api.TEANativeInsideApi.4
        @Override // com.tencent.common.ITEAThirdPartyDevEventMsgCb
        public void onThirdPartyDeviceControlCommandResult(String str, String str2, int i2, int i3, String str3) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str2;
            eventMsgInfo.iVar0 = i2;
            eventMsgInfo.iVar1 = i3;
            eventMsgInfo.objVar0 = str3;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_THIRDPARTY_DEVICE_CTRL_CMD_RESULT, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEAThirdPartyDevEventMsgCb
        public void onThirdPartyDeviceUpgradeResult(String str, String str2, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str2;
            eventMsgInfo.iVar0 = i2;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_THIRDPARTY_DEVICE_UPGRADE_RESULT, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEAThirdPartyDevEventMsgCb
        public void onThirdPartyDeviceUpgradeState(String str, String str2, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str2;
            eventMsgInfo.iVar0 = i2;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_THIRDPARTY_DEVICE_UPGRADE_STATE, eventMsgInfo);
        }
    };
    private ITEANativeInsideTeaUserStateUpdateEventCb mITeaUserStateUpdateCb = new ITEANativeInsideTeaUserStateUpdateEventCb() { // from class: com.tencent.api.TEANativeInsideApi.5
        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceBeamformingStartEndAngleUpdate(String str, short s2, short s3, int i2) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceMicrophoneOverallMuteStateUpdate(String str, boolean z2, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str;
            eventMsgInfo.bVar0 = z2;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_USER_STATE_MIC_MUTE, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceMicrophoneSelectedStateUpdate(String str, String str2, boolean z2, int i2) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceOffHookStateUpdate(String str, boolean z2, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str;
            eventMsgInfo.bVar0 = z2;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_USER_STATE_OFF_HOOK, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceOrientationModeStateUpdate(String str, String str2, int i2, int i3) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceOverallWorkingModeStateUpdate(String str, int i2, int i3) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDevicePreprocessAiNsAggressivenessUpdate(String str, float f2, int i2) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDevicePreprocessOverallModeStateUpdate(String str, int i2, int i3) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDevicePreprocessRangeModeStateUpdate(String str, String str2, int i2, int i3) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDevicePreprocessTraditionalNsAggressivenessUpdate(String str, float f2, int i2) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDevicePreprocessUserMicrophoneDelayUpdate(String str, String str2, short s2, int i2) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDevicePreprocessZoomingModeStateUpdate(String str, String str2, int i2, int i3) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceSpeakerMaxVolumeStateUpdate(String str, String str2, float f2, int i2) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceSpeakerMuteStateUpdate(String str, String str2, boolean z2, int i2) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceSpeakerOverallEqModeStateUpdate(String str, int i2, int i3) {
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceSpeakerOverallVolumeUpdate(String str, float f2, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str;
            eventMsgInfo.fVar0 = f2;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_USER_STATE_SPEAKER_VOLUME, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEANativeInsideTeaUserStateUpdateEventCb
        public void OnDeviceVolumeUpDownStateUpdate(String str, boolean z2, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str;
            eventMsgInfo.bVar0 = z2;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_USER_STATE_VOLUME_UP, eventMsgInfo);
        }
    };
    private ITEAInsideDeviceConnectStateUpdateCbDelegate mITeaDeviceConnectStateUpdateCb = new ITEAInsideDeviceConnectStateUpdateCbDelegate() { // from class: com.tencent.api.TEANativeInsideApi.6
        @Override // com.tencent.common.ITEAInsideDeviceConnectStateUpdateCbDelegate
        public void OnDeviceConnectStateUpdate(String str, String str2, boolean z2, String str3) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str;
            eventMsgInfo.string1 = str2;
            eventMsgInfo.bVar0 = z2;
            eventMsgInfo.string2 = str3;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_DEVICE_CONNECT_STATE_UPDATE, eventMsgInfo);
        }
    };
    private ITEAInsideDevicePortAttachStateUpdateCbDelegate mITeaInsideDevicePortAttachStateUpdateCb = new ITEAInsideDevicePortAttachStateUpdateCbDelegate() { // from class: com.tencent.api.TEANativeInsideApi.7
        @Override // com.tencent.common.ITEAInsideDevicePortAttachStateUpdateCbDelegate
        public void onDevicePortAttachStateUpdate(String str, int i2, String str2, boolean z2, String str3) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.string0 = str;
            eventMsgInfo.iVar0 = i2;
            eventMsgInfo.string1 = str2;
            eventMsgInfo.bVar0 = z2;
            eventMsgInfo.string2 = str3;
            TEANativeInsideApi.this.sendMessage(TEANativeInsideApi.EVENT_MSG_DEVICE_PORT_ATTACH_STATE_UPDATE, eventMsgInfo);
        }
    };
    private ITEATeaDevEventMsgCb mTeaDevEventMsgCb = new ITEATeaDevEventMsgCb() { // from class: com.tencent.api.TEANativeInsideApi.8
        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceAudioDumpDone(String str, int i2) {
            TEANativeInsideApi.this.mWaitAudioDumpResultCb.set(false);
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            TEANativeInsideApi.this.sendMessage(5, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceAudioUploadData(String str, TEAMediaFrame tEAMediaFrame) {
            TEANativeInsideApi.this.mAudioUploadCblock.lock();
            if (TEANativeInsideApi.this.mAudioUploadCb != null) {
                TEANativeInsideApi.this.mAudioUploadCb.onAudioUploadData(new TEAAudioFrame(tEAMediaFrame));
            }
            TEANativeInsideApi.this.mAudioUploadCblock.unlock();
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceControlCommandResult(String str, int i2, String str2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            eventMsgInfo.string0 = str2;
            TEANativeInsideApi.this.sendMessage(8, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceDOAUpdate(String str, float f2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.fVar0 = f2;
            TEANativeInsideApi.this.sendMessage(3, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceExtUltrasoundFilePushDone(String str, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            eventMsgInfo.string0 = str;
            TEANativeInsideApi.this.sendMessage(9, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceExtUltrasoundStopDone(String str, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            eventMsgInfo.string0 = str;
            TEANativeInsideApi.this.sendMessage(10, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceLogDumpDone(String str, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            if (TEANativeInsideApi.this.mIsSync.get()) {
                TEANativeInsideApi.this.sendMessage(12, eventMsgInfo);
                TEANativeInsideApi.this.mIsSync.set(false);
            } else {
                TEANativeInsideApi.this.mWaitLogDumpResultCb.set(false);
                TEANativeInsideApi.this.sendMessage(4, eventMsgInfo);
            }
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceModeState(String str, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            TEANativeInsideApi.this.sendMessage(7, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceOTAResult(String str, int i2) {
            TEANativeInsideApi.this.mWaitOtaResultCb.set(false);
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            TEANativeInsideApi.this.sendMessage(2, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceOTAState(String str, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            TEANativeInsideApi.this.sendMessage(1, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceReboot(String str, int i2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            eventMsgInfo.string0 = str;
            TEANativeInsideApi.this.sendMessage(11, eventMsgInfo);
        }

        @Override // com.tencent.common.ITEATeaDevEventMsgCb
        public void onTeaDeviceStreamMuteState(String str, int i2, boolean z2) {
            EventMsgInfo eventMsgInfo = new EventMsgInfo();
            eventMsgInfo.iVar0 = i2;
            eventMsgInfo.iVar1 = z2 ? 1 : 0;
            TEANativeInsideApi.this.sendMessage(6, eventMsgInfo);
        }
    };

    public class EventHandler extends Handler {
        private WeakReference<TEANativeInsideApi> mWeakRef;

        public EventHandler(Looper looper, TEANativeInsideApi tEANativeInsideApi) {
            super(looper);
            this.mWeakRef = new WeakReference<>(tEANativeInsideApi);
        }

        @Override // android.os.Handler
        public void handleMessage(Message message) {
            if (this.mWeakRef.get() == null) {
                Log.e(TEANativeInsideApi.API_TAG, "mWeakRef is null");
                return;
            }
            TEANativeInsideApi.this.mTeaInsideEventCbLock.lock();
            int i2 = message.what;
            if (i2 > 0 && i2 < 100) {
                handleMessageTeaDeviceApi(message);
            } else if (i2 > 101 && i2 < TEANativeInsideApi.EVENT_MSG_TEA_USB_ACTION_END) {
                handleMessageTeaUsbAction(message);
            } else if (i2 > TEANativeInsideApi.EVENT_MSG_THIRDPARTY_DEVICE_API_START && i2 < TEANativeInsideApi.EVENT_MSG_THIRDPARTY_DEVICE_API_END) {
                handleMessageThirdPartyDeviceApi(message);
            } else if (i2 > TEANativeInsideApi.EVENT_MSG_USER_STATE_UPDATE_START && i2 < 400) {
                handleMessageUserStateUpdateApi(message);
            } else if (i2 > TEANativeInsideApi.EVENT_MSG_DEVICE_CONNECT_STATE_UPDATE_START && i2 < 500) {
                handleMessageDeviceConnectStateUpdateApi(message);
            } else if (i2 > 501 && i2 < TEANativeInsideApi.EVENT_MSG_DEVICE_PORT_ATTACH_STATE_UPDATE_END) {
                handleMessageDevicePortAttachStateUpdateApi(message);
            }
            TEANativeInsideApi.this.mTeaInsideEventCbLock.unlock();
        }

        public void handleMessageDeviceConnectStateUpdateApi(Message message) {
            if (TEANativeInsideApi.this.mTeaInsideDeviceConnectStateUpdateCb == null) {
                Log.i(TEANativeInsideApi.API_TAG, "handleMessageDeviceConnectStateUpdateApi meet cb instance is null");
                return;
            }
            EventMsgInfo eventMsgInfo = (EventMsgInfo) message.obj;
            if (message.what != TEANativeInsideApi.EVENT_MSG_DEVICE_CONNECT_STATE_UPDATE) {
                StringBuilder sbF = g.a.a.a.a.F("handleMessageDeviceConnectStateUpdateApi event msg: ");
                sbF.append(message.what);
                sbF.append(" not recognition");
                Log.w(TEANativeInsideApi.API_TAG, sbF.toString());
                return;
            }
            StringBuilder sbF2 = g.a.a.a.a.F("handleMessageDeviceConnectStateUpdateApi event msg EVENT_MSG_DEVICE_CONNECT_STATE_UPDATE -> dev: ");
            sbF2.append(eventMsgInfo.string0);
            sbF2.append(" mute:");
            sbF2.append(eventMsgInfo.bVar0);
            sbF2.append(" result:");
            g.a.a.a.a.q0(sbF2, eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
            TEANativeInsideApi.this.mTeaInsideDeviceConnectStateUpdateCb.OnDeviceConnectStateUpdate(eventMsgInfo.string0, eventMsgInfo.string1, eventMsgInfo.bVar0, eventMsgInfo.string2);
        }

        public void handleMessageDevicePortAttachStateUpdateApi(Message message) {
            if (TEANativeInsideApi.this.mTeaInsideDevicePortAttachStateUpdateCb == null) {
                Log.i(TEANativeInsideApi.API_TAG, "handleMessageDevicePortAttachStateUpdateApi meet cb instance is null");
                return;
            }
            EventMsgInfo eventMsgInfo = (EventMsgInfo) message.obj;
            if (message.what != TEANativeInsideApi.EVENT_MSG_DEVICE_PORT_ATTACH_STATE_UPDATE) {
                StringBuilder sbF = g.a.a.a.a.F("handleMessageDevicePortAttachStateUpdateApi event msg: ");
                sbF.append(message.what);
                sbF.append(" not recognition");
                Log.w(TEANativeInsideApi.API_TAG, sbF.toString());
                return;
            }
            StringBuilder sbF2 = g.a.a.a.a.F("handleMessageDevicePortAttachStateUpdateApi event msg EVENT_MSG_DEVICE_CONNECT_STATE_UPDATE -> dev: ");
            sbF2.append(eventMsgInfo.string0);
            sbF2.append(" mute:");
            sbF2.append(eventMsgInfo.bVar0);
            sbF2.append(" result:");
            g.a.a.a.a.q0(sbF2, eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
            TEANativeInsideApi.this.mTeaInsideDevicePortAttachStateUpdateCb.onDevicePortAttachStateUpdate(eventMsgInfo.string0, eventMsgInfo.iVar0, eventMsgInfo.string1, eventMsgInfo.bVar0, eventMsgInfo.string2);
        }

        public void handleMessageTeaDeviceApi(Message message) {
            String string;
            if (TEANativeInsideApi.this.mTeaInsideTeaDevEventCb != null) {
                EventMsgInfo eventMsgInfo = (EventMsgInfo) message.obj;
                switch (message.what) {
                    case 1:
                        g.a.a.a.a.q0(g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_OTA_STATE -> ota state: "), eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onOTAStateChange(eventMsgInfo.iVar0);
                        return;
                    case 2:
                        g.a.a.a.a.q0(g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_OTA_RESULT -> ota result: "), eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onOTAResultUpdate(eventMsgInfo.iVar0);
                        return;
                    case 3:
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onDOAUpdate(eventMsgInfo.fVar0);
                        return;
                    case 4:
                        g.a.a.a.a.q0(g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_LOG_DUMP_DONE -> dump result: "), eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onDeviceLogUpgrade(eventMsgInfo.iVar0);
                        return;
                    case 5:
                        g.a.a.a.a.q0(g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_AUDIO_DUMP_DONE -> dump result: "), eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onAudioDumpUpgrade(eventMsgInfo.iVar0);
                        return;
                    case 6:
                        StringBuilder sbF = g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_STREAM_MUTE_STATE -> streamType: ");
                        sbF.append(eventMsgInfo.iVar0);
                        sbF.append(" mute: ");
                        g.a.a.a.a.q0(sbF, eventMsgInfo.iVar1, TEANativeInsideApi.API_TAG);
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onStreamMuteStatusUpdate(eventMsgInfo.iVar0, eventMsgInfo.iVar1 == 1);
                        return;
                    case 7:
                        g.a.a.a.a.q0(g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_MODE_STATE -> mode: "), eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onModeStatusUpdate(eventMsgInfo.iVar0);
                        return;
                    case 8:
                        StringBuilder sbF2 = g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_CTRL_CMD_RESULT -> cmd: ");
                        sbF2.append(eventMsgInfo.iVar0);
                        sbF2.append(" response:");
                        sbF2.append(eventMsgInfo.string0);
                        Log.i(TEANativeInsideApi.API_TAG, sbF2.toString());
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onControlCmdResult(eventMsgInfo.iVar0, eventMsgInfo.string0);
                        return;
                    case 9:
                        StringBuilder sbF3 = g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_ULTRA_FILE_PUSH_RESULT -> result: ");
                        sbF3.append(eventMsgInfo.iVar0);
                        sbF3.append(" device:");
                        sbF3.append(eventMsgInfo.string0);
                        Log.i(TEANativeInsideApi.API_TAG, sbF3.toString());
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onExtUltrasoundFilePushDone(eventMsgInfo.string0, eventMsgInfo.iVar0);
                        return;
                    case 10:
                        StringBuilder sbF4 = g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_ULTRA_STOP_RESULT -> result: ");
                        sbF4.append(eventMsgInfo.iVar0);
                        sbF4.append(" device:");
                        sbF4.append(eventMsgInfo.string0);
                        Log.i(TEANativeInsideApi.API_TAG, sbF4.toString());
                        TEANativeInsideApi.this.mTeaInsideTeaDevEventCb.onExtUltrasoundStopDone(eventMsgInfo.string0, eventMsgInfo.iVar0);
                        return;
                    case 11:
                        StringBuilder sbF5 = g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_REBOOT_RESULT -> result: ");
                        sbF5.append(eventMsgInfo.iVar0);
                        sbF5.append(" device:");
                        sbF5.append(eventMsgInfo.string0);
                        string = sbF5.toString();
                        break;
                    case 12:
                        g.a.a.a.a.q0(g.a.a.a.a.F("handleMessageTeaDeviceApi event msg EVENT_MSG_TEA_DEVICE_LOG_SYNC_DONE -> sync result: "), eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                        TEANativeInsideApi.this._syncMasterDeviceDebugFilesToHost("/sdcard/Android/data/com.tencent.hidexampledemo", 0, 1);
                        return;
                    default:
                        StringBuilder sbF6 = g.a.a.a.a.F("handleMessageTeaDeviceApi event msg: ");
                        sbF6.append(message.what);
                        sbF6.append(" not recognition");
                        Log.w(TEANativeInsideApi.API_TAG, sbF6.toString());
                        return;
                }
            } else {
                string = "handleMessageTeaDeviceApi meet cb instance is null";
            }
            Log.i(TEANativeInsideApi.API_TAG, string);
        }

        public void handleMessageTeaUsbAction(Message message) {
            if (TEANativeInsideApi.this.mConnectCb == null) {
                Log.i(TEANativeInsideApi.API_TAG, "handleMessageTeaUsbAction meet cb instance is null");
            }
            EventMsgInfo eventMsgInfo = (EventMsgInfo) message.obj;
            switch (message.what) {
                case 102:
                    g.a.a.a.a.q0(g.a.a.a.a.F("handleMessageTeaUsbAction event msg EVENT_MSG_TEA_DEVICE_CHECK_VERSION_IF_CB_SUCCESS -> afterPermissionCheck: "), eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                    TEANativeInsideApi.this.checkVersionIfCallbackSuccess(eventMsgInfo.bVar0, eventMsgInfo.string0, eventMsgInfo.iVar0, eventMsgInfo.iVar1);
                    break;
                case 103:
                    Log.i(TEANativeInsideApi.API_TAG, "handleMessageTeaUsbAction event msg EVENT_MSG_TEA_DEVICE_ATTACH");
                    TEANativeInsideApi.this.mConnectCb.onUsbAttach(eventMsgInfo.string0, eventMsgInfo.iVar0, eventMsgInfo.iVar1);
                    break;
                case 104:
                    Log.i(TEANativeInsideApi.API_TAG, "handleMessageTeaUsbAction event msg EVENT_MSG_TEA_DEVICE_DETACH");
                    TEANativeInsideApi.this.mConnectCb.onUsbDetech(eventMsgInfo.string0, eventMsgInfo.iVar0, eventMsgInfo.iVar1);
                    break;
                case 105:
                    Log.i(TEANativeInsideApi.API_TAG, "handleMessageTeaUsbAction event msg EVENT_MSG_TEA_DEVICE_SELECT");
                    TEANativeInsideApi.this.mConnectCb.onUsbDeviceSelect(eventMsgInfo.string0);
                    break;
                default:
                    StringBuilder sbF = g.a.a.a.a.F("handleMessageTeaUsbAction event msg: ");
                    sbF.append(message.what);
                    sbF.append(" not recognition");
                    Log.w(TEANativeInsideApi.API_TAG, sbF.toString());
                    break;
            }
        }

        public void handleMessageThirdPartyDeviceApi(Message message) {
            if (TEANativeInsideApi.this.mTeaInsideThirdPartyDevEventCb == null) {
                Log.i(TEANativeInsideApi.API_TAG, "handleMessageThirdPartyDeviceApi meet cb instance is null");
            }
            EventMsgInfo eventMsgInfo = (EventMsgInfo) message.obj;
            switch (message.what) {
                case TEANativeInsideApi.EVENT_MSG_THIRDPARTY_DEVICE_UPGRADE_STATE /* 202 */:
                    StringBuilder sbF = g.a.a.a.a.F("handleMessageThirdPartyDeviceApi event msg EVENT_MSG_THIRDPARTY_DEVICE_UPGRADE_STATE -> dev: ");
                    sbF.append(eventMsgInfo.string0);
                    sbF.append(" upgrade_state:");
                    g.a.a.a.a.q0(sbF, eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                    TEANativeInsideApi.this.mTeaInsideThirdPartyDevEventCb.onUpgradeStateChange(eventMsgInfo.string0, eventMsgInfo.iVar0);
                    break;
                case TEANativeInsideApi.EVENT_MSG_THIRDPARTY_DEVICE_UPGRADE_RESULT /* 203 */:
                    StringBuilder sbF2 = g.a.a.a.a.F("handleMessageThirdPartyDeviceApi event msg EVENT_MSG_THIRDPARTY_DEVICE_UPGRADE_RESULT -> dev: ");
                    sbF2.append(eventMsgInfo.string0);
                    sbF2.append(" upgrade_result:");
                    g.a.a.a.a.q0(sbF2, eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                    TEANativeInsideApi.this.mTeaInsideThirdPartyDevEventCb.onUpgradeResult(eventMsgInfo.string0, eventMsgInfo.iVar0);
                    break;
                case TEANativeInsideApi.EVENT_MSG_THIRDPARTY_DEVICE_CTRL_CMD_RESULT /* 204 */:
                    StringBuilder sbF3 = g.a.a.a.a.F("handleMessageThirdPartyDeviceApi event msg EVENT_MSG_THIRDPARTY_DEVICE_CTRL_CMD_RESULT -> dev: ");
                    sbF3.append(eventMsgInfo.string0);
                    sbF3.append(" type:");
                    sbF3.append(eventMsgInfo.iVar0);
                    sbF3.append(" result:");
                    sbF3.append(eventMsgInfo.iVar1);
                    sbF3.append(" describe:");
                    sbF3.append(eventMsgInfo.objVar0.toString());
                    Log.i(TEANativeInsideApi.API_TAG, sbF3.toString());
                    TEANativeInsideApi.this.mTeaInsideThirdPartyDevEventCb.onControlResult(eventMsgInfo.string0, eventMsgInfo.iVar0, eventMsgInfo.iVar1, eventMsgInfo.objVar0.toString());
                    break;
                default:
                    StringBuilder sbF4 = g.a.a.a.a.F("handleMessageThirdPartyDeviceApi event msg: ");
                    sbF4.append(message.what);
                    sbF4.append(" not recognition");
                    Log.w(TEANativeInsideApi.API_TAG, sbF4.toString());
                    break;
            }
        }

        public void handleMessageUserStateUpdateApi(Message message) {
            if (TEANativeInsideApi.this.mTeaInsideUserStateUpdateCb == null) {
                Log.i(TEANativeInsideApi.API_TAG, "handleMessageUserStateUpdateApi meet cb instance is null");
            }
            EventMsgInfo eventMsgInfo = (EventMsgInfo) message.obj;
            switch (message.what) {
                case TEANativeInsideApi.EVENT_MSG_USER_STATE_MIC_MUTE /* 302 */:
                    StringBuilder sbF = g.a.a.a.a.F("handleMessageUserStateUpdateApi event msg EVENT_MSG_USER_STATE_MIC_MUTE -> dev: ");
                    sbF.append(eventMsgInfo.string0);
                    sbF.append(" mute:");
                    sbF.append(eventMsgInfo.bVar0);
                    sbF.append(" result:");
                    g.a.a.a.a.q0(sbF, eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                    TEANativeInsideApi.this.mTeaInsideUserStateUpdateCb.OnDeviceMicrophoneOverallMuteStateUpdate(eventMsgInfo.string0, eventMsgInfo.bVar0, eventMsgInfo.iVar0);
                    break;
                case TEANativeInsideApi.EVENT_MSG_USER_STATE_SPEAKER_VOLUME /* 303 */:
                    StringBuilder sbF2 = g.a.a.a.a.F("handleMessageUserStateUpdateApi event msg EVENT_MSG_USER_STATE_SPEAKER_VOLUME -> dev: ");
                    sbF2.append(eventMsgInfo.string0);
                    sbF2.append(" volume:");
                    sbF2.append(eventMsgInfo.fVar0);
                    sbF2.append(" result:");
                    g.a.a.a.a.q0(sbF2, eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                    TEANativeInsideApi.this.mTeaInsideUserStateUpdateCb.OnDeviceSpeakerOverallVolumeUpdate(eventMsgInfo.string0, eventMsgInfo.fVar0, eventMsgInfo.iVar0);
                    break;
                case TEANativeInsideApi.EVENT_MSG_USER_STATE_OFF_HOOK /* 304 */:
                    StringBuilder sbF3 = g.a.a.a.a.F("handleMessageUserStateUpdateApi event msg EVENT_MSG_USER_STATE_OFF_HOOK -> dev: ");
                    sbF3.append(eventMsgInfo.string0);
                    sbF3.append(" off_hook:");
                    sbF3.append(eventMsgInfo.bVar0);
                    sbF3.append(" result:");
                    g.a.a.a.a.q0(sbF3, eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                    TEANativeInsideApi.this.mTeaInsideUserStateUpdateCb.OnDeviceOffHookStateUpdate(eventMsgInfo.string0, eventMsgInfo.bVar0, eventMsgInfo.iVar0);
                    break;
                case TEANativeInsideApi.EVENT_MSG_USER_STATE_VOLUME_UP /* 305 */:
                    StringBuilder sbF4 = g.a.a.a.a.F("handleMessageUserStateUpdateApi event msg EVENT_MSG_USER_STATE_VOLUME_UP -> dev: ");
                    sbF4.append(eventMsgInfo.string0);
                    sbF4.append(" off_hook:");
                    sbF4.append(eventMsgInfo.bVar0);
                    sbF4.append(" result:");
                    g.a.a.a.a.q0(sbF4, eventMsgInfo.iVar0, TEANativeInsideApi.API_TAG);
                    TEANativeInsideApi.this.mTeaInsideUserStateUpdateCb.OnDeviceVolumeUpDownStateUpdate(eventMsgInfo.string0, eventMsgInfo.bVar0, eventMsgInfo.iVar0);
                    break;
                default:
                    StringBuilder sbF5 = g.a.a.a.a.F("handleMessageUserStateUpdateApi event msg: ");
                    sbF5.append(message.what);
                    sbF5.append(" not recognition");
                    Log.w(TEANativeInsideApi.API_TAG, sbF5.toString());
                    break;
            }
        }
    }

    public static class EventMsgInfo {
        public boolean bVar0;
        public float fVar0;
        public int iVar0;
        public int iVar1;
        public long lVar0;
        public Object objVar0;
        public String string0;
        public String string1;
        public String string2;

        private EventMsgInfo() {
        }
    }

    static {
        try {
            com.tencent.common.a.b(null);
        } catch (UnsupportedOperationException e2) {
            Log.e(API_TAG, e2.getMessage());
        }
    }

    public TEANativeInsideApi(Context context, ITEAUsbEventCb iTEAUsbEventCb) {
        EventHandler eventHandler;
        this.mUsbMonitor = null;
        this.mConnectCb = null;
        this.mContext = null;
        if (context != null) {
            Context applicationContext = context.getApplicationContext();
            this.mContext = applicationContext;
            a.a(applicationContext);
            a aVarC = a.c();
            this.mUsbMonitor = aVarC;
            aVarC.a(this.mUsgStateChangeCb);
        }
        this.mConnectCb = iTEAUsbEventCb;
        _createSdk();
        Looper looperMyLooper = Looper.myLooper();
        if (looperMyLooper != null) {
            eventHandler = new EventHandler(looperMyLooper, this);
        } else {
            Looper mainLooper = Looper.getMainLooper();
            if (mainLooper == null) {
                this.mEventHandler = null;
                return;
            }
            eventHandler = new EventHandler(mainLooper, this);
        }
        this.mEventHandler = eventHandler;
    }

    private final native int _closeNativeHidDevice();

    private final native int _createSdk();

    private final native String _getAllDeviceInformation();

    private final native int _getDeviceDump(long j2, String str);

    private final native String _getDeviceInformation();

    private final native int _getDeviceLineoutSinkRouteMode();

    private final native int _getDeviceLog(String str);

    private final native int _getDeviceMode();

    private final native boolean _getDeviceMute(int i2);

    private final native int _getDeviceOTAState();

    private final native boolean _getDeviceOffHook();

    private final native int[] _getDeviceOverallBeamformingStartEndAngle();

    private final native int _getDevicePoeSinkRouteMode();

    private final native String _getDevicePortAttachInformation();

    private final native float _getDevicePreprocessOverallAiNsAggressiveness();

    private final native float _getDeviceSpeakerOverallVolume();

    private final native int _getDeviceStatus();

    private final native String _getDeviceVersion();

    private final native int _getDevicesCount();

    private final native int _getSDKState();

    private final native String _getVersion();

    private final native int _insertNativeHidDevice(UsbHidDevice usbHidDevice);

    private final native int _openNativeHidDevice(int i2, int i3, int i4, int i5, int i6, int i7, int i8);

    private final native int _openNativeHidDevices(UsbHidDevice[] usbHidDeviceArr, int i2);

    private final native int _pushNewExternalUltrasoundWavFile(String str);

    private final native int _rebootDevice();

    private final native int _registerDeviceConnectStateChangeEventCb(Object obj);

    private final native int _registerDevicePortAttachStateChangeEventCb(Object obj);

    private final native int _registerTeaDeviceEventCb(Object obj);

    private final native int _registerThirdPartyDeviceEventCb(Object obj);

    private final native int _registerUserStateChangeEventCb(Object obj);

    private final native int _reinit();

    private final native int _releaseSdk();

    private final native int _removeNativeHidDevice(String str);

    private final native int _selectNativeHidDevice(String str);

    private final native int _sendThirdPartyDeviceControl(String str, int i2, String str2);

    private final native int _setDeviceDoaUploadEnable(boolean z2);

    private final native int _setDeviceLineoutSinkRouteMode(int i2);

    private final native int _setDeviceMode(int i2);

    private final native int _setDeviceMute(int i2, boolean z2);

    private final native int _setDeviceOffHook(boolean z2);

    private final native int _setDeviceOverallBeamformingStartEndAngle(int i2, int i3);

    private final native int _setDevicePoeSinkRouteMode(int i2);

    private final native int _setDevicePreprocessOverallAiNsAggressiveness(float f2);

    private final native int _setDeviceRingCall(boolean z2);

    private final native int _setDeviceTimeMs(long j2);

    private final native int _setHostPlatform(int i2);

    private final native int _startDeviceOTA(String str, String str2);

    private final native int _startPlayExternalUltrasoundWavFile(int i2);

    private final native int _startThirdPartyDeviceOTA(String str, String str2, String str3);

    private final native int _startUploadDeviceAudioPcm();

    private final native int _stopPlayExternalUltrasoundWavFile();

    private final native int _stopUploadDeviceAudioPcm();

    /* JADX INFO: Access modifiers changed from: private */
    public final native int _syncMasterDeviceDebugFilesToHost(String str, int i2, int i3);

    private final native int _syncSpecificDevicesLogToMasterDevice(int i2, String[] strArr, boolean z2);

    private final native int _unregisterDeviceConnectStateChangeEventCb();

    private final native int _unregisterDevicePortAttachStateChangeEventCb();

    private final native int _unregisterTeaDeviceEventCb();

    private final native int _unregisterThirdPartyDeviceEventCb();

    private final native int _unregisterUserStateChangeEventCb();

    /* JADX INFO: Access modifiers changed from: private */
    public void checkVersionIfCallbackSuccess(boolean z2, String str, int i2, int i3) {
        Log.i(API_TAG, "init success then check device version");
        String deviceVersion = getDeviceVersion();
        if (TextUtils.equals(deviceVersion, "")) {
            if (this.mCheckDeviceVersionRetryInit > 0) {
                StringBuilder sbF = g.a.a.a.a.F("check device version failed to reinit device, trycnt:");
                sbF.append(this.mCheckDeviceVersionRetryInit);
                Log.w(API_TAG, sbF.toString());
                this.mCheckDeviceVersionRetryInit--;
                return;
            }
            return;
        }
        Log.i(API_TAG, "check device version success ver:" + deviceVersion + ", cb onUsbOpenSuccess");
        setDeviceTimeMs(System.currentTimeMillis());
        _setHostPlatform(0);
        ITEAUsbEventCb iTEAUsbEventCb = this.mConnectCb;
        if (iTEAUsbEventCb != null) {
            iTEAUsbEventCb.onUsbOpenSuccess(z2, str, i2, i3);
        }
    }

    private synchronized int closeNativeHidDevice() {
        int i_closeNativeHidDevice;
        i_closeNativeHidDevice = _closeNativeHidDevice();
        if (i_closeNativeHidDevice == 0) {
            this.mHasInit = false;
        }
        return i_closeNativeHidDevice;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public synchronized int insertNativeHidDevice(UsbHidDevice usbHidDevice) {
        return _insertNativeHidDevice(usbHidDevice);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public boolean isCurrentDevice(UsbDevice usbDevice) {
        return this.mUsbDevice != null && usbDevice.getDeviceId() == this.mUsbDevice.getDeviceId();
    }

    private int openHidDevice() {
        String str;
        Log.i(API_TAG, "openHidDevice");
        Context context = this.mContext;
        if (context == null) {
            str = "[Error]Open hid device failed, context is null";
        } else {
            UsbHidDevice.factory(context);
            UsbHidDevice[] hidDeviceList = UsbHidDevice.getHidDeviceList();
            if (hidDeviceList != null && hidDeviceList.length != 0) {
                for (UsbHidDevice usbHidDevice : hidDeviceList) {
                    usbHidDevice.open(this.mContext, new b() { // from class: com.tencent.api.TEANativeInsideApi.3
                        @Override // com.tencent.usb.b
                        public void onUsbHidDeviceConnectFailed(UsbHidDevice usbHidDevice2) {
                            Log.e(TEANativeInsideApi.API_TAG, "[Open]Open java hid device failed");
                        }

                        @Override // com.tencent.usb.b
                        public void onUsbHidDeviceConnected(UsbHidDevice usbHidDevice2) {
                            Log.i(TEANativeInsideApi.API_TAG, "[Open]Open java hid device success");
                            TEANativeInsideApi.this.insertNativeHidDevice(usbHidDevice2);
                            Log.i(TEANativeInsideApi.API_TAG, "[Open]Open native hid device success, request permission: Yes, check version");
                            TEANativeInsideApi.this.postCheckDeviceIfCallbackSuccessMsg(true, usbHidDevice2);
                        }
                    });
                }
                int iOpenNativeHidDevices = openNativeHidDevices(hidDeviceList, hidDeviceList.length);
                usbDeviceSelect(hidDeviceList[0].getDeviceName());
                sendDeviceSelectMsg(hidDeviceList[0].getDeviceName());
                return iOpenNativeHidDevices;
            }
            str = "[Error]Open hid device failed, no device attached";
        }
        Log.e(API_TAG, str);
        return -1;
    }

    private synchronized int openNativeHidDevice(int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
        int i_openNativeHidDevice;
        Log.i(API_TAG, "Libusb->vid:0x" + Integer.toHexString(i2) + ",pid:0x" + Integer.toHexString(i3) + ",busnum:" + i4 + ",devnum:" + i5 + ",inEpAddr:" + i6 + ",outEpAddr:" + i7 + ",fd:" + i8);
        i_openNativeHidDevice = _openNativeHidDevice(i2, i3, i4, i5, i6, i7, i8);
        StringBuilder sb = new StringBuilder();
        sb.append("Libusb->getUsbDevice with pid/vid/fd,ret=");
        sb.append(i_openNativeHidDevice);
        Log.i(API_TAG, sb.toString());
        return i_openNativeHidDevice;
    }

    private synchronized int openNativeHidDevices(UsbHidDevice[] usbHidDeviceArr, int i2) {
        int i_openNativeHidDevices;
        Log.i(API_TAG, "openNativeHidDevices");
        i_openNativeHidDevices = _openNativeHidDevices(usbHidDeviceArr, i2);
        Log.i(API_TAG, "openNativeHidDevices,ret=" + i_openNativeHidDevices);
        return i_openNativeHidDevices;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void postCheckDeviceIfCallbackSuccessMsg(boolean z2, UsbHidDevice usbHidDevice) {
        Log.i(API_TAG, "init success then post check device version message");
        EventMsgInfo eventMsgInfo = new EventMsgInfo();
        eventMsgInfo.bVar0 = z2;
        eventMsgInfo.iVar0 = usbHidDevice.getDeviceVid();
        eventMsgInfo.iVar1 = usbHidDevice.getDevicePid();
        eventMsgInfo.string0 = usbHidDevice.getDeviceName();
        sendMessage(102, eventMsgInfo);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public synchronized int removeNativeHidDevice(String str) {
        return _removeNativeHidDevice(str);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void sendMessage(int i2, Object obj) {
        EventHandler eventHandler = this.mEventHandler;
        if (eventHandler != null) {
            Message.obtain(eventHandler, i2, obj).sendToTarget();
        }
    }

    public synchronized int SetDeviceMicrophoneOverallMute(int i2, boolean z2) {
        StringBuilder sb = new StringBuilder();
        sb.append("setDeviceMute:");
        sb.append(z2 ? "MUTE" : "UNMUTE");
        Log.i(API_TAG, sb.toString());
        return _setDeviceMute(i2, z2);
    }

    public synchronized String getAllDeviceInformation() {
        Log.i(API_TAG, "getAllDeviceInformation");
        return _getAllDeviceInformation();
    }

    public synchronized String getCurrentDeviceName() {
        UsbHidDevice usbHidDevice = this.mUsbDevice;
        if (usbHidDevice == null) {
            return "";
        }
        return usbHidDevice.getDeviceName();
    }

    public synchronized int getDeviceDump(long j2, String str) {
        Log.i(API_TAG, "getDeviceDump");
        this.mWaitAudioDumpResultCb.set(true);
        return _getDeviceDump(j2, str);
    }

    public synchronized String getDeviceInformation() {
        Log.i(API_TAG, "getDeviceInformation");
        return _getDeviceInformation();
    }

    public synchronized int getDeviceLineoutSinkRouteMode() {
        int i_getDeviceLineoutSinkRouteMode;
        i_getDeviceLineoutSinkRouteMode = _getDeviceLineoutSinkRouteMode();
        Log.i(API_TAG, "getDeviceLineoutSinkRouteMode: mode: " + i_getDeviceLineoutSinkRouteMode);
        return i_getDeviceLineoutSinkRouteMode;
    }

    public synchronized int getDeviceLog(String str) {
        Log.i(API_TAG, "getDeviceLog");
        this.mWaitLogDumpResultCb.set(true);
        return _getDeviceLog(str);
    }

    public synchronized int getDeviceLogNew(String str) {
        Log.i(API_TAG, "getDeviceLogNew");
        this.mWaitLogDumpResultCb.set(true);
        this.mIsSync.set(true);
        return _syncSpecificDevicesLogToMasterDevice(0, null, false);
    }

    public synchronized int getDeviceMode() {
        int i_getDeviceMode;
        i_getDeviceMode = _getDeviceMode();
        Log.i(API_TAG, "getDeviceMode:" + i_getDeviceMode);
        return i_getDeviceMode;
    }

    public synchronized boolean getDeviceMute(int i2) {
        boolean z_getDeviceMute;
        z_getDeviceMute = _getDeviceMute(i2);
        StringBuilder sb = new StringBuilder();
        sb.append("getDeviceMute:");
        sb.append(z_getDeviceMute ? "MUTE" : "UNMUTE");
        Log.i(API_TAG, sb.toString());
        return z_getDeviceMute;
    }

    public synchronized int getDeviceOTAState() {
        Log.i(API_TAG, "getDeviceOTAState");
        return _getDeviceOTAState();
    }

    public synchronized boolean getDeviceOffHook() {
        Log.i(API_TAG, "getDeviceOffHook");
        return _getDeviceOffHook();
    }

    public synchronized int[] getDeviceOverallBeamformingStartEndAngle() {
        Log.i(API_TAG, "getDeviceOverallBeamformingStartEndAngle");
        return _getDeviceOverallBeamformingStartEndAngle();
    }

    public synchronized int getDevicePoeSinkRouteMode() {
        int i_getDevicePoeSinkRouteMode;
        i_getDevicePoeSinkRouteMode = _getDevicePoeSinkRouteMode();
        Log.i(API_TAG, "getDevicePoeSinkRouteMode: mode: " + i_getDevicePoeSinkRouteMode);
        return i_getDevicePoeSinkRouteMode;
    }

    public synchronized String getDevicePortAttachInformation() {
        String str_getDevicePortAttachInformation;
        str_getDevicePortAttachInformation = _getDevicePortAttachInformation();
        Log.i(API_TAG, "getDevicePortAttachInformation: " + str_getDevicePortAttachInformation);
        return str_getDevicePortAttachInformation;
    }

    public synchronized float getDevicePreprocessOverallAiNsAggressiveness() {
        float f_getDevicePreprocessOverallAiNsAggressiveness;
        f_getDevicePreprocessOverallAiNsAggressiveness = _getDevicePreprocessOverallAiNsAggressiveness();
        Log.i(API_TAG, "getDevicePreprocessOverallAiNsAggressiveness: aggr " + f_getDevicePreprocessOverallAiNsAggressiveness);
        return f_getDevicePreprocessOverallAiNsAggressiveness;
    }

    public synchronized float getDeviceSpeakerOverallVolume() {
        Log.i(API_TAG, "getDeviceSpeakerOverallVolume");
        return _getDeviceSpeakerOverallVolume();
    }

    public synchronized int getDeviceStatus() {
        Log.i(API_TAG, "getDeviceStatus");
        return _getDeviceStatus();
    }

    public synchronized String getDeviceVersion() {
        Log.i(API_TAG, "getDeviceVersion");
        return _getDeviceVersion();
    }

    public synchronized int getDevicesCount() {
        Log.i(API_TAG, "getDevicesCount");
        return _getDevicesCount();
    }

    public Map<String, String> getHidDeviceList() {
        this.mDeviceList.clear();
        for (UsbHidDevice usbHidDevice : UsbHidDevice.getHidDeviceList()) {
            this.mDeviceList.put(usbHidDevice.getDeviceName(), usbHidDevice.getDeviceInfo());
        }
        return this.mDeviceList;
    }

    public synchronized int getSDKState() {
        int i_getSDKState;
        i_getSDKState = _getSDKState();
        Log.i(API_TAG, "getSDKState state: " + i_getSDKState);
        return i_getSDKState;
    }

    public synchronized String getSdkVersion() {
        Log.i(API_TAG, "getSdkVersion");
        return _getVersion();
    }

    public synchronized int init() {
        Log.i(API_TAG, "initialize(tname:" + Thread.currentThread().getName() + ",tid:" + Thread.currentThread().getId() + ")");
        if (this.mHasInit) {
            Log.w(API_TAG, "[Warn]TeaApi has initialized, return directly");
            return 0;
        }
        _registerTeaDeviceEventCb(this.mTeaDevEventMsgCb);
        _registerThirdPartyDeviceEventCb(this.mThirdPartyDevEventMsgCb);
        _registerUserStateChangeEventCb(this.mITeaUserStateUpdateCb);
        _registerDeviceConnectStateChangeEventCb(this.mITeaDeviceConnectStateUpdateCb);
        _registerDevicePortAttachStateChangeEventCb(this.mITeaInsideDevicePortAttachStateUpdateCb);
        this.mHasInit = true;
        return openHidDevice();
    }

    public synchronized int pushNewExternalUltrasoundWavFile(String str) {
        Log.i(API_TAG, "pushNewExternalUltrasoundWavFile: file: " + str);
        return _pushNewExternalUltrasoundWavFile(str);
    }

    public synchronized int rebootDevice() {
        Log.i(API_TAG, "rebootDevice");
        return _rebootDevice();
    }

    public synchronized void registerAudioUploadCb(ITEAAudioUploadCb iTEAAudioUploadCb) {
        Log.i(API_TAG, "registerAudioUploadCb");
        this.mAudioUploadCblock.lock();
        this.mAudioUploadCb = iTEAAudioUploadCb;
        this.mAudioUploadCblock.unlock();
    }

    public synchronized void registerDeviceConnectStateUpdataCb(ITEAInsideDeviceConnectStateUpdateCbDelegate iTEAInsideDeviceConnectStateUpdateCbDelegate) {
        Log.i(API_TAG, "registerDeviceConnectStateUpdataCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideDeviceConnectStateUpdateCb = iTEAInsideDeviceConnectStateUpdateCbDelegate;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized void registerDevicePortAttachStateUpdateCb(ITEAInsideDevicePortAttachStateUpdateCbDelegate iTEAInsideDevicePortAttachStateUpdateCbDelegate) {
        Log.i(API_TAG, "registerDevicePortAttachStateUpdateCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideDevicePortAttachStateUpdateCb = iTEAInsideDevicePortAttachStateUpdateCbDelegate;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized void registerTeaDevEventCb(ITEANativeInsideTeaDevEventCb iTEANativeInsideTeaDevEventCb) {
        Log.i(API_TAG, "registerTeaDevEventCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideTeaDevEventCb = iTEANativeInsideTeaDevEventCb;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized void registerThirdPartyDevEventCb(ITEANativeInsideThirdPartyDevEventCb iTEANativeInsideThirdPartyDevEventCb) {
        Log.i(API_TAG, "registerThirdPartyDevEventCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideThirdPartyDevEventCb = iTEANativeInsideThirdPartyDevEventCb;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized void registerUserStateUpdataCb(ITEANativeInsideTeaUserStateUpdateEventCb iTEANativeInsideTeaUserStateUpdateEventCb) {
        Log.i(API_TAG, "registerUserStateUpdataCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideUserStateUpdateCb = iTEANativeInsideTeaUserStateUpdateEventCb;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized int reinit() {
        Log.i(API_TAG, "reinitialize(tname:" + Thread.currentThread().getName() + ",tid:" + Thread.currentThread().getId() + ")");
        if (uninit() == -1) {
            return -1;
        }
        _releaseSdk();
        _createSdk();
        return init();
    }

    public synchronized int release() {
        Log.i(API_TAG, "release(tname:" + Thread.currentThread().getName() + ",tid:" + Thread.currentThread().getId() + ")");
        this.mUsbMonitor.b();
        return _releaseSdk();
    }

    public synchronized void sendDeviceSelectMsg(String str) {
        EventMsgInfo eventMsgInfo = new EventMsgInfo();
        eventMsgInfo.string0 = str;
        sendMessage(105, eventMsgInfo);
    }

    public synchronized int sendThirdPartyDeviceControl(String str, int i2, String str2) {
        Log.i(API_TAG, "sendThirdPartyDeviceControl");
        return _sendThirdPartyDeviceControl(str, i2, str2);
    }

    public synchronized int setDeviceDoaUploadEnable(boolean z2) {
        Log.i(API_TAG, "setDeviceDoaUploadEnable:" + z2);
        return _setDeviceDoaUploadEnable(z2);
    }

    public synchronized int setDeviceLineoutSinkRouteMode(int i2) {
        Log.i(API_TAG, "setDeviceLineoutSinkRouteMode: mode: " + i2);
        return _setDeviceLineoutSinkRouteMode(i2);
    }

    public synchronized int setDeviceMode(int i2) {
        Log.i(API_TAG, "setDeviceMode:" + i2);
        return _setDeviceMode(i2);
    }

    public synchronized int setDeviceMute(int i2, boolean z2) {
        StringBuilder sb = new StringBuilder();
        sb.append("setDeviceMute:");
        sb.append(z2 ? "MUTE" : "UNMUTE");
        Log.i(API_TAG, sb.toString());
        byte[] bArr = new byte[2];
        bArr[0] = 2;
        if (z2) {
            bArr[1] = 3;
        } else {
            bArr[1] = 1;
        }
        UsbHidDevice usbHidDevice = this.mUsbDevice;
        if (usbHidDevice == null) {
            return -1;
        }
        usbHidDevice.write(bArr);
        return 0;
    }

    public synchronized int setDeviceOffHook(boolean z2) {
        StringBuilder sb = new StringBuilder();
        sb.append("setDeviceOffHook:");
        sb.append(z2 ? "offhook" : "onhook");
        Log.i(API_TAG, sb.toString());
        return _setDeviceOffHook(z2);
    }

    public synchronized int setDeviceOverallBeamformingStartEndAngle(int i2, int i3) {
        Log.i(API_TAG, "setDeviceOverallBeamformingStartEndAngle: start_angle: " + i2 + ", end_angle: " + i3);
        return _setDeviceOverallBeamformingStartEndAngle(i2, i3);
    }

    public synchronized int setDevicePoeSinkRouteMode(int i2) {
        Log.i(API_TAG, "setDevicePoeSinkRouteMode: mode: " + i2);
        return _setDevicePoeSinkRouteMode(i2);
    }

    public synchronized int setDevicePreprocessOverallAiNsAggressiveness(float f2) {
        Log.i(API_TAG, "setDevicePreprocessOverallAiNsAggressiveness: aggr: " + f2);
        return _setDevicePreprocessOverallAiNsAggressiveness(f2);
    }

    public synchronized int setDeviceRingCall(boolean z2) {
        StringBuilder sb = new StringBuilder();
        sb.append("setDeviceRingCall:");
        sb.append(z2 ? "true" : "false");
        Log.i(API_TAG, sb.toString());
        return _setDeviceRingCall(z2);
    }

    public synchronized int setDeviceTimeMs(long j2) {
        Log.i(API_TAG, "setDeviceTimeMs:" + j2 + "ms");
        return _setDeviceTimeMs(j2);
    }

    public synchronized int startDeviceOTA(String str, String str2) {
        Log.i(API_TAG, "startDeviceOTA");
        this.mWaitOtaResultCb.set(true);
        return _startDeviceOTA(str, str2);
    }

    public synchronized int startPlayExternalUltrasoundWavFile(int i2) {
        Log.i(API_TAG, "startPlayExternalUltrasoundWavFile");
        return _startPlayExternalUltrasoundWavFile(i2);
    }

    public synchronized int startThirdPartyDeviceOta(String str, String str2, String str3) {
        Log.i(API_TAG, "startThirdPartyDeviceOta");
        this.mWaitOtaResultCb.set(true);
        return _startThirdPartyDeviceOTA(str, str2, str3);
    }

    public synchronized int startUploadDeviceAudioPcm() {
        if (this.mStartUploadDevicePcm) {
            Log.i(API_TAG, "startUploadDeviceAudioPcm has started, return directly");
            return 0;
        }
        Log.i(API_TAG, "startUploadDeviceAudioPcm start");
        int i_startUploadDeviceAudioPcm = _startUploadDeviceAudioPcm();
        if (i_startUploadDeviceAudioPcm == 0) {
            this.mStartUploadDevicePcm = true;
            Log.i(API_TAG, "startUploadDeviceAudioPcm success");
        }
        Log.i(API_TAG, "startUploadDeviceAudioPcm end");
        return i_startUploadDeviceAudioPcm;
    }

    public synchronized int startUploadDeviceAudioPcmInternal(int i2) {
        return startUploadDeviceAudioPcm();
    }

    public synchronized int stopPlayExternalUltrasoundWavFile() {
        Log.i(API_TAG, "stopPlayExternalUltrasoundWavFile");
        return _stopPlayExternalUltrasoundWavFile();
    }

    public synchronized int stopUploadDeviceAudioPcm() {
        if (!this.mStartUploadDevicePcm) {
            Log.i(API_TAG, "stopUploadDeviceAudioPcm has stopped, return directly");
            return 0;
        }
        Log.i(API_TAG, "stopUploadDeviceAudioPcm start");
        int i_stopUploadDeviceAudioPcm = _stopUploadDeviceAudioPcm();
        if (i_stopUploadDeviceAudioPcm == 0) {
            Log.i(API_TAG, "stopUploadDeviceAudioPcm success");
        }
        this.mStartUploadDevicePcm = false;
        Log.i(API_TAG, "startUploadDeviceAudioPcm end");
        return i_stopUploadDeviceAudioPcm;
    }

    public synchronized int uninit() {
        Log.i(API_TAG, "uninitialize(tname:" + Thread.currentThread().getName() + ",tid:" + Thread.currentThread().getId() + ")");
        if (!this.mHasInit) {
            Log.w(API_TAG, "[Warn]TeaApi has uninitialized, return directly");
            return 0;
        }
        _unregisterTeaDeviceEventCb();
        _unregisterThirdPartyDeviceEventCb();
        _unregisterUserStateChangeEventCb();
        _unregisterDeviceConnectStateChangeEventCb();
        _unregisterDevicePortAttachStateChangeEventCb();
        for (UsbHidDevice usbHidDevice : UsbHidDevice.getHidDeviceList()) {
            if (usbHidDevice != null) {
                usbHidDevice.close();
            }
        }
        return closeNativeHidDevice();
    }

    public synchronized void unregisterDeviceConnectStateUpdataCb() {
        Log.i(API_TAG, "unregisterDeviceConnectStateUpdataCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideDeviceConnectStateUpdateCb = null;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized void unregisterDevicePortAttachStateUpdateCb() {
        Log.i(API_TAG, "unregisterDevicePortAttachStateUpdateCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideDevicePortAttachStateUpdateCb = null;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized void unregisterTeaDevEventCb() {
        Log.i(API_TAG, "unregisterTeaDevEventCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideTeaDevEventCb = null;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized void unregisterThirdPartyDevEventCb() {
        Log.i(API_TAG, "unregisterThirdPartyDevEventCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideThirdPartyDevEventCb = null;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized void unregisterUserStateUpdataCb() {
        Log.i(API_TAG, "unregisterUserStateUpdataCb");
        this.mTeaInsideEventCbLock.lock();
        this.mTeaInsideUserStateUpdateCb = null;
        this.mTeaInsideEventCbLock.unlock();
    }

    public synchronized int usbDeviceSelect(String str) {
        Log.i(API_TAG, "usbDeviceSelect " + str);
        for (UsbHidDevice usbHidDevice : UsbHidDevice.getHidDeviceList()) {
            if (usbHidDevice.getDeviceName().equals(str)) {
                this.mUsbDevice = usbHidDevice;
            }
        }
        return _selectNativeHidDevice(str);
    }

    public byte[] usbManagerRead(int i2) {
        UsbHidDevice usbHidDevice = this.mUsbDevice;
        return usbHidDevice == null ? new byte[0] : usbHidDevice.read(i2);
    }

    public void usbManagerWrite(byte[] bArr) {
        UsbHidDevice usbHidDevice = this.mUsbDevice;
        if (usbHidDevice != null) {
            usbHidDevice.write(bArr);
        }
    }
}
