summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSudheer Shanka <sudheersai@google.com>2019-07-31 02:06:42 (GMT)
committerSudheer Shanka <sudheersai@google.com>2019-07-31 09:18:13 (GMT)
commit90de12ad0c76fa9e231b3864c4afb8f312b53dda (patch)
treed080b8ef24506a87331af6f168fbda759f518eaa
parentf52b0bd3dfd214f7286191e420b9c05d31dafdb0 (diff)
downloadandroid_packages_providers_DownloadProvider-90de12ad0c76fa9e231b3864c4afb8f312b53dda.zip
android_packages_providers_DownloadProvider-90de12ad0c76fa9e231b3864c4afb8f312b53dda.tar.gz
android_packages_providers_DownloadProvider-90de12ad0c76fa9e231b3864c4afb8f312b53dda.tar.bz2
Trigger mediascan after a download is completed.
When a media item is inserted, media_type will be automatically updated but some of the other media attributes will only be updated after a media scan. Bug: 138419471 Test: manual Test: atest DownloadProviderTests Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java Test: atest cts/tests/app/DownloadManagerLegacyTest/src/android/app/cts/DownloadManagerLegacyTest.java Test: atest cts/tests/app/DownloadManagerApi28Test/src/android/app/cts/DownloadManagerApi28Test.java Change-Id: If8192b31fb7da37425480e7afa53dd1304533b76
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java5
-rw-r--r--tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java6
2 files changed, 11 insertions, 0 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index 550c8fb..eb0313c 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -851,6 +851,8 @@ public final class DownloadProvider extends ContentProvider {
mediaStoreUri.toString());
filteredValues.put(COLUMN_MEDIA_SCANNED, MEDIA_SCANNED);
}
+ MediaStore.scanFile(getContext(),
+ new File(filteredValues.getAsString(Downloads.Impl._DATA)));
} finally {
restoreCallingIdentity(token);
}
@@ -1551,6 +1553,9 @@ public final class DownloadProvider extends ContentProvider {
qb.update(db, updateValues, Downloads.Impl._ID + "=?",
new String[] { Long.toString(info.mId) });
}
+ if (Downloads.Impl.isStatusSuccess(info.mStatus)) {
+ MediaStore.scanFile(getContext(), new File(info.mFileName));
+ }
}
if (updateSchedule) {
Helpers.scheduleJob(context, info);
diff --git a/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java b/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
index 38bf4d6..6acdfed 100644
--- a/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
+++ b/tests/src/com/android/providers/downloads/AbstractDownloadProviderFunctionalTest.java
@@ -33,6 +33,7 @@ import android.database.DatabaseUtils;
import android.database.MatrixCursor;
import android.net.Uri;
import android.os.Binder;
+import android.os.Bundle;
import android.os.IBinder;
import android.provider.Downloads;
import android.provider.MediaStore;
@@ -123,6 +124,11 @@ public abstract class AbstractDownloadProviderFunctionalTest extends
}
@Override
+ public Bundle call(String method, String request, Bundle args) {
+ return new Bundle();
+ }
+
+ @Override
public IBinder getIContentProviderBinder() {
return new Binder();
}