Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac6d8962 authored by destradaa's avatar destradaa
Browse files

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
parent b225d05c
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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();