summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSudheer Shanka <sudheersai@google.com>2019-02-15 15:06:06 -0800
committerSudheer Shanka <sudheersai@google.com>2019-02-28 15:15:20 -0800
commit37e236239a63930a2cf0b20df9b1054efa73dc82 (patch)
treeea27834ef2e5db02d8785d9be30a891d870b0efe /src
parent50d0910a9b0a7eccbd5ef7ad30904ccc238dac43 (diff)
downloadandroid_packages_providers_DownloadProvider-37e236239a63930a2cf0b20df9b1054efa73dc82.tar.gz
android_packages_providers_DownloadProvider-37e236239a63930a2cf0b20df9b1054efa73dc82.tar.bz2
android_packages_providers_DownloadProvider-37e236239a63930a2cf0b20df9b1054efa73dc82.zip
Fix DownloadStorageProvider watching files in known download dirs.
This change will ensure when the download root is queried for the first time, DownloadStorageProvider will start observing the existing download dirs. There is still a corner case which is not fixed by this change that is if a new sandbox top-level Download directory gets created while the user is using the files app, changes in that newly created directory won't be picked up automatically unless the user refreshes the app. Bug: 124524422 Test: manual Change-Id: I8d57eeb3f630039d217c4f0c8802c1b1b80da745
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/downloads/DownloadStorageProvider.java18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java
index 0396e612..2b5b7356 100644
--- a/src/com/android/providers/downloads/DownloadStorageProvider.java
+++ b/src/com/android/providers/downloads/DownloadStorageProvider.java
@@ -478,7 +478,6 @@ public class DownloadStorageProvider extends FileSystemProvider {
String[] projection, Set<String> filePaths,
Bundle queryArgs) throws FileNotFoundException {
final List<File> downloadsDirs = getDownloadsDirectories();
- result.setIncludedDownloadDirs(downloadsDirs);
final int size = downloadsDirs.size();
for (int i = 0; i < size; ++i) {
final File downloadDir = downloadsDirs.get(i);
@@ -751,7 +750,6 @@ public class DownloadStorageProvider extends FileSystemProvider {
Set<String> downloadedFilePaths, @Nullable String searchString)
throws FileNotFoundException {
final List<File> downloadsDirs = getDownloadsDirectories();
- result.setIncludedDownloadDirs(downloadsDirs);
// Add every file from the Downloads directory to the result cursor. Ignore files that
// were in the supplied downloaded file paths.
final int size = downloadsDirs.size();
@@ -768,7 +766,7 @@ public class DownloadStorageProvider extends FileSystemProvider {
}
}
- private List<File> getDownloadsDirectories() {
+ private static List<File> getDownloadsDirectories() {
final List<File> downloadsDirectories = new ArrayList<>();
downloadsDirectories.add(getTopLevelDownloadsDirectory());
final File sandboxDir = Environment.buildExternalStorageAndroidSandboxDirs()[0];
@@ -1021,8 +1019,6 @@ public class DownloadStorageProvider extends FileSystemProvider {
private static int mOpenCursorCount = 0;
@GuardedBy("mLock")
private static @Nullable ContentChangedRelay mFileWatcher;
- @GuardedBy("mLock")
- private List<File> mIncludedDownloadDirs;
private final ContentResolver mResolver;
@@ -1031,16 +1027,10 @@ public class DownloadStorageProvider extends FileSystemProvider {
mResolver = resolver;
}
- void setIncludedDownloadDirs(List<File> downloadDirs) {
- synchronized (mLock) {
- mIncludedDownloadDirs = downloadDirs;
- }
- }
-
void start() {
synchronized (mLock) {
- if (mOpenCursorCount++ == 0 && mIncludedDownloadDirs != null) {
- mFileWatcher = new ContentChangedRelay(mResolver, mIncludedDownloadDirs);
+ if (mOpenCursorCount++ == 0) {
+ mFileWatcher = new ContentChangedRelay(mResolver, getDownloadsDirectories());
mFileWatcher.startWatching();
}
}
@@ -1050,7 +1040,7 @@ public class DownloadStorageProvider extends FileSystemProvider {
public void close() {
super.close();
synchronized (mLock) {
- if (--mOpenCursorCount == 0 && mFileWatcher != null) {
+ if (--mOpenCursorCount == 0) {
mFileWatcher.stopWatching();
mFileWatcher = null;
}