Simplify WakeLockManager
and WifiLockManager
logic.
Disabling reference counting allows some checks to be removed. This is a no-op. PiperOrigin-RevId: 299829600
This commit is contained in:
parent
1c03226fb3
commit
c976d16a74
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user