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;
|
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;
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|||||||
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;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (enabled && stayAwake) {
|
if (enabled && stayAwake) {
|
||||||
if (!wifiLock.isHeld()) {
|
wifiLock.acquire();
|
||||||
wifiLock.acquire();
|
} else {
|
||||||
}
|
|
||||||
} else if (wifiLock.isHeld()) {
|
|
||||||
wifiLock.release();
|
wifiLock.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user