Fixed crash when the device is turned while the warning dialog about server certifica...
[pub/Android/ownCloud.git] / src / com / owncloud / android / files / services / FileDownloader.java
index 4aafcce..59d5daa 100644 (file)
@@ -7,7 +7,9 @@ import java.util.Map;
 \r
 import com.owncloud.android.authenticator.AccountAuthenticator;\r
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;\r
-import com.owncloud.android.files.interfaces.OnDatatransferProgressListener;\r
+import eu.alefzero.webdav.OnDatatransferProgressListener;\r
+\r
+import com.owncloud.android.network.OwnCloudClientUtils;\r
 \r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
@@ -141,22 +143,8 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         boolean downloadResult = false;\r
 \r
         /// prepare client object to send the request to the ownCloud server\r
-        AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);\r
-        WebdavClient wdc = new WebdavClient(mAccount, getApplicationContext());\r
-        String username = mAccount.name.split("@")[0];\r
-        String password = null;\r
-        try {\r
-            password = am.blockingGetAuthToken(mAccount,\r
-                    AccountAuthenticator.AUTH_TOKEN_TYPE, true);\r
-        } catch (Exception e) {\r
-            Log.e(TAG, "Access to account credentials failed", e);\r
-            sendFinalBroadcast(downloadResult, null);\r
-            return;\r
-        }\r
-        wdc.setCredentials(username, password);\r
-        wdc.allowSelfsignedCertificates();\r
+        WebdavClient wdc = OwnCloudClientUtils.createOwnCloudClient(mAccount, getApplicationContext());\r
         wdc.setDataTransferProgressListener(this);\r
-\r
         \r
         /// download will be in a temporal file\r
         File tmpFile = new File(getTemporalPath(mAccount.name) + mFilePath);\r