Java Code Examples for com.google.android.vending.expansion.downloader.Constants#LOGV
The following examples show how to use
com.google.android.vending.expansion.downloader.Constants#LOGV .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloaderService.java From UnityOBBDownloader with Apache License 2.0 | 6 votes |
private void scheduleAlarm(long wakeUp) { AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE); if (alarms == null) { Log.e(Constants.TAG, "couldn't get alarm manager"); return; } if (Constants.LOGV) { Log.v(Constants.TAG, "scheduling retry in " + wakeUp + "ms"); } String className = getAlarmReceiverClassName(); Intent intent = new Intent(Constants.ACTION_RETRY); intent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent); intent.setClassName(this.getPackageName(), className); mAlarmIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); alarms.set( AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + wakeUp, mAlarmIntent ); }
Example 2
Source File: DownloaderService.java From Alite with GNU General Public License v3.0 | 6 votes |
private void scheduleAlarm(long wakeUp) { AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE); if (alarms == null) { Log.e(Constants.TAG, "couldn't get alarm manager"); return; } if (Constants.LOGV) { Log.v(Constants.TAG, "scheduling retry in " + wakeUp + "ms"); } String className = getAlarmReceiverClassName(); Intent intent = new Intent(Constants.ACTION_RETRY); intent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent); intent.setClassName(this.getPackageName(), className); mAlarmIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); alarms.set( AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + wakeUp, mAlarmIntent ); }
Example 3
Source File: DownloaderService.java From play-apk-expansion with Apache License 2.0 | 6 votes |
private void scheduleAlarm(long wakeUp) { AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE); if (alarms == null) { Log.e(Constants.TAG, "couldn't get alarm manager"); return; } if (Constants.LOGV) { Log.v(Constants.TAG, "scheduling retry in " + wakeUp + "ms"); } String className = getAlarmReceiverClassName(); Intent intent = new Intent(Constants.ACTION_RETRY); intent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent); intent.setClassName(this.getPackageName(), className); mAlarmIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); alarms.set( AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + wakeUp, mAlarmIntent ); }
Example 4
Source File: DownloaderService.java From travelguide with Apache License 2.0 | 6 votes |
private void scheduleAlarm(long wakeUp) { AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE); if (alarms == null) { Log.e(Constants.TAG, "couldn't get alarm manager"); return; } if (Constants.LOGV) { Log.v(Constants.TAG, "scheduling retry in " + wakeUp + "ms"); } String className = getAlarmReceiverClassName(); Intent intent = new Intent(Constants.ACTION_RETRY); intent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent); intent.setClassName(this.getPackageName(), className); mAlarmIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); alarms.set( AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + wakeUp, mAlarmIntent ); }
Example 5
Source File: DownloadThread.java From travelguide with Apache License 2.0 | 5 votes |
/** * Handle a 3xx redirect status. */ private void handleRedirect(State state, HttpResponse response, int statusCode) throws StopRequest, RetryDownload { if (Constants.LOGVV) { Log.v(Constants.TAG, "got HTTP redirect " + statusCode); } if (state.mRedirectCount >= Constants.MAX_REDIRECTS) { throw new StopRequest(DownloaderService.STATUS_TOO_MANY_REDIRECTS, "too many redirects"); } Header header = response.getFirstHeader("Location"); if (header == null) { return; } if (Constants.LOGVV) { Log.v(Constants.TAG, "Location :" + header.getValue()); } String newUri; try { newUri = new URI(mInfo.mUri).resolve(new URI(header.getValue())).toString(); } catch (URISyntaxException ex) { if (Constants.LOGV) { Log.d(Constants.TAG, "Couldn't resolve redirect URI " + header.getValue() + " for " + mInfo.mUri); } throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR, "Couldn't resolve redirect URI"); } ++state.mRedirectCount; state.mRequestUri = newUri; if (statusCode == 301 || statusCode == 303) { // use the new URI for all future requests (should a retry/resume be // necessary) state.mNewUri = newUri; } throw new RetryDownload(); }
Example 6
Source File: DownloadThread.java From UnityOBBDownloader with Apache License 2.0 | 5 votes |
/** * Close the destination output stream. */ private void closeDestination(State state) { try { // close the file if (state.mStream != null) { state.mStream.close(); state.mStream = null; } } catch (IOException ex) { if (Constants.LOGV) { Log.v(Constants.TAG, "exception when closing the file after download : " + ex); } // nothing can really be done if the file can't be closed } }
Example 7
Source File: DownloadThread.java From UnityOBBDownloader with Apache License 2.0 | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, HttpURLConnection request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); int responseCode = sendRequest(state, request); handleExceptionalStatus(state, innerState, request, responseCode); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, request); InputStream entityStream = openResponseEntity(state, request); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example 8
Source File: DownloadThread.java From Alite with GNU General Public License v3.0 | 5 votes |
/** * Handle a 3xx redirect status. */ private void handleRedirect(State state, HttpResponse response, int statusCode) throws StopRequest, RetryDownload { if (Constants.LOGVV) { Log.v(Constants.TAG, "got HTTP redirect " + statusCode); } if (state.mRedirectCount >= Constants.MAX_REDIRECTS) { throw new StopRequest(DownloaderService.STATUS_TOO_MANY_REDIRECTS, "too many redirects"); } Header header = response.getFirstHeader("Location"); if (header == null) { return; } if (Constants.LOGVV) { Log.v(Constants.TAG, "Location :" + header.getValue()); } String newUri; try { newUri = new URI(mInfo.mUri).resolve(new URI(header.getValue())).toString(); } catch (URISyntaxException ex) { if (Constants.LOGV) { Log.d(Constants.TAG, "Couldn't resolve redirect URI " + header.getValue() + " for " + mInfo.mUri); } throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR, "Couldn't resolve redirect URI"); } ++state.mRedirectCount; state.mRequestUri = newUri; throw new RetryDownload(); }
Example 9
Source File: DownloadThread.java From Alite with GNU General Public License v3.0 | 5 votes |
/** * Close the destination output stream. */ private void closeDestination(State state) { try { // close the file if (state.mStream != null) { state.mStream.close(); state.mStream = null; } } catch (IOException ex) { if (Constants.LOGV) { Log.v(Constants.TAG, "exception when closing the file after download : " + ex); } // nothing can really be done if the file can't be closed } }
Example 10
Source File: DownloadThread.java From Alite with GNU General Public License v3.0 | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, AndroidHttpClient client, HttpGet request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); HttpResponse response = sendRequest(state, client, request); handleExceptionalStatus(state, innerState, response); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, response); InputStream entityStream = openResponseEntity(state, response); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example 11
Source File: DownloadThread.java From travelguide with Apache License 2.0 | 5 votes |
/** * Close the destination output stream. */ private void closeDestination(State state) { try { // close the file if (state.mStream != null) { state.mStream.close(); state.mStream = null; } } catch (IOException ex) { if (Constants.LOGV) { Log.v(Constants.TAG, "exception when closing the file after download : " + ex); } // nothing can really be done if the file can't be closed } }
Example 12
Source File: DownloadThread.java From travelguide with Apache License 2.0 | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, AndroidHttpClient client, HttpGet request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); HttpResponse response = sendRequest(state, client, request); handleExceptionalStatus(state, innerState, response); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, response); InputStream entityStream = openResponseEntity(state, response); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example 13
Source File: DownloadThread.java From play-apk-expansion with Apache License 2.0 | 5 votes |
/** * Close the destination output stream. */ private void closeDestination(State state) { try { // close the file if (state.mStream != null) { state.mStream.close(); state.mStream = null; } } catch (IOException ex) { if (Constants.LOGV) { Log.v(Constants.TAG, "exception when closing the file after download : " + ex); } // nothing can really be done if the file can't be closed } }
Example 14
Source File: DownloadThread.java From play-apk-expansion with Apache License 2.0 | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, HttpURLConnection request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); int responseCode = sendRequest(state, request); handleExceptionalStatus(state, innerState, request, responseCode); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, request); InputStream entityStream = openResponseEntity(state, request); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example 15
Source File: DownloadThread.java From QtAndroidTools with MIT License | 5 votes |
/** * Fully execute a single download request - setup and send the request, * handle the response, and transfer the data to the destination file. */ private void executeDownload(State state, HttpURLConnection request) throws StopRequest, RetryDownload { InnerState innerState = new InnerState(); byte data[] = new byte[Constants.BUFFER_SIZE]; checkPausedOrCanceled(state); setupDestinationFile(state, innerState); addRequestHeaders(innerState, request); // check just before sending the request to avoid using an invalid // connection at all checkConnectivity(state); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING); int responseCode = sendRequest(state, request); handleExceptionalStatus(state, innerState, request, responseCode); if (Constants.LOGV) { Log.v(Constants.TAG, "received response for " + mInfo.mUri); } processResponseHeaders(state, innerState, request); InputStream entityStream = openResponseEntity(state, request); mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING); transferData(state, innerState, data, entityStream); }
Example 16
Source File: DownloadThread.java From QtAndroidTools with MIT License | 4 votes |
/** * Executes the download */ public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); State state = new State(mInfo, mService); PowerManager.WakeLock wakeLock = null; int finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; try { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.TAG); wakeLock.acquire(); if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } boolean finished = false; while (!finished) { if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } // Set or unset proxy, which may have changed since last GET // request. // setDefaultProxy() supports null as proxy parameter. URL url = new URL(state.mRequestUri); HttpURLConnection request = (HttpURLConnection)url.openConnection(); request.setRequestProperty("User-Agent", userAgent()); try { executeDownload(state, request); finished = true; } catch (RetryDownload exc) { // fall through } finally { request.disconnect(); request = null; } } if (Constants.LOGV) { Log.v(Constants.TAG, "download completed for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } finalizeDestinationFile(state); finalStatus = DownloaderService.STATUS_SUCCESS; } catch (StopRequest error) { // remove the cause before printing, in case it contains PII Log.w(Constants.TAG, "Aborting request for download " + mInfo.mFileName + ": " + error.getMessage()); error.printStackTrace(); finalStatus = error.mFinalStatus; // fall through to finally block } catch (Throwable ex) { // sometimes the socket code throws unchecked // exceptions Log.w(Constants.TAG, "Exception for " + mInfo.mFileName + ": " + ex); finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; // falls through to the code that reports an error } finally { if (wakeLock != null) { wakeLock.release(); wakeLock = null; } cleanupDestination(state, finalStatus); notifyDownloadCompleted(finalStatus, state.mCountRetry, state.mRetryAfter, state.mRedirectCount, state.mGotData, state.mFilename); } }
Example 17
Source File: DownloadThread.java From Alite with GNU General Public License v3.0 | 4 votes |
/** * Executes the download in a separate thread */ @SuppressLint("Wakelock") public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); State state = new State(mInfo, mService); AndroidHttpClient client = null; PowerManager.WakeLock wakeLock = null; int finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; try { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.TAG); wakeLock.acquire(); if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } client = AndroidHttpClient.newInstance(userAgent(), mContext); boolean finished = false; while (!finished) { if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } // Set or unset proxy, which may have changed since last GET // request. // setDefaultProxy() supports null as proxy parameter. ConnRouteParams.setDefaultProxy(client.getParams(), getPreferredHttpHost(mContext, state.mRequestUri)); HttpGet request = new HttpGet(state.mRequestUri); try { executeDownload(state, client, request); finished = true; } catch (RetryDownload exc) { // fall through } finally { request.abort(); request = null; } } if (Constants.LOGV) { Log.v(Constants.TAG, "download completed for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } finalizeDestinationFile(state); finalStatus = DownloaderService.STATUS_SUCCESS; } catch (StopRequest error) { // remove the cause before printing, in case it contains PII Log.w(Constants.TAG, "Aborting request for download " + mInfo.mFileName + ": " + error.getMessage()); error.printStackTrace(); finalStatus = error.mFinalStatus; // fall through to finally block } catch (Throwable ex) { // sometimes the socket code throws unchecked // exceptions Log.w(Constants.TAG, "Exception for " + mInfo.mFileName + ": " + ex); finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; // falls through to the code that reports an error } finally { if (wakeLock != null) { wakeLock.release(); wakeLock = null; } if (client != null) { client.close(); client = null; } cleanupDestination(state, finalStatus); notifyDownloadCompleted(finalStatus, state.mCountRetry, state.mRetryAfter, state.mRedirectCount, state.mGotData, state.mFilename); } }
Example 18
Source File: DownloadThread.java From travelguide with Apache License 2.0 | 4 votes |
/** * Executes the download in a separate thread */ public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); State state = new State(mInfo, mService); AndroidHttpClient client = null; PowerManager.WakeLock wakeLock = null; int finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; try { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.TAG); wakeLock.acquire(); if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } client = AndroidHttpClient.newInstance(userAgent(), mContext); boolean finished = false; while (!finished) { if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } // Set or unset proxy, which may have changed since last GET // request. // setDefaultProxy() supports null as proxy parameter. ConnRouteParams.setDefaultProxy(client.getParams(), getPreferredHttpHost(mContext, state.mRequestUri)); HttpGet request = new HttpGet(state.mRequestUri); try { executeDownload(state, client, request); finished = true; } catch (RetryDownload exc) { // fall through } finally { request.abort(); request = null; } } if (Constants.LOGV) { Log.v(Constants.TAG, "download completed for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } finalizeDestinationFile(state); finalStatus = DownloaderService.STATUS_SUCCESS; } catch (StopRequest error) { // remove the cause before printing, in case it contains PII Log.w(Constants.TAG, "Aborting request for download " + mInfo.mFileName + ": " + error.getMessage()); error.printStackTrace(); finalStatus = error.mFinalStatus; // fall through to finally block } catch (Throwable ex) { // sometimes the socket code throws unchecked // exceptions Log.w(Constants.TAG, "Exception for " + mInfo.mFileName + ": " + ex); finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; // falls through to the code that reports an error } finally { if (wakeLock != null) { wakeLock.release(); wakeLock = null; } if (client != null) { client.close(); client = null; } cleanupDestination(state, finalStatus); notifyDownloadCompleted(finalStatus, state.mCountRetry, state.mRetryAfter, state.mRedirectCount, state.mGotData, state.mFilename); } }
Example 19
Source File: DownloadThread.java From UnityOBBDownloader with Apache License 2.0 | 4 votes |
/** * Executes the download in a separate thread */ public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); State state = new State(mInfo, mService); PowerManager.WakeLock wakeLock = null; int finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; try { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.TAG); wakeLock.acquire(); if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } boolean finished = false; while (!finished) { if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } // Set or unset proxy, which may have changed since last GET // request. // setDefaultProxy() supports null as proxy parameter. URL url = new URL(state.mRequestUri); HttpURLConnection request = (HttpURLConnection)url.openConnection(); request.setRequestProperty("User-Agent", userAgent()); try { executeDownload(state, request); finished = true; } catch (RetryDownload exc) { // fall through } finally { request.disconnect(); request = null; } } if (Constants.LOGV) { Log.v(Constants.TAG, "download completed for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } finalizeDestinationFile(state); finalStatus = DownloaderService.STATUS_SUCCESS; } catch (StopRequest error) { // remove the cause before printing, in case it contains PII Log.w(Constants.TAG, "Aborting request for download " + mInfo.mFileName + ": " + error.getMessage()); error.printStackTrace(); finalStatus = error.mFinalStatus; // fall through to finally block } catch (Throwable ex) { // sometimes the socket code throws unchecked // exceptions Log.w(Constants.TAG, "Exception for " + mInfo.mFileName + ": " + ex); finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; // falls through to the code that reports an error } finally { if (wakeLock != null) { wakeLock.release(); wakeLock = null; } cleanupDestination(state, finalStatus); notifyDownloadCompleted(finalStatus, state.mCountRetry, state.mRetryAfter, state.mRedirectCount, state.mGotData, state.mFilename); } }
Example 20
Source File: DownloadThread.java From play-apk-expansion with Apache License 2.0 | 4 votes |
/** * Executes the download in a separate thread */ public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); State state = new State(mInfo, mService); PowerManager.WakeLock wakeLock = null; int finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; try { PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.TAG); wakeLock.acquire(); if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } boolean finished = false; while (!finished) { if (Constants.LOGV) { Log.v(Constants.TAG, "initiating download for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } // Set or unset proxy, which may have changed since last GET // request. // setDefaultProxy() supports null as proxy parameter. URL url = new URL(state.mRequestUri); HttpURLConnection request = (HttpURLConnection)url.openConnection(); request.setRequestProperty("User-Agent", userAgent()); try { executeDownload(state, request); finished = true; } catch (RetryDownload exc) { // fall through } finally { request.disconnect(); request = null; } } if (Constants.LOGV) { Log.v(Constants.TAG, "download completed for " + mInfo.mFileName); Log.v(Constants.TAG, " at " + mInfo.mUri); } finalizeDestinationFile(state); finalStatus = DownloaderService.STATUS_SUCCESS; } catch (StopRequest error) { // remove the cause before printing, in case it contains PII Log.w(Constants.TAG, "Aborting request for download " + mInfo.mFileName + ": " + error.getMessage()); error.printStackTrace(); finalStatus = error.mFinalStatus; // fall through to finally block } catch (Throwable ex) { // sometimes the socket code throws unchecked // exceptions Log.w(Constants.TAG, "Exception for " + mInfo.mFileName + ": " + ex); finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR; // falls through to the code that reports an error } finally { if (wakeLock != null) { wakeLock.release(); wakeLock = null; } cleanupDestination(state, finalStatus); notifyDownloadCompleted(finalStatus, state.mCountRetry, state.mRetryAfter, state.mRedirectCount, state.mGotData, state.mFilename); } }