Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0524d26 authored by Grace Kloba's avatar Grace Kloba Committed by Android Git Automerger
Browse files

am 3ff7cecd: Merge "DO NOT MERGE" into eclair-mr2

Merge commit '3ff7cecd' into eclair-mr2-plus-aosp

* commit '3ff7cecd':
  DO NOT MERGE
parents 3ca122df 3ff7cecd
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -24,10 +24,12 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.bouncycastle.crypto.Digest;
@@ -541,6 +543,26 @@ public final class CacheManager {
                    Log.e(LOGTAG, f.getPath() + " delete failed.");
                }
            }
            // remove the unreferenced files in the cache directory
            final List<String> fileList = mDataBase.getAllCacheFileNames();
            if (fileList == null) return;
            String[] toDelete = mBaseDir.list(new FilenameFilter() {
                public boolean accept(File dir, String filename) {
                    if (fileList.contains(filename)) {
                        return false;
                    } else {
                        return true;
                    }
                }
            });
            if (toDelete == null) return;
            size = toDelete.length;
            for (int i = 0; i < size; i++) {
                File f = new File(mBaseDir, toDelete[i]);
                if (!f.delete()) {
                    Log.e(LOGTAG, f.getPath() + " delete failed.");
                }
            }
        }
    }

+15 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.webkit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Map.Entry;

@@ -727,6 +728,20 @@ public class WebViewDatabase {
        return pathList;
    }

    List<String> getAllCacheFileNames() {
        ArrayList<String> pathList = null;
        Cursor cursor = mCacheDatabase.rawQuery("SELECT filepath FROM cache",
                null);
        if (cursor != null && cursor.moveToFirst()) {
            pathList = new ArrayList<String>(cursor.getCount());
            do {
                pathList.add(cursor.getString(0));
            } while (cursor.moveToNext());
        }
        cursor.close();
        return pathList;
    }

    //
    // password functions
    //