diff options
author | Andrei Popescu <andreip@google.com> | 2009-09-21 18:49:42 +0100 |
---|---|---|
committer | Andrei Popescu <andreip@google.com> | 2009-09-21 19:53:13 +0100 |
commit | 1b20b9de7c495232fd81ab2f6b4ef2e5a35bf457 (patch) | |
tree | a58eb1f9ad1d1ea0a58d92de785b3ab97f5701f6 | |
parent | 07712d137998b271e958b285c05eea38a0b8e600 (diff) | |
download | packages_apps_browser-1b20b9de7c495232fd81ab2f6b4ef2e5a35bf457.zip packages_apps_browser-1b20b9de7c495232fd81ab2f6b4ef2e5a35bf457.tar.gz packages_apps_browser-1b20b9de7c495232fd81ab2f6b4ef2e5a35bf457.tar.bz2 |
Remove Gears files
-rw-r--r-- | src/com/android/browser/BrowserProvider.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java index 4db1ebc..c90ad49 100644 --- a/src/com/android/browser/BrowserProvider.java +++ b/src/com/android/browser/BrowserProvider.java @@ -38,6 +38,7 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.net.Uri; +import android.os.AsyncTask; import android.os.Handler; import android.preference.PreferenceManager; import android.provider.Browser; @@ -49,6 +50,8 @@ import android.text.util.Regex; import android.util.Log; import android.util.TypedValue; +import java.io.File; +import java.io.FilenameFilter; import java.util.Date; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -265,12 +268,62 @@ public class BrowserProvider extends ContentProvider { } if (oldVersion < 22) { db.execSQL("DELETE FROM bookmarks WHERE (bookmark = 0 AND url LIKE \"%.google.%client=ms-%\")"); + removeGears(); } else { db.execSQL("DROP TABLE IF EXISTS bookmarks"); db.execSQL("DROP TABLE IF EXISTS searches"); onCreate(db); } } + + private void removeGears() { + AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { + public Void doInBackground(Void... unused) { + String browserDataDirString = mContext.getApplicationInfo().dataDir; + final String appPluginsDirString = "app_plugins"; + final String gearsPrefix = "gears"; + File appPluginsDir = new File(browserDataDirString + File.separator + + appPluginsDirString); + if (!appPluginsDir.exists()) { + return null; + } + // Delete the Gears plugin files + File[] gearsFiles = appPluginsDir.listFiles(new FilenameFilter() { + public boolean accept(File dir, String filename) { + return filename.startsWith(gearsPrefix); + } + }); + for (int i = 0; i < gearsFiles.length; ++i) { + if (gearsFiles[i].isDirectory()) { + deleteDirectory(gearsFiles[i]); + } else { + gearsFiles[i].delete(); + } + } + // Delete the Gears data files + File gearsDataDir = new File(browserDataDirString + File.separator + + gearsPrefix); + if (!gearsDataDir.exists()) { + return null; + } + deleteDirectory(gearsDataDir); + return null; + } + + private void deleteDirectory(File currentDir) { + File[] files = currentDir.listFiles(); + for (int i = 0; i < files.length; ++i) { + if (files[i].isDirectory()) { + deleteDirectory(files[i]); + } + files[i].delete(); + } + currentDir.delete(); + } + }; + + task.execute(); + } } @Override |