package com.bytedance.bae.router;

import X.0HH;
import com.bytedance.bae.base.BaeLogging;
import com.bytedance.bae.router.device.AudioRouteDeviceManager;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;

public class AudioRouteController implements IAudioRouterCallback {
    public AudioRouteDeviceManager mAudioRouteDeviceManager = new AudioRouteDeviceManager(this);
    public long mNativeAudioRouteControllerPtr;

    static {
        Covode.recordClassIndex(24224);
    }

    private native void onBluetoothHeadsetOffline(long j);

    private native void onBluetoothHeadsetOnline(long j);

    private native void onBluetoothScoConnected(long j);

    private native void onBluetoothScoDisconnected(long j);

    private native void onUsbHeadsetOffline(long j);

    private native void onUsbHeadsetOnline(long j);

    private native void onWiredHeadsetOffline(long j);

    private native void onWiredHeadsetOnline(long j);

    private String getCaptureDeviceName() {
        return this.mAudioRouteDeviceManager.getCaptureDeviceName();
    }

    private String getRenderDeviceName() {
        return this.mAudioRouteDeviceManager.getRenderDeviceName();
    }

    private String getSessionInfo() {
        return this.mAudioRouteDeviceManager.getSessionInfo();
    }

    public void onBluetoothHeadsetOffline() {
        MethodCollector.i(14933);
        BaeLogging.d("AudioRouteController", "onBluetoothHeadsetOffline");
        onBluetoothHeadsetOffline(this.mNativeAudioRouteControllerPtr);
        MethodCollector.o(14933);
    }

    public void onBluetoothHeadsetOnline() {
        MethodCollector.i(14720);
        BaeLogging.d("AudioRouteController", "onBluetoothHeadsetOnline");
        onBluetoothHeadsetOnline(this.mNativeAudioRouteControllerPtr);
        MethodCollector.o(14720);
    }

    public void onBluetoothScoConnected() {
        MethodCollector.i(15143);
        BaeLogging.d("AudioRouteController", "onBluetoothScoConnected");
        onBluetoothScoConnected(this.mNativeAudioRouteControllerPtr);
        MethodCollector.o(15143);
    }

    public void onBluetoothScoDisconnected() {
        MethodCollector.i(15144);
        BaeLogging.d("AudioRouteController", "onBluetoothScoDisconnected");
        onBluetoothScoDisconnected(this.mNativeAudioRouteControllerPtr);
        MethodCollector.o(15144);
    }

    public void onUsbHeadsetOffline() {
        MethodCollector.i(14298);
        BaeLogging.d("AudioRouteController", "onUsbHeadsetOffline");
        onUsbHeadsetOffline(this.mNativeAudioRouteControllerPtr);
        MethodCollector.o(14298);
    }

    public void onUsbHeadsetOnline() {
        MethodCollector.i(14079);
        BaeLogging.d("AudioRouteController", "onUsbHeadsetOnline");
        onUsbHeadsetOnline(this.mNativeAudioRouteControllerPtr);
        MethodCollector.o(14079);
    }

    public void onWiredHeadsetOffline() {
        MethodCollector.i(13862);
        BaeLogging.d("AudioRouteController", "onWiredHeadsetOffline");
        onWiredHeadsetOffline(this.mNativeAudioRouteControllerPtr);
        MethodCollector.o(13862);
    }

    public void onWiredHeadsetOnline() {
        MethodCollector.i(13860);
        BaeLogging.d("AudioRouteController", "onWiredHeadsetOnline");
        onWiredHeadsetOnline(this.mNativeAudioRouteControllerPtr);
        MethodCollector.o(13860);
    }

    private int release() {
        if (this.mNativeAudioRouteControllerPtr != 0) {
            BaeLogging.d("AudioRouteController", "release(Java)");
            int release = this.mAudioRouteDeviceManager.release();
            this.mAudioRouteDeviceManager = null;
            this.mNativeAudioRouteControllerPtr = 0;
            BaeLogging.d("AudioRouteController", "release(Java) finished");
            return release;
        }
        BaeLogging.d("AudioRouteController", "already released.");
        return 0;
    }

    public AudioRouteController(long j) {
        this.mNativeAudioRouteControllerPtr = j;
    }

    private int setAudioRouting(int i, boolean z) {
        return this.mAudioRouteDeviceManager.setAudioRouting(i, z);
    }

    public void onError(int i, String str) {
        if (str != null) {
            BaeLogging.e("AudioRouteController", 0HH.LIZ("code: %d, msg: %s", new Object[]{Integer.valueOf(i), str}));
            return;
        }
        BaeLogging.e("AudioRouteController", 0HH.LIZ("code: %d", new Object[]{Integer.valueOf(i)}));
    }
}
