From: David A. Velasco Date: Tue, 24 Jul 2012 11:04:58 +0000 (+0200) Subject: Explicit default values for network timeouts; fixed null pointer in message broadcast... X-Git-Tag: oc-android-1.4.3~243 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/9d3208ea0372294f606df5ddb543b2062d1eacac?ds=inline Explicit default values for network timeouts; fixed null pointer in message broadcasted when a download can't finish --- diff --git a/src/eu/alefzero/owncloud/files/services/FileDownloader.java b/src/eu/alefzero/owncloud/files/services/FileDownloader.java index cb5d0c8d..e5316b3e 100644 --- a/src/eu/alefzero/owncloud/files/services/FileDownloader.java +++ b/src/eu/alefzero/owncloud/files/services/FileDownloader.java @@ -164,16 +164,14 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis } } - if (!download_result) { - tmpFile.delete(); - } - mNotificationMngr.cancel(1); Intent end = new Intent(DOWNLOAD_FINISH_MESSAGE); - end.putExtra(EXTRA_REMOTE_PATH, mRemotePath); - end.putExtra(EXTRA_FILE_PATH, newFile.getAbsolutePath()); end.putExtra(EXTRA_DOWNLOAD_RESULT, download_result); end.putExtra(ACCOUNT_NAME, mAccount.name); + end.putExtra(EXTRA_REMOTE_PATH, mRemotePath); + if (download_result) { + end.putExtra(EXTRA_FILE_PATH, newFile.getAbsolutePath()); + } sendBroadcast(end); if (download_result) { diff --git a/src/eu/alefzero/webdav/WebdavClient.java b/src/eu/alefzero/webdav/WebdavClient.java index bd58fcc2..7194195c 100644 --- a/src/eu/alefzero/webdav/WebdavClient.java +++ b/src/eu/alefzero/webdav/WebdavClient.java @@ -57,6 +57,13 @@ public class WebdavClient extends HttpClient { private Credentials mCredentials; final private static String TAG = "WebdavClient"; private static final String USER_AGENT = "Android-ownCloud"; + + /** Default timeout for waiting data from the server: 10 seconds */ + public static final int DEFAULT_DATA_TIMEOUT = 10000; + + /** Default timeout for establishing a connection: infinite */ + public static final int DEFAULT_CONNECTION_TIMEOUT = 0; + private OnDatatransferProgressListener mDataTransferListener; static private MultiThreadedHttpConnectionManager mConnManager = null; @@ -76,6 +83,8 @@ public class WebdavClient extends HttpClient { * @return */ public WebdavClient (Account account, Context context) { + setDefaultTimeouts(); + OwnCloudVersion ownCloudVersion = new OwnCloudVersion(AccountManager.get(context).getUserData(account, AccountAuthenticator.KEY_OC_VERSION)); String baseUrl = AccountManager.get(context).getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL); @@ -84,13 +93,15 @@ public class WebdavClient extends HttpClient { String password = AccountManager.get(context).getPassword(account); mUri = Uri.parse(baseUrl + webDavPath); -Log.e("ASD", ""+username); + Log.e("ASD", ""+username); setCredentials(username, password); } public WebdavClient() { super(getMultiThreadedConnManager()); + setDefaultTimeouts(); + getParams().setParameter(HttpMethodParams.USER_AGENT, USER_AGENT); getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); allowSelfsignedCertificates(); @@ -107,6 +118,14 @@ Log.e("ASD", ""+username); mCredentials = new UsernamePasswordCredentials(username, password); return mCredentials; } + + /** + * Sets the connection and wait-for-data timeouts to be applied by default. + */ + private void setDefaultTimeouts() { + getParams().setSoTimeout(DEFAULT_DATA_TIMEOUT); + getHttpConnectionManager().getParams().setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); + } public void allowSelfsignedCertificates() { // https