Don't hold wakelocks for passive requests am: eca0b750e7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16265552

Change-Id: I22d3be1d9ac48f0c32d28dc5247833b961a0481c
This commit is contained in:
Soonil Nagarkar
2021-11-16 00:37:52 +00:00
committed by Automerger Merge Worker

View File

@@ -911,6 +911,9 @@ public class LocationProviderManager extends
@Override @Override
public void onPreExecute() { public void onPreExecute() {
mUseWakeLock = false; mUseWakeLock = false;
// don't acquire a wakelock for passive requests or for mock locations
if (getRequest().getIntervalMillis() != LocationRequest.PASSIVE_INTERVAL) {
final int size = locationResult.size(); final int size = locationResult.size();
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
if (!locationResult.get(i).isMock()) { if (!locationResult.get(i).isMock()) {
@@ -918,11 +921,11 @@ public class LocationProviderManager extends
break; break;
} }
} }
}
// update last delivered location // update last delivered location
setLastDeliveredLocation(locationResult.getLastLocation()); setLastDeliveredLocation(locationResult.getLastLocation());
// don't acquire a wakelock for mock locations to prevent abuse
if (mUseWakeLock) { if (mUseWakeLock) {
mWakeLock.acquire(WAKELOCK_TIMEOUT_MS); mWakeLock.acquire(WAKELOCK_TIMEOUT_MS);
} }