From 3a4a3e7cd5a379e7e757177826ba935f000eb455 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 24 Jun 2016 18:13:22 -0600 Subject: Make scanning decisions based on latest data. When deciding to kick off a media scan of a newly-downloaded file, use the latest values from InfoDelta, instead of stale values from the last database read, which may lead us to skip the scan. Bug: 29234780 Change-Id: I7ffbcdd1edb9965999b7f5f100f57a9c2933f3a5 --- src/com/android/providers/downloads/DownloadInfo.java | 4 ++-- src/com/android/providers/downloads/DownloadThread.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/android/providers/downloads/DownloadInfo.java b/src/com/android/providers/downloads/DownloadInfo.java index 00a2dd78..c571de4d 100644 --- a/src/com/android/providers/downloads/DownloadInfo.java +++ b/src/com/android/providers/downloads/DownloadInfo.java @@ -448,12 +448,12 @@ public class DownloadInfo { /** * Returns whether a file should be scanned */ - public boolean shouldScanFile() { + public boolean shouldScanFile(int status) { return (mMediaScanned == 0) && (mDestination == Downloads.Impl.DESTINATION_EXTERNAL || mDestination == Downloads.Impl.DESTINATION_FILE_URI || mDestination == Downloads.Impl.DESTINATION_NON_DOWNLOADMANAGER_DOWNLOAD) - && Downloads.Impl.isStatusSuccess(mStatus); + && Downloads.Impl.isStatusSuccess(status); } /** diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java index 60a04ff1..40194038 100644 --- a/src/com/android/providers/downloads/DownloadThread.java +++ b/src/com/android/providers/downloads/DownloadThread.java @@ -383,8 +383,9 @@ public class DownloadThread extends Thread { if (Downloads.Impl.isStatusCompleted(mInfoDelta.mStatus)) { mInfo.sendIntentIfRequested(); - if (mInfo.shouldScanFile()) { - DownloadScanner.requestScanBlocking(mContext, mInfo); + if (mInfo.shouldScanFile(mInfoDelta.mStatus)) { + DownloadScanner.requestScanBlocking(mContext, mInfo.mId, mInfoDelta.mFileName, + mInfoDelta.mMimeType); } } else if (mInfoDelta.mStatus == STATUS_WAITING_TO_RETRY || mInfoDelta.mStatus == STATUS_WAITING_FOR_NETWORK -- cgit v1.2.3