summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Martinz <amartinz@shiftphones.com>2019-01-09 19:13:43 (GMT)
committerAlexander Martinz <amartinz@shiftphones.com>2019-01-09 19:14:24 (GMT)
commitd17b08e4a990751b88e6ce30f91f76f745f6415f (patch)
treec5f3b637be631f99a0852c7c8a4fb73f1f1a6b45
parent0a846b8c5bb768540d16f89fa8d6a7e260348175 (diff)
downloadandroid_packages_apps_Trebuchet-d17b08e4a990751b88e6ce30f91f76f745f6415f.zip
android_packages_apps_Trebuchet-d17b08e4a990751b88e6ce30f91f76f745f6415f.tar.gz
android_packages_apps_Trebuchet-d17b08e4a990751b88e6ce30f91f76f745f6415f.tar.bz2
Discovery: fix crash when saving suggestions while disk is full
Change-Id: If7e678f35f7e2f767f43b19b407009007a33ef1d Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
-rw-r--r--src/com/android/launcher3/discovery/suggestions/SuggestionsDatabaseHelper.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/com/android/launcher3/discovery/suggestions/SuggestionsDatabaseHelper.java b/src/com/android/launcher3/discovery/suggestions/SuggestionsDatabaseHelper.java
index d18f9c9..c324929 100644
--- a/src/com/android/launcher3/discovery/suggestions/SuggestionsDatabaseHelper.java
+++ b/src/com/android/launcher3/discovery/suggestions/SuggestionsDatabaseHelper.java
@@ -117,17 +117,18 @@ public class SuggestionsDatabaseHelper extends SQLiteOpenHelper {
values.put(KEY_NIGHT_COUNTER, candidate.getNightCounter());
values.put(KEY_HEADSET_COUNTER, candidate.getHeadsetCounter());
- SQLiteDatabase db = getWritableDatabase();
- if (shouldUpdate) {
- String[] arguments = new String[] {
- candidate.getPackageName(), candidate.getClassName()
- };
- db.update(TABLE_NAME, values, QUERY_FILTER, arguments);
- } else {
- db.insert(TABLE_NAME, null, values);
+ try (SQLiteDatabase db = getWritableDatabase()) {
+ if (shouldUpdate) {
+ String[] arguments = new String[] {
+ candidate.getPackageName(), candidate.getClassName()
+ };
+ db.update(TABLE_NAME, values, QUERY_FILTER, arguments);
+ } else {
+ db.insert(TABLE_NAME, null, values);
+ }
+ } catch (SQLiteFullException sfe) {
+ // prevent crash
}
-
- db.close();
}
@NonNull