Rabbit-R1/android (non root)/java/sources/org/webrtc/audio/VolumeLogger.java
2024-05-21 17:08:36 -04:00

60 lines
2.1 KiB
Java

package org.webrtc.audio;
import android.media.AudioManager;
import java.util.Timer;
import java.util.TimerTask;
import org.webrtc.Logging;
/* loaded from: classes3.dex */
class VolumeLogger {
private static final String TAG = "VolumeLogger";
private static final String THREAD_NAME = "WebRtcVolumeLevelLoggerThread";
private static final int TIMER_PERIOD_IN_SECONDS = 30;
private final AudioManager audioManager;
private Timer timer;
public VolumeLogger(AudioManager audioManager) {
this.audioManager = audioManager;
}
public void start() {
Logging.d(TAG, "start" + WebRtcAudioUtils.getThreadInfo());
if (this.timer != null) {
return;
}
Logging.d(TAG, "audio mode is: " + WebRtcAudioUtils.modeToString(this.audioManager.getMode()));
Timer timer = new Timer(THREAD_NAME);
this.timer = timer;
timer.schedule(new LogVolumeTask(this.audioManager.getStreamMaxVolume(2), this.audioManager.getStreamMaxVolume(0)), 0L, 30000L);
}
/* loaded from: classes3.dex */
private class LogVolumeTask extends TimerTask {
private final int maxRingVolume;
private final int maxVoiceCallVolume;
LogVolumeTask(int i, int i2) {
this.maxRingVolume = i;
this.maxVoiceCallVolume = i2;
}
@Override // java.util.TimerTask, java.lang.Runnable
public void run() {
int mode = VolumeLogger.this.audioManager.getMode();
if (mode == 1) {
Logging.d(VolumeLogger.TAG, "STREAM_RING stream volume: " + VolumeLogger.this.audioManager.getStreamVolume(2) + " (max=" + this.maxRingVolume + ")");
} else if (mode == 3) {
Logging.d(VolumeLogger.TAG, "VOICE_CALL stream volume: " + VolumeLogger.this.audioManager.getStreamVolume(0) + " (max=" + this.maxVoiceCallVolume + ")");
}
}
}
public void stop() {
Logging.d(TAG, "stop" + WebRtcAudioUtils.getThreadInfo());
Timer timer = this.timer;
if (timer != null) {
timer.cancel();
this.timer = null;
}
}
}