package org.webrtc.audio; import android.content.Context; import android.media.AudioDeviceInfo; import android.media.AudioManager; import android.os.Build; import java.util.Arrays; import org.webrtc.Logging; /* loaded from: classes3.dex */ final class WebRtcAudioUtils { private static final String TAG = "WebRtcAudioUtilsExternal"; public static String audioSourceToString(int i) { switch (i) { case 0: return "DEFAULT"; case 1: return "MIC"; case 2: return "VOICE_UPLINK"; case 3: return "VOICE_DOWNLINK"; case 4: return "VOICE_CALL"; case 5: return "CAMCORDER"; case 6: return "VOICE_RECOGNITION"; case 7: return "VOICE_COMMUNICATION"; case 8: default: return "INVALID"; case 9: return "UNPROCESSED"; case 10: return "VOICE_PERFORMANCE"; } } public static String channelMaskToString(int i) { return i != 12 ? i != 16 ? "INVALID" : "IN_MONO" : "IN_STEREO"; } /* JADX INFO: Access modifiers changed from: package-private */ public static String deviceTypeToString(int i) { switch (i) { case 1: return "TYPE_BUILTIN_EARPIECE"; case 2: return "TYPE_BUILTIN_SPEAKER"; case 3: return "TYPE_WIRED_HEADSET"; case 4: return "TYPE_WIRED_HEADPHONES"; case 5: return "TYPE_LINE_ANALOG"; case 6: return "TYPE_LINE_DIGITAL"; case 7: return "TYPE_BLUETOOTH_SCO"; case 8: return "TYPE_BLUETOOTH_A2DP"; case 9: return "TYPE_HDMI"; case 10: return "TYPE_HDMI_ARC"; case 11: return "TYPE_USB_DEVICE"; case 12: return "TYPE_USB_ACCESSORY"; case 13: return "TYPE_DOCK"; case 14: return "TYPE_FM"; case 15: return "TYPE_BUILTIN_MIC"; case 16: return "TYPE_FM_TUNER"; case 17: return "TYPE_TV_TUNER"; case 18: return "TYPE_TELEPHONY"; case 19: return "TYPE_AUX_LINE"; case 20: return "TYPE_IP"; case 21: return "TYPE_BUS"; case 22: return "TYPE_USB_HEADSET"; default: return "TYPE_UNKNOWN"; } } /* JADX INFO: Access modifiers changed from: package-private */ public static String modeToString(int i) { return i != 0 ? i != 1 ? i != 2 ? i != 3 ? "MODE_INVALID" : "MODE_IN_COMMUNICATION" : "MODE_IN_CALL" : "MODE_RINGTONE" : "MODE_NORMAL"; } private static String streamTypeToString(int i) { return i != 0 ? i != 1 ? i != 2 ? i != 3 ? i != 4 ? i != 5 ? "STREAM_INVALID" : "STREAM_NOTIFICATION" : "STREAM_ALARM" : "STREAM_MUSIC" : "STREAM_RING" : "STREAM_SYSTEM" : "STREAM_VOICE_CALL"; } WebRtcAudioUtils() { } public static String getThreadInfo() { return "@[name=" + Thread.currentThread().getName() + ", id=" + Thread.currentThread().getId() + "]"; } public static boolean runningOnEmulator() { return Build.HARDWARE.equals("goldfish") && Build.BRAND.startsWith("generic_"); } static void logDeviceInfo(String str) { Logging.d(str, "Android SDK: " + Build.VERSION.SDK_INT + ", Release: " + Build.VERSION.RELEASE + ", Brand: " + Build.BRAND + ", Device: " + Build.DEVICE + ", Id: " + Build.ID + ", Hardware: " + Build.HARDWARE + ", Manufacturer: " + Build.MANUFACTURER + ", Model: " + Build.MODEL + ", Product: " + Build.PRODUCT); } /* JADX INFO: Access modifiers changed from: package-private */ public static void logAudioState(String str, Context context, AudioManager audioManager) { logDeviceInfo(str); logAudioStateBasic(str, context, audioManager); logAudioStateVolume(str, audioManager); logAudioDeviceInfo(str, audioManager); } public static String audioEncodingToString(int i) { if (i == 0) { return "INVALID"; } switch (i) { case 2: return "PCM_16BIT"; case 3: return "PCM_8BIT"; case 4: return "PCM_FLOAT"; case 5: case 6: return "AC3"; case 7: return "DTS"; case 8: return "DTS_HD"; case 9: return "MP3"; default: return "Invalid encoding: " + i; } } private static void logAudioStateBasic(String str, Context context, AudioManager audioManager) { Logging.d(str, "Audio State: audio mode: " + modeToString(audioManager.getMode()) + ", has mic: " + hasMicrophone(context) + ", mic muted: " + audioManager.isMicrophoneMute() + ", music active: " + audioManager.isMusicActive() + ", speakerphone: " + audioManager.isSpeakerphoneOn() + ", BT SCO: " + audioManager.isBluetoothScoOn()); } private static boolean isVolumeFixed(AudioManager audioManager) { return audioManager.isVolumeFixed(); } private static void logAudioStateVolume(String str, AudioManager audioManager) { int[] iArr = {0, 3, 2, 4, 5, 1}; Logging.d(str, "Audio State: "); boolean isVolumeFixed = isVolumeFixed(audioManager); Logging.d(str, " fixed volume=" + isVolumeFixed); if (isVolumeFixed) { return; } for (int i = 0; i < 6; i++) { int i2 = iArr[i]; StringBuilder sb = new StringBuilder(); sb.append(" " + streamTypeToString(i2) + ": "); sb.append("volume=").append(audioManager.getStreamVolume(i2)); sb.append(", max=").append(audioManager.getStreamMaxVolume(i2)); logIsStreamMute(str, audioManager, i2, sb); Logging.d(str, sb.toString()); } } private static void logIsStreamMute(String str, AudioManager audioManager, int i, StringBuilder sb) { sb.append(", muted=").append(audioManager.isStreamMute(i)); } private static void logAudioDeviceInfo(String str, AudioManager audioManager) { AudioDeviceInfo[] devices = audioManager.getDevices(3); if (devices.length == 0) { return; } Logging.d(str, "Audio Devices: "); for (AudioDeviceInfo audioDeviceInfo : devices) { StringBuilder sb = new StringBuilder(" "); sb.append(deviceTypeToString(audioDeviceInfo.getType())); sb.append(audioDeviceInfo.isSource() ? "(in): " : "(out): "); if (audioDeviceInfo.getChannelCounts().length > 0) { sb.append("channels=").append(Arrays.toString(audioDeviceInfo.getChannelCounts())); sb.append(", "); } if (audioDeviceInfo.getEncodings().length > 0) { sb.append("encodings=").append(Arrays.toString(audioDeviceInfo.getEncodings())); sb.append(", "); } if (audioDeviceInfo.getSampleRates().length > 0) { sb.append("sample rates=").append(Arrays.toString(audioDeviceInfo.getSampleRates())); sb.append(", "); } sb.append("id=").append(audioDeviceInfo.getId()); Logging.d(str, sb.toString()); } } private static boolean hasMicrophone(Context context) { return context.getPackageManager().hasSystemFeature("android.hardware.microphone"); } }