Commit c976d16a by samrobinson Committed by Oliver Woodman

Simplify `WakeLockManager` and `WifiLockManager` logic.

Disabling reference counting allows some checks to be removed.

This is a no-op.

PiperOrigin-RevId: 299829600
parent 1c03226f
...@@ -61,6 +61,7 @@ import com.google.android.exoplayer2.util.Log; ...@@ -61,6 +61,7 @@ import com.google.android.exoplayer2.util.Log;
return; return;
} }
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKE_LOCK_TAG); wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKE_LOCK_TAG);
wakeLock.setReferenceCounted(false);
} }
} }
...@@ -92,10 +93,8 @@ import com.google.android.exoplayer2.util.Log; ...@@ -92,10 +93,8 @@ import com.google.android.exoplayer2.util.Log;
} }
if (enabled && stayAwake) { if (enabled && stayAwake) {
if (!wakeLock.isHeld()) { wakeLock.acquire();
wakeLock.acquire(); } else {
}
} else if (wakeLock.isHeld()) {
wakeLock.release(); wakeLock.release();
} }
} }
......
...@@ -59,6 +59,7 @@ import com.google.android.exoplayer2.util.Log; ...@@ -59,6 +59,7 @@ import com.google.android.exoplayer2.util.Log;
return; return;
} }
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, WIFI_LOCK_TAG); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, WIFI_LOCK_TAG);
wifiLock.setReferenceCounted(false);
} }
this.enabled = enabled; this.enabled = enabled;
...@@ -85,10 +86,8 @@ import com.google.android.exoplayer2.util.Log; ...@@ -85,10 +86,8 @@ import com.google.android.exoplayer2.util.Log;
} }
if (enabled && stayAwake) { if (enabled && stayAwake) {
if (!wifiLock.isHeld()) { wifiLock.acquire();
wifiLock.acquire(); } else {
}
} else if (wifiLock.isHeld()) {
wifiLock.release(); wifiLock.release();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment