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;
return;
}
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKE_LOCK_TAG);
wakeLock.setReferenceCounted(false);
}
}
......@@ -92,10 +93,8 @@ import com.google.android.exoplayer2.util.Log;
}
if (enabled && stayAwake) {
if (!wakeLock.isHeld()) {
wakeLock.acquire();
}
} else if (wakeLock.isHeld()) {
wakeLock.acquire();
} else {
wakeLock.release();
}
}
......
......@@ -59,6 +59,7 @@ import com.google.android.exoplayer2.util.Log;
return;
}
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, WIFI_LOCK_TAG);
wifiLock.setReferenceCounted(false);
}
this.enabled = enabled;
......@@ -85,10 +86,8 @@ import com.google.android.exoplayer2.util.Log;
}
if (enabled && stayAwake) {
if (!wifiLock.isHeld()) {
wifiLock.acquire();
}
} else if (wifiLock.isHeld()) {
wifiLock.acquire();
} else {
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