Merge "Don't crash settings when out of space." into nyc-dev
This commit is contained in:
@@ -31,6 +31,7 @@ import android.database.DatabaseUtils;
|
|||||||
import android.database.MergeCursor;
|
import android.database.MergeCursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteException;
|
import android.database.sqlite.SQLiteException;
|
||||||
|
import android.database.sqlite.SQLiteFullException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.provider.SearchIndexableData;
|
import android.provider.SearchIndexableData;
|
||||||
@@ -1194,35 +1195,39 @@ public class Index {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(UpdateData... params) {
|
protected Void doInBackground(UpdateData... params) {
|
||||||
final List<SearchIndexableData> dataToUpdate = params[0].dataToUpdate;
|
|
||||||
final List<SearchIndexableData> dataToDelete = params[0].dataToDelete;
|
|
||||||
final Map<String, List<String>> nonIndexableKeys = params[0].nonIndexableKeys;
|
|
||||||
|
|
||||||
final boolean forceUpdate = params[0].forceUpdate;
|
|
||||||
final boolean fullIndex = params[0].fullIndex;
|
|
||||||
|
|
||||||
final SQLiteDatabase database = getWritableDatabase();
|
|
||||||
if (database == null) {
|
|
||||||
Log.e(LOG_TAG, "Cannot update Index as I cannot get a writable database");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final String localeStr = Locale.getDefault().toString();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
database.beginTransaction();
|
final List<SearchIndexableData> dataToUpdate = params[0].dataToUpdate;
|
||||||
if (dataToDelete.size() > 0) {
|
final List<SearchIndexableData> dataToDelete = params[0].dataToDelete;
|
||||||
processDataToDelete(database, localeStr, dataToDelete);
|
final Map<String, List<String>> nonIndexableKeys = params[0].nonIndexableKeys;
|
||||||
|
|
||||||
|
final boolean forceUpdate = params[0].forceUpdate;
|
||||||
|
final boolean fullIndex = params[0].fullIndex;
|
||||||
|
|
||||||
|
final SQLiteDatabase database = getWritableDatabase();
|
||||||
|
if (database == null) {
|
||||||
|
Log.e(LOG_TAG, "Cannot update Index as I cannot get a writable database");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
if (dataToUpdate.size() > 0) {
|
final String localeStr = Locale.getDefault().toString();
|
||||||
processDataToUpdate(database, localeStr, dataToUpdate, nonIndexableKeys,
|
|
||||||
forceUpdate);
|
try {
|
||||||
|
database.beginTransaction();
|
||||||
|
if (dataToDelete.size() > 0) {
|
||||||
|
processDataToDelete(database, localeStr, dataToDelete);
|
||||||
|
}
|
||||||
|
if (dataToUpdate.size() > 0) {
|
||||||
|
processDataToUpdate(database, localeStr, dataToUpdate, nonIndexableKeys,
|
||||||
|
forceUpdate);
|
||||||
|
}
|
||||||
|
database.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
database.endTransaction();
|
||||||
}
|
}
|
||||||
database.setTransactionSuccessful();
|
if (fullIndex) {
|
||||||
} finally {
|
IndexDatabaseHelper.setLocaleIndexed(mContext, localeStr);
|
||||||
database.endTransaction();
|
}
|
||||||
}
|
} catch (SQLiteFullException e) {
|
||||||
if (fullIndex) {
|
Log.e(LOG_TAG, "Unable to index search, out of space", e);
|
||||||
IndexDatabaseHelper.setLocaleIndexed(mContext, localeStr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user