mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 09:32:27 -06:00
63 lines
2.1 KiB
Java
63 lines
2.1 KiB
Java
|
package androidx.media3.exoplayer;
|
||
|
|
||
|
import android.content.BroadcastReceiver;
|
||
|
import android.content.Context;
|
||
|
import android.content.Intent;
|
||
|
import android.content.IntentFilter;
|
||
|
import android.os.Handler;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
final class AudioBecomingNoisyManager {
|
||
|
private final Context context;
|
||
|
private final AudioBecomingNoisyReceiver receiver;
|
||
|
private boolean receiverRegistered;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public interface EventListener {
|
||
|
void onAudioBecomingNoisy();
|
||
|
}
|
||
|
|
||
|
public AudioBecomingNoisyManager(Context context, Handler handler, EventListener eventListener) {
|
||
|
this.context = context.getApplicationContext();
|
||
|
this.receiver = new AudioBecomingNoisyReceiver(handler, eventListener);
|
||
|
}
|
||
|
|
||
|
public void setEnabled(boolean z) {
|
||
|
if (z && !this.receiverRegistered) {
|
||
|
this.context.registerReceiver(this.receiver, new IntentFilter("android.media.AUDIO_BECOMING_NOISY"));
|
||
|
this.receiverRegistered = true;
|
||
|
} else {
|
||
|
if (z || !this.receiverRegistered) {
|
||
|
return;
|
||
|
}
|
||
|
this.context.unregisterReceiver(this.receiver);
|
||
|
this.receiverRegistered = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
private final class AudioBecomingNoisyReceiver extends BroadcastReceiver implements Runnable {
|
||
|
private final Handler eventHandler;
|
||
|
private final EventListener listener;
|
||
|
|
||
|
public AudioBecomingNoisyReceiver(Handler handler, EventListener eventListener) {
|
||
|
this.eventHandler = handler;
|
||
|
this.listener = eventListener;
|
||
|
}
|
||
|
|
||
|
@Override // android.content.BroadcastReceiver
|
||
|
public void onReceive(Context context, Intent intent) {
|
||
|
if ("android.media.AUDIO_BECOMING_NOISY".equals(intent.getAction())) {
|
||
|
this.eventHandler.post(this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public void run() {
|
||
|
if (AudioBecomingNoisyManager.this.receiverRegistered) {
|
||
|
this.listener.onAudioBecomingNoisy();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|