mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 09:32:27 -06:00
53 lines
1.6 KiB
Java
53 lines
1.6 KiB
Java
|
package androidx.media3.exoplayer;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.net.wifi.WifiManager;
|
||
|
import androidx.media3.common.util.Log;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
final class WifiLockManager {
|
||
|
private static final String TAG = "WifiLockManager";
|
||
|
private static final String WIFI_LOCK_TAG = "ExoPlayer:WifiLockManager";
|
||
|
private boolean enabled;
|
||
|
private boolean stayAwake;
|
||
|
private WifiManager.WifiLock wifiLock;
|
||
|
private final WifiManager wifiManager;
|
||
|
|
||
|
public WifiLockManager(Context context) {
|
||
|
this.wifiManager = (WifiManager) context.getApplicationContext().getSystemService("wifi");
|
||
|
}
|
||
|
|
||
|
public void setEnabled(boolean z) {
|
||
|
if (z && this.wifiLock == null) {
|
||
|
WifiManager wifiManager = this.wifiManager;
|
||
|
if (wifiManager == null) {
|
||
|
Log.w(TAG, "WifiManager is null, therefore not creating the WifiLock.");
|
||
|
return;
|
||
|
} else {
|
||
|
WifiManager.WifiLock createWifiLock = wifiManager.createWifiLock(3, WIFI_LOCK_TAG);
|
||
|
this.wifiLock = createWifiLock;
|
||
|
createWifiLock.setReferenceCounted(false);
|
||
|
}
|
||
|
}
|
||
|
this.enabled = z;
|
||
|
updateWifiLock();
|
||
|
}
|
||
|
|
||
|
public void setStayAwake(boolean z) {
|
||
|
this.stayAwake = z;
|
||
|
updateWifiLock();
|
||
|
}
|
||
|
|
||
|
private void updateWifiLock() {
|
||
|
WifiManager.WifiLock wifiLock = this.wifiLock;
|
||
|
if (wifiLock == null) {
|
||
|
return;
|
||
|
}
|
||
|
if (this.enabled && this.stayAwake) {
|
||
|
wifiLock.acquire();
|
||
|
} else {
|
||
|
wifiLock.release();
|
||
|
}
|
||
|
}
|
||
|
}
|