diff options
author | Winson Chung <winsonc@google.com> | 2014-12-02 00:35:51 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-12-02 00:35:51 +0000 |
commit | 653af821ea2ce568010f60a9134ca3a7dea69fd8 (patch) | |
tree | 01e6b890c0f17e69fec7510d2856736b72e335e0 /src | |
parent | c0809125914256df4cbb1414348fed7699f6a53d (diff) | |
parent | 1c96028f414f904b90c1a180a537021a6a3eceff (diff) | |
download | android_packages_apps_Trebuchet-653af821ea2ce568010f60a9134ca3a7dea69fd8.tar.gz android_packages_apps_Trebuchet-653af821ea2ce568010f60a9134ca3a7dea69fd8.tar.bz2 android_packages_apps_Trebuchet-653af821ea2ce568010f60a9134ca3a7dea69fd8.zip |
am 1c96028f: Merge "Ignoring specific db exception to workaround Bug. 18554839." into ub-now-queens
* commit '1c96028f414f904b90c1a180a537021a6a3eceff':
Ignoring specific db exception to workaround Bug. 18554839.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/WidgetPreviewLoader.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java index 9cedae0f9..c3c0649f0 100644 --- a/src/com/android/launcher3/WidgetPreviewLoader.java +++ b/src/com/android/launcher3/WidgetPreviewLoader.java @@ -12,6 +12,7 @@ import android.database.sqlite.SQLiteCantOpenDatabaseException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDiskIOException; import android.database.sqlite.SQLiteOpenHelper; +import android.database.sqlite.SQLiteReadOnlyDatabaseException; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; @@ -26,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; @@ -165,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(); + } } } |