Don't hold wakelocks for passive requests
Prevents power usage for passive requests and reduces wakelock thrashing. Bug: 206340085 Test: presubmits Change-Id: I258ba16ace2a2a3fa248665bc936e6b855471762
This commit is contained in:
@@ -911,18 +911,21 @@ public class LocationProviderManager extends
|
|||||||
@Override
|
@Override
|
||||||
public void onPreExecute() {
|
public void onPreExecute() {
|
||||||
mUseWakeLock = false;
|
mUseWakeLock = false;
|
||||||
final int size = locationResult.size();
|
|
||||||
for (int i = 0; i < size; ++i) {
|
// don't acquire a wakelock for passive requests or for mock locations
|
||||||
if (!locationResult.get(i).isMock()) {
|
if (getRequest().getIntervalMillis() != LocationRequest.PASSIVE_INTERVAL) {
|
||||||
mUseWakeLock = true;
|
final int size = locationResult.size();
|
||||||
break;
|
for (int i = 0; i < size; ++i) {
|
||||||
|
if (!locationResult.get(i).isMock()) {
|
||||||
|
mUseWakeLock = true;
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user