diff options
| author | 2015-07-31 18:01:55 -0700 | |
|---|---|---|
| committer | 2015-07-31 18:05:50 -0700 | |
| commit | ac6d896222051ceeb68dcdd4283f3aee18ec1046 (patch) | |
| tree | c59754983b07e1bf83d4bb651531dae3366aab9a | |
| parent | b225d05ce4e4ba3d3b67482c1673ef6afdc83724 (diff) | |
Add timeout for XTRA data connection.
b/22540683
The timeout in the XTRA data connection prevents it from keeping a
wake-lock held indefinitely if the connection is dropped.
Change-Id: Id14c780ddbcb42f764ae0565765e222013f56ab3
| -rw-r--r-- | services/core/java/com/android/server/location/GpsXtraDownloader.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/location/GpsXtraDownloader.java b/services/core/java/com/android/server/location/GpsXtraDownloader.java index 3585049fab23..c464371bf16a 100644 --- a/services/core/java/com/android/server/location/GpsXtraDownloader.java +++ b/services/core/java/com/android/server/location/GpsXtraDownloader.java @@ -19,13 +19,14 @@ package com.android.server.location; import android.text.TextUtils; import android.util.Log; +import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; -import libcore.io.Streams; - -import java.io.IOException; import java.util.Properties; import java.util.Random; +import java.util.concurrent.TimeUnit; + +import libcore.io.Streams; /** * A class for downloading GPS XTRA data. @@ -37,6 +38,7 @@ public class GpsXtraDownloader { private static final String TAG = "GpsXtraDownloader"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final String DEFAULT_USER_AGENT = "Android"; + private static final int CONNECTION_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(30); private final String[] mXtraServers; // to load balance our server requests @@ -113,6 +115,7 @@ public class GpsXtraDownloader { connection.setRequestProperty( "x-wap-profile", "http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20021212#"); + connection.setConnectTimeout(CONNECTION_TIMEOUT_MS); connection.connect(); int statusCode = connection.getResponseCode(); |