FileDownloader.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. /* ownCloud Android client application
  2. * Copyright (C) 2012 Bartek Przybylski
  3. * Copyright (C) 2012-2013 ownCloud Inc.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2,
  7. * as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. */
  18. package com.owncloud.android.files.services;
  19. import java.io.File;
  20. import java.io.IOException;
  21. import java.util.AbstractList;
  22. import java.util.HashMap;
  23. import java.util.Iterator;
  24. import java.util.Map;
  25. import java.util.Vector;
  26. import java.util.concurrent.ConcurrentHashMap;
  27. import java.util.concurrent.ConcurrentMap;
  28. import com.owncloud.android.R;
  29. import com.owncloud.android.authentication.AuthenticatorActivity;
  30. import com.owncloud.android.datamodel.FileDataStorageManager;
  31. import com.owncloud.android.datamodel.OCFile;
  32. import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
  33. import com.owncloud.android.lib.common.OwnCloudClientFactory;
  34. import com.owncloud.android.lib.common.OwnCloudClient;
  35. import com.owncloud.android.operations.DownloadFileOperation;
  36. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  37. import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
  38. import com.owncloud.android.lib.resources.files.FileUtils;
  39. import com.owncloud.android.ui.activity.FileActivity;
  40. import com.owncloud.android.ui.activity.FileDisplayActivity;
  41. import com.owncloud.android.ui.preview.PreviewImageActivity;
  42. import com.owncloud.android.ui.preview.PreviewImageFragment;
  43. import com.owncloud.android.utils.DisplayUtils;
  44. import com.owncloud.android.utils.Log_OC;
  45. import android.accounts.Account;
  46. import android.accounts.AccountsException;
  47. import android.app.Notification;
  48. import android.app.NotificationManager;
  49. import android.app.PendingIntent;
  50. import android.app.Service;
  51. import android.content.Intent;
  52. import android.os.Binder;
  53. import android.os.Handler;
  54. import android.os.HandlerThread;
  55. import android.os.IBinder;
  56. import android.os.Looper;
  57. import android.os.Message;
  58. import android.os.Process;
  59. import android.widget.RemoteViews;
  60. public class FileDownloader extends Service implements OnDatatransferProgressListener {
  61. public static final String EXTRA_ACCOUNT = "ACCOUNT";
  62. public static final String EXTRA_FILE = "FILE";
  63. private static final String DOWNLOAD_ADDED_MESSAGE = "DOWNLOAD_ADDED";
  64. private static final String DOWNLOAD_FINISH_MESSAGE = "DOWNLOAD_FINISH";
  65. public static final String EXTRA_DOWNLOAD_RESULT = "RESULT";
  66. public static final String EXTRA_FILE_PATH = "FILE_PATH";
  67. public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
  68. public static final String ACCOUNT_NAME = "ACCOUNT_NAME";
  69. private static final String TAG = "FileDownloader";
  70. private Looper mServiceLooper;
  71. private ServiceHandler mServiceHandler;
  72. private IBinder mBinder;
  73. private OwnCloudClient mDownloadClient = null;
  74. private Account mLastAccount = null;
  75. private FileDataStorageManager mStorageManager;
  76. private ConcurrentMap<String, DownloadFileOperation> mPendingDownloads = new ConcurrentHashMap<String, DownloadFileOperation>();
  77. private DownloadFileOperation mCurrentDownload = null;
  78. private NotificationManager mNotificationManager;
  79. private Notification mNotification;
  80. private int mLastPercent;
  81. public static String getDownloadAddedMessage() {
  82. return FileDownloader.class.getName().toString() + DOWNLOAD_ADDED_MESSAGE;
  83. }
  84. public static String getDownloadFinishMessage() {
  85. return FileDownloader.class.getName().toString() + DOWNLOAD_FINISH_MESSAGE;
  86. }
  87. /**
  88. * Builds a key for mPendingDownloads from the account and file to download
  89. *
  90. * @param account Account where the file to download is stored
  91. * @param file File to download
  92. */
  93. private String buildRemoteName(Account account, OCFile file) {
  94. return account.name + file.getRemotePath();
  95. }
  96. /**
  97. * Service initialization
  98. */
  99. @Override
  100. public void onCreate() {
  101. super.onCreate();
  102. mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  103. HandlerThread thread = new HandlerThread("FileDownloaderThread",
  104. Process.THREAD_PRIORITY_BACKGROUND);
  105. thread.start();
  106. mServiceLooper = thread.getLooper();
  107. mServiceHandler = new ServiceHandler(mServiceLooper, this);
  108. mBinder = new FileDownloaderBinder();
  109. }
  110. /**
  111. * Entry point to add one or several files to the queue of downloads.
  112. *
  113. * New downloads are added calling to startService(), resulting in a call to this method. This ensures the service will keep on working
  114. * although the caller activity goes away.
  115. */
  116. @Override
  117. public int onStartCommand(Intent intent, int flags, int startId) {
  118. if ( !intent.hasExtra(EXTRA_ACCOUNT) ||
  119. !intent.hasExtra(EXTRA_FILE)
  120. /*!intent.hasExtra(EXTRA_FILE_PATH) ||
  121. !intent.hasExtra(EXTRA_REMOTE_PATH)*/
  122. ) {
  123. Log_OC.e(TAG, "Not enough information provided in intent");
  124. return START_NOT_STICKY;
  125. }
  126. Account account = intent.getParcelableExtra(EXTRA_ACCOUNT);
  127. OCFile file = intent.getParcelableExtra(EXTRA_FILE);
  128. AbstractList<String> requestedDownloads = new Vector<String>(); // dvelasco: now this always contains just one element, but that can change in a near future (download of multiple selection)
  129. String downloadKey = buildRemoteName(account, file);
  130. try {
  131. DownloadFileOperation newDownload = new DownloadFileOperation(account, file);
  132. mPendingDownloads.putIfAbsent(downloadKey, newDownload);
  133. newDownload.addDatatransferProgressListener(this);
  134. newDownload.addDatatransferProgressListener((FileDownloaderBinder)mBinder);
  135. requestedDownloads.add(downloadKey);
  136. sendBroadcastNewDownload(newDownload);
  137. } catch (IllegalArgumentException e) {
  138. Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage());
  139. return START_NOT_STICKY;
  140. }
  141. if (requestedDownloads.size() > 0) {
  142. Message msg = mServiceHandler.obtainMessage();
  143. msg.arg1 = startId;
  144. msg.obj = requestedDownloads;
  145. mServiceHandler.sendMessage(msg);
  146. }
  147. return START_NOT_STICKY;
  148. }
  149. /**
  150. * Provides a binder object that clients can use to perform operations on the queue of downloads, excepting the addition of new files.
  151. *
  152. * Implemented to perform cancellation, pause and resume of existing downloads.
  153. */
  154. @Override
  155. public IBinder onBind(Intent arg0) {
  156. return mBinder;
  157. }
  158. /**
  159. * Called when ALL the bound clients were onbound.
  160. */
  161. @Override
  162. public boolean onUnbind(Intent intent) {
  163. ((FileDownloaderBinder)mBinder).clearListeners();
  164. return false; // not accepting rebinding (default behaviour)
  165. }
  166. /**
  167. * Binder to let client components to perform operations on the queue of downloads.
  168. *
  169. * It provides by itself the available operations.
  170. */
  171. public class FileDownloaderBinder extends Binder implements OnDatatransferProgressListener {
  172. /**
  173. * Map of listeners that will be reported about progress of downloads from a {@link FileDownloaderBinder} instance
  174. */
  175. private Map<String, OnDatatransferProgressListener> mBoundListeners = new HashMap<String, OnDatatransferProgressListener>();
  176. /**
  177. * Cancels a pending or current download of a remote file.
  178. *
  179. * @param account Owncloud account where the remote file is stored.
  180. * @param file A file in the queue of pending downloads
  181. */
  182. public void cancel(Account account, OCFile file) {
  183. DownloadFileOperation download = null;
  184. synchronized (mPendingDownloads) {
  185. download = mPendingDownloads.remove(buildRemoteName(account, file));
  186. }
  187. if (download != null) {
  188. download.cancel();
  189. }
  190. }
  191. public void clearListeners() {
  192. mBoundListeners.clear();
  193. }
  194. /**
  195. * Returns True when the file described by 'file' in the ownCloud account 'account' is downloading or waiting to download.
  196. *
  197. * If 'file' is a directory, returns 'true' if some of its descendant files is downloading or waiting to download.
  198. *
  199. * @param account Owncloud account where the remote file is stored.
  200. * @param file A file that could be in the queue of downloads.
  201. */
  202. public boolean isDownloading(Account account, OCFile file) {
  203. if (account == null || file == null) return false;
  204. String targetKey = buildRemoteName(account, file);
  205. synchronized (mPendingDownloads) {
  206. if (file.isFolder()) {
  207. // this can be slow if there are many downloads :(
  208. Iterator<String> it = mPendingDownloads.keySet().iterator();
  209. boolean found = false;
  210. while (it.hasNext() && !found) {
  211. found = it.next().startsWith(targetKey);
  212. }
  213. return found;
  214. } else {
  215. return (mPendingDownloads.containsKey(targetKey));
  216. }
  217. }
  218. }
  219. /**
  220. * Adds a listener interested in the progress of the download for a concrete file.
  221. *
  222. * @param listener Object to notify about progress of transfer.
  223. * @param account ownCloud account holding the file of interest.
  224. * @param file {@link OCfile} of interest for listener.
  225. */
  226. public void addDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {
  227. if (account == null || file == null || listener == null) return;
  228. String targetKey = buildRemoteName(account, file);
  229. mBoundListeners.put(targetKey, listener);
  230. }
  231. /**
  232. * Removes a listener interested in the progress of the download for a concrete file.
  233. *
  234. * @param listener Object to notify about progress of transfer.
  235. * @param account ownCloud account holding the file of interest.
  236. * @param file {@link OCfile} of interest for listener.
  237. */
  238. public void removeDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {
  239. if (account == null || file == null || listener == null) return;
  240. String targetKey = buildRemoteName(account, file);
  241. if (mBoundListeners.get(targetKey) == listener) {
  242. mBoundListeners.remove(targetKey);
  243. }
  244. }
  245. @Override
  246. public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer,
  247. String fileName) {
  248. String key = buildRemoteName(mCurrentDownload.getAccount(), mCurrentDownload.getFile());
  249. OnDatatransferProgressListener boundListener = mBoundListeners.get(key);
  250. if (boundListener != null) {
  251. boundListener.onTransferProgress(progressRate, totalTransferredSoFar, totalToTransfer, fileName);
  252. }
  253. }
  254. }
  255. /**
  256. * Download worker. Performs the pending downloads in the order they were requested.
  257. *
  258. * Created with the Looper of a new thread, started in {@link FileUploader#onCreate()}.
  259. */
  260. private static class ServiceHandler extends Handler {
  261. // don't make it a final class, and don't remove the static ; lint will warn about a possible memory leak
  262. FileDownloader mService;
  263. public ServiceHandler(Looper looper, FileDownloader service) {
  264. super(looper);
  265. if (service == null)
  266. throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
  267. mService = service;
  268. }
  269. @Override
  270. public void handleMessage(Message msg) {
  271. @SuppressWarnings("unchecked")
  272. AbstractList<String> requestedDownloads = (AbstractList<String>) msg.obj;
  273. if (msg.obj != null) {
  274. Iterator<String> it = requestedDownloads.iterator();
  275. while (it.hasNext()) {
  276. mService.downloadFile(it.next());
  277. }
  278. }
  279. mService.stopSelf(msg.arg1);
  280. }
  281. }
  282. /**
  283. * Core download method: requests a file to download and stores it.
  284. *
  285. * @param downloadKey Key to access the download to perform, contained in mPendingDownloads
  286. */
  287. private void downloadFile(String downloadKey) {
  288. synchronized(mPendingDownloads) {
  289. mCurrentDownload = mPendingDownloads.get(downloadKey);
  290. }
  291. if (mCurrentDownload != null) {
  292. notifyDownloadStart(mCurrentDownload);
  293. RemoteOperationResult downloadResult = null;
  294. try {
  295. /// prepare client object to send the request to the ownCloud server
  296. if (mDownloadClient == null || !mLastAccount.equals(mCurrentDownload.getAccount())) {
  297. mLastAccount = mCurrentDownload.getAccount();
  298. mStorageManager = new FileDataStorageManager(mLastAccount, getContentResolver());
  299. mDownloadClient = OwnCloudClientFactory.createOwnCloudClient(mLastAccount, getApplicationContext());
  300. }
  301. /// perform the download
  302. downloadResult = mCurrentDownload.execute(mDownloadClient);
  303. if (downloadResult.isSuccess()) {
  304. saveDownloadedFile();
  305. }
  306. } catch (AccountsException e) {
  307. Log_OC.e(TAG, "Error while trying to get autorization for " + mLastAccount.name, e);
  308. downloadResult = new RemoteOperationResult(e);
  309. } catch (IOException e) {
  310. Log_OC.e(TAG, "Error while trying to get autorization for " + mLastAccount.name, e);
  311. downloadResult = new RemoteOperationResult(e);
  312. } finally {
  313. synchronized(mPendingDownloads) {
  314. mPendingDownloads.remove(downloadKey);
  315. }
  316. }
  317. /// notify result
  318. notifyDownloadResult(mCurrentDownload, downloadResult);
  319. sendBroadcastDownloadFinished(mCurrentDownload, downloadResult);
  320. }
  321. }
  322. /**
  323. * Updates the OC File after a successful download.
  324. */
  325. private void saveDownloadedFile() {
  326. OCFile file = mStorageManager.getFileById(mCurrentDownload.getFile().getFileId());
  327. long syncDate = System.currentTimeMillis();
  328. file.setLastSyncDateForProperties(syncDate);
  329. file.setLastSyncDateForData(syncDate);
  330. file.setModificationTimestamp(mCurrentDownload.getModificationTimestamp());
  331. file.setModificationTimestampAtLastSyncForData(mCurrentDownload.getModificationTimestamp());
  332. // file.setEtag(mCurrentDownload.getEtag()); // TODO Etag, where available
  333. file.setMimetype(mCurrentDownload.getMimeType());
  334. file.setStoragePath(mCurrentDownload.getSavePath());
  335. file.setFileLength((new File(mCurrentDownload.getSavePath()).length()));
  336. mStorageManager.saveFile(file);
  337. }
  338. /**
  339. * Creates a status notification to show the download progress
  340. *
  341. * @param download Download operation starting.
  342. */
  343. private void notifyDownloadStart(DownloadFileOperation download) {
  344. /// create status notification with a progress bar
  345. mLastPercent = 0;
  346. mNotification = new Notification(DisplayUtils.getSeasonalIconId(), getString(R.string.downloader_download_in_progress_ticker), System.currentTimeMillis());
  347. mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
  348. mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);
  349. mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, download.getSize() < 0);
  350. mNotification.contentView.setTextViewText(R.id.status_text, String.format(getString(R.string.downloader_download_in_progress_content), 0, new File(download.getSavePath()).getName()));
  351. mNotification.contentView.setImageViewResource(R.id.status_icon, DisplayUtils.getSeasonalIconId());
  352. /// includes a pending intent in the notification showing the details view of the file
  353. Intent showDetailsIntent = null;
  354. if (PreviewImageFragment.canBePreviewed(download.getFile())) {
  355. showDetailsIntent = new Intent(this, PreviewImageActivity.class);
  356. } else {
  357. showDetailsIntent = new Intent(this, FileDisplayActivity.class);
  358. }
  359. showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, download.getFile());
  360. showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, download.getAccount());
  361. showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  362. mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);
  363. mNotificationManager.notify(R.string.downloader_download_in_progress_ticker, mNotification);
  364. }
  365. /**
  366. * Callback method to update the progress bar in the status notification.
  367. */
  368. @Override
  369. public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String filePath) {
  370. int percent = (int)(100.0*((double)totalTransferredSoFar)/((double)totalToTransfer));
  371. if (percent != mLastPercent) {
  372. mNotification.contentView.setProgressBar(R.id.status_progress, 100, percent, totalToTransfer < 0);
  373. String fileName = filePath.substring(filePath.lastIndexOf(FileUtils.PATH_SEPARATOR) + 1);
  374. String text = String.format(getString(R.string.downloader_download_in_progress_content), percent, fileName);
  375. mNotification.contentView.setTextViewText(R.id.status_text, text);
  376. mNotificationManager.notify(R.string.downloader_download_in_progress_ticker, mNotification);
  377. }
  378. mLastPercent = percent;
  379. }
  380. /**
  381. * Updates the status notification with the result of a download operation.
  382. *
  383. * @param downloadResult Result of the download operation.
  384. * @param download Finished download operation
  385. */
  386. private void notifyDownloadResult(DownloadFileOperation download, RemoteOperationResult downloadResult) {
  387. mNotificationManager.cancel(R.string.downloader_download_in_progress_ticker);
  388. if (!downloadResult.isCancelled()) {
  389. int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
  390. int contentId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_content : R.string.downloader_download_failed_content;
  391. Notification finalNotification = new Notification(DisplayUtils.getSeasonalIconId(), getString(tickerId), System.currentTimeMillis());
  392. finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
  393. boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED ||
  394. // (downloadResult.isTemporalRedirection() && downloadResult.isIdPRedirection()
  395. (downloadResult.isIdPRedirection()
  396. && mDownloadClient.getCredentials() == null));
  397. //&& MainApp.getAuthTokenTypeSamlSessionCookie().equals(mDownloadClient.getAuthTokenType())));
  398. if (needsToUpdateCredentials) {
  399. // let the user update credentials with one click
  400. Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
  401. updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, download.getAccount());
  402. updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ENFORCED_UPDATE, true);
  403. updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN);
  404. updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  405. updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
  406. updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
  407. finalNotification.contentIntent = PendingIntent.getActivity(this, (int)System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT);
  408. finalNotification.setLatestEventInfo( getApplicationContext(),
  409. getString(tickerId),
  410. String.format(getString(contentId), new File(download.getSavePath()).getName()),
  411. finalNotification.contentIntent);
  412. mDownloadClient = null; // grant that future retries on the same account will get the fresh credentials
  413. } else {
  414. Intent showDetailsIntent = null;
  415. if (downloadResult.isSuccess()) {
  416. if (PreviewImageFragment.canBePreviewed(download.getFile())) {
  417. showDetailsIntent = new Intent(this, PreviewImageActivity.class);
  418. } else {
  419. showDetailsIntent = new Intent(this, FileDisplayActivity.class);
  420. }
  421. showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, download.getFile());
  422. showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, download.getAccount());
  423. showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  424. } else {
  425. // TODO put something smart in showDetailsIntent
  426. showDetailsIntent = new Intent();
  427. }
  428. finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);
  429. finalNotification.setLatestEventInfo(getApplicationContext(), getString(tickerId), String.format(getString(contentId), new File(download.getSavePath()).getName()), finalNotification.contentIntent);
  430. }
  431. mNotificationManager.notify(tickerId, finalNotification);
  432. }
  433. }
  434. /**
  435. * Sends a broadcast when a download finishes in order to the interested activities can update their view
  436. *
  437. * @param download Finished download operation
  438. * @param downloadResult Result of the download operation
  439. */
  440. private void sendBroadcastDownloadFinished(DownloadFileOperation download, RemoteOperationResult downloadResult) {
  441. Intent end = new Intent(getDownloadFinishMessage());
  442. end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess());
  443. end.putExtra(ACCOUNT_NAME, download.getAccount().name);
  444. end.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());
  445. end.putExtra(EXTRA_FILE_PATH, download.getSavePath());
  446. sendStickyBroadcast(end);
  447. }
  448. /**
  449. * Sends a broadcast when a new download is added to the queue.
  450. *
  451. * @param download Added download operation
  452. */
  453. private void sendBroadcastNewDownload(DownloadFileOperation download) {
  454. Intent added = new Intent(getDownloadAddedMessage());
  455. added.putExtra(ACCOUNT_NAME, download.getAccount().name);
  456. added.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());
  457. added.putExtra(EXTRA_FILE_PATH, download.getSavePath());
  458. sendStickyBroadcast(added);
  459. }
  460. }