Merge pull request #1487 from colinkho:main

PiperOrigin-RevId: 646917527
(cherry picked from commit 6244d8605f48d1b548201a8a964a9879961b3c68)
This commit is contained in:
Copybara-Service 2024-06-26 06:05:07 -07:00 committed by Tianyi Feng
parent 0b87e176fd
commit 708dc6cab9
2 changed files with 9 additions and 6 deletions

View File

@ -33,14 +33,13 @@ import androidx.media3.common.util.Log;
private static final String TAG = "WakeLockManager";
private static final String WAKE_LOCK_TAG = "ExoPlayer:WakeLockManager";
@Nullable private final PowerManager powerManager;
private final Context applicationContext;
@Nullable private WakeLock wakeLock;
private boolean enabled;
private boolean stayAwake;
public WakeLockManager(Context context) {
powerManager =
(PowerManager) context.getApplicationContext().getSystemService(Context.POWER_SERVICE);
applicationContext = context.getApplicationContext();
}
/**
@ -56,6 +55,8 @@ import androidx.media3.common.util.Log;
public void setEnabled(boolean enabled) {
if (enabled) {
if (wakeLock == null) {
PowerManager powerManager =
(PowerManager) applicationContext.getSystemService(Context.POWER_SERVICE);
if (powerManager == null) {
Log.w(TAG, "PowerManager is null, therefore not creating the WakeLock.");
return;

View File

@ -32,14 +32,13 @@ import androidx.media3.common.util.Log;
private static final String TAG = "WifiLockManager";
private static final String WIFI_LOCK_TAG = "ExoPlayer:WifiLockManager";
@Nullable private final WifiManager wifiManager;
private final Context applicationContext;
@Nullable private WifiLock wifiLock;
private boolean enabled;
private boolean stayAwake;
public WifiLockManager(Context context) {
wifiManager =
(WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
applicationContext = context.getApplicationContext();
}
/**
@ -54,6 +53,9 @@ import androidx.media3.common.util.Log;
*/
public void setEnabled(boolean enabled) {
if (enabled && wifiLock == null) {
WifiManager wifiManager =
(WifiManager)
applicationContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null) {
Log.w(TAG, "WifiManager is null, therefore not creating the WifiLock.");
return;