DO NOT MERGE ANYWHERE: Add a wakelock timeout when downloading xtra data for GNSS.
Test: manual
Bug:36973866
Change-Id: Ia7168f313abebbf3c5c4fc26567ed914f1987a91
(cherry picked from commit c5706f651a0462e9ae5a91c9a026d44710b1f8ea)
diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java
index ae98077..ee46020 100644
--- a/services/core/java/com/android/server/location/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/GnssLocationProvider.java
@@ -294,6 +294,9 @@
// current setting - 4 hours
private static final long MAX_RETRY_INTERVAL = 4*60*60*1000;
+ // Timeout when holding wakelocks for downloading XTRA data.
+ private static final long DOWNLOAD_XTRA_DATA_TIMEOUT_MS = 60 * 1000;
+
private BackOff mNtpBackOff = new BackOff(RETRY_INTERVAL, MAX_RETRY_INTERVAL);
private BackOff mXtraBackOff = new BackOff(RETRY_INTERVAL, MAX_RETRY_INTERVAL);
@@ -1023,7 +1026,7 @@
mDownloadXtraDataPending = STATE_DOWNLOADING;
// hold wake lock while task runs
- mWakeLock.acquire();
+ mWakeLock.acquire(DOWNLOAD_XTRA_DATA_TIMEOUT_MS);
Log.i(TAG, "WakeLock acquired by handleDownloadXtraData()");
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
@Override
@@ -1046,7 +1049,11 @@
}
// release wake lock held by task
- mWakeLock.release();
+ if (mWakeLock.isHeld()) {
+ mWakeLock.release();
+ } else {
+ Log.e(TAG, "WakeLock expired before release in handleDownloadXtraData()");
+ }
Log.i(TAG, "WakeLock released by handleDownloadXtraData()");
}
});