Loading src/com/android/documentsui/archives/Archive.java +0 −20 Original line number Diff line number Diff line Loading @@ -42,8 +42,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; /** Loading @@ -67,7 +65,6 @@ public abstract class Archive implements Closeable { final Uri mArchiveUri; final int mArchiveMode; final Uri mNotificationUri; final ThreadPoolExecutor mExecutor; final Map<String, ZipEntry> mEntries; final Map<String, List<ZipEntry>> mTree; Loading @@ -81,12 +78,6 @@ public abstract class Archive implements Closeable { mArchiveMode = archiveMode; mNotificationUri = notificationUri; // At most 8 active threads. All threads idling for more than a minute will // be closed. mExecutor = new ThreadPoolExecutor(8, 8, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); mExecutor.allowCoreThreadTimeOut(true); mTree = new HashMap<>(); mEntries = new HashMap<>(); } Loading Loading @@ -244,17 +235,6 @@ public abstract class Archive implements Closeable { return new ArchiveId(mArchiveUri, mArchiveMode, path); } /** * Closes an archive. * * <p>This method does not block until shutdown. Once called, other methods should not be * called. Any active pipes will be terminated. */ @Override public void close() { mExecutor.shutdownNow(); } void addCursorRow(MatrixCursor cursor, ZipEntry entry) { final MatrixCursor.RowBuilder row = cursor.newRow(); final ArchiveId parsedId = createArchiveId(getEntryPath(entry)); Loading src/com/android/documentsui/archives/ArchivesProvider.java +4 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.internal.util.Preconditions; import java.io.Closeable; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.locks.Lock; Loading Loading @@ -71,6 +72,8 @@ public class ArchivesProvider extends DocumentsProvider implements Closeable { oldValue.getWriteLock().lock(); try { oldValue.get().close(); } catch (IOException e) { Log.e(TAG, "Closing archive failed.", e); }finally { oldValue.getWriteLock().unlock(); } Loading src/com/android/documentsui/archives/ReadableArchive.java +17 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Stack; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; /** Loading @@ -55,6 +58,7 @@ import java.util.zip.ZipEntry; public class ReadableArchive extends Archive { private static final String TAG = "Archive"; final ThreadPoolExecutor mExecutor; private final StrictJarFile mZipFile; private ReadableArchive( Loading @@ -70,6 +74,12 @@ public class ReadableArchive extends Archive { throw new IllegalStateException("Unsupported access mode."); } // At most 8 active threads. All threads idling for more than a minute will // be closed. mExecutor = new ThreadPoolExecutor(8, 8, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); mExecutor.allowCoreThreadTimeOut(true); mZipFile = file != null ? new StrictJarFile(file.getPath(), false /* verify */, false /* signatures */) : Loading Loading @@ -335,9 +345,15 @@ public class ReadableArchive extends Archive { openDocument(documentId, "r", signal), 0, entry.getSize(), null); } /** * Closes an archive. * * <p>This method does not block until shutdown. Once called, other methods should not be * called. Any active pipes will be terminated. */ @Override public void close() { super.close(); mExecutor.shutdownNow(); try { mZipFile.close(); } catch (IOException e) { Loading Loading
src/com/android/documentsui/archives/Archive.java +0 −20 Original line number Diff line number Diff line Loading @@ -42,8 +42,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; /** Loading @@ -67,7 +65,6 @@ public abstract class Archive implements Closeable { final Uri mArchiveUri; final int mArchiveMode; final Uri mNotificationUri; final ThreadPoolExecutor mExecutor; final Map<String, ZipEntry> mEntries; final Map<String, List<ZipEntry>> mTree; Loading @@ -81,12 +78,6 @@ public abstract class Archive implements Closeable { mArchiveMode = archiveMode; mNotificationUri = notificationUri; // At most 8 active threads. All threads idling for more than a minute will // be closed. mExecutor = new ThreadPoolExecutor(8, 8, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); mExecutor.allowCoreThreadTimeOut(true); mTree = new HashMap<>(); mEntries = new HashMap<>(); } Loading Loading @@ -244,17 +235,6 @@ public abstract class Archive implements Closeable { return new ArchiveId(mArchiveUri, mArchiveMode, path); } /** * Closes an archive. * * <p>This method does not block until shutdown. Once called, other methods should not be * called. Any active pipes will be terminated. */ @Override public void close() { mExecutor.shutdownNow(); } void addCursorRow(MatrixCursor cursor, ZipEntry entry) { final MatrixCursor.RowBuilder row = cursor.newRow(); final ArchiveId parsedId = createArchiveId(getEntryPath(entry)); Loading
src/com/android/documentsui/archives/ArchivesProvider.java +4 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.internal.util.Preconditions; import java.io.Closeable; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.locks.Lock; Loading Loading @@ -71,6 +72,8 @@ public class ArchivesProvider extends DocumentsProvider implements Closeable { oldValue.getWriteLock().lock(); try { oldValue.get().close(); } catch (IOException e) { Log.e(TAG, "Closing archive failed.", e); }finally { oldValue.getWriteLock().unlock(); } Loading
src/com/android/documentsui/archives/ReadableArchive.java +17 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Stack; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; /** Loading @@ -55,6 +58,7 @@ import java.util.zip.ZipEntry; public class ReadableArchive extends Archive { private static final String TAG = "Archive"; final ThreadPoolExecutor mExecutor; private final StrictJarFile mZipFile; private ReadableArchive( Loading @@ -70,6 +74,12 @@ public class ReadableArchive extends Archive { throw new IllegalStateException("Unsupported access mode."); } // At most 8 active threads. All threads idling for more than a minute will // be closed. mExecutor = new ThreadPoolExecutor(8, 8, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); mExecutor.allowCoreThreadTimeOut(true); mZipFile = file != null ? new StrictJarFile(file.getPath(), false /* verify */, false /* signatures */) : Loading Loading @@ -335,9 +345,15 @@ public class ReadableArchive extends Archive { openDocument(documentId, "r", signal), 0, entry.getSize(), null); } /** * Closes an archive. * * <p>This method does not block until shutdown. Once called, other methods should not be * called. Any active pipes will be terminated. */ @Override public void close() { super.close(); mExecutor.shutdownNow(); try { mZipFile.close(); } catch (IOException e) { Loading