summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2014-12-01 15:05:17 -0800
committerDanesh M <daneshm90@gmail.com>2015-09-27 21:07:54 -0700
commit6238f10efa9b29c5a799982e1f1b892410f816f1 (patch)
tree863179958caa1cbc0362a2086afa780e55651164
parent12170d8ee951ec1d035eb731ba3c060d2a1549d5 (diff)
downloadandroid_packages_apps_Trebuchet-6238f10efa9b29c5a799982e1f1b892410f816f1.tar.gz
android_packages_apps_Trebuchet-6238f10efa9b29c5a799982e1f1b892410f816f1.tar.bz2
android_packages_apps_Trebuchet-6238f10efa9b29c5a799982e1f1b892410f816f1.zip
Ignoring specific db exception to workaround Bug. 18554839.
Change-Id: I80f2dd62297eea671f2d129ae22263e72e506ae4
-rw-r--r--src/com/android/launcher3/WidgetPreviewLoader.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java
index 7b803cdc1..e4d06bfc3 100644
--- a/src/com/android/launcher3/WidgetPreviewLoader.java
+++ b/src/com/android/launcher3/WidgetPreviewLoader.java
@@ -27,8 +27,8 @@ import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
+import android.os.Build;
import android.util.Log;
-
import com.android.launcher3.compat.AppWidgetManagerCompat;
import java.io.ByteArrayOutputStream;
@@ -166,14 +166,26 @@ public class WidgetPreviewLoader {
LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE);
final String lastVersionName = sp.getString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, null);
final String versionName = android.os.Build.VERSION.INCREMENTAL;
+ final boolean isLollipop = Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP;
if (!versionName.equals(lastVersionName)) {
- // clear all the previews whenever the system version changes, to ensure that previews
- // are up-to-date for any apps that might have been updated with the system
- clearDb();
-
- SharedPreferences.Editor editor = sp.edit();
- editor.putString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, versionName);
- editor.commit();
+ try {
+ // clear all the previews whenever the system version changes, to ensure that
+ // previews are up-to-date for any apps that might have been updated with the system
+ clearDb();
+ } catch (SQLiteReadOnlyDatabaseException e) {
+ if (isLollipop) {
+ // Workaround for Bug. 18554839, if we fail to clear the db due to the read-only
+ // issue, then ignore this error and leave the old previews
+ } else {
+ throw e;
+ }
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ SharedPreferences.Editor editor = sp.edit();
+ editor.putString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, versionName);
+ editor.commit();
+ }
}
}