diff options
author | James Wei <jameswei@google.com> | 2020-04-07 04:48:51 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-07 04:48:51 +0000 |
commit | a98972cbf4a3764dc1e998019f4c106c2d97bf24 (patch) | |
tree | efba138ac2ae22eea6fe9a1f3e379c67b295ac0f | |
parent | 61d1702f4c7ecac9a80f2697f9401a8339d79058 (diff) | |
parent | 631bfe73c838008b5fbb0419cbb0cccf58b53522 (diff) | |
download | Mtp-a98972cbf4a3764dc1e998019f4c106c2d97bf24.tar.gz |
MTP: Add MTP host exception handling#2 am: e0297ce1af am: 073d5efa7c am: 631bfe73c8
Change-Id: Ibeab85655409c2ee07d013e48dc254f35c8a604d
-rw-r--r-- | src/com/android/mtp/MtpDatabase.java | 5 | ||||
-rw-r--r-- | tests/src/com/android/mtp/MtpDatabaseTest.java | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/com/android/mtp/MtpDatabase.java b/src/com/android/mtp/MtpDatabase.java index bfb5cb8..f3b1549 100644 --- a/src/com/android/mtp/MtpDatabase.java +++ b/src/com/android/mtp/MtpDatabase.java @@ -535,7 +535,8 @@ class MtpDatabase { // TODO Remove mappingState. return deleted != 0; } catch (SQLiteException exSql) { - Log.w(TAG, "SQLiteException:" + selection, exSql); + Log.w(TAG, "deleteDocumentsAndRoots.SQLiteException (bypassed): " + + selection + ", dump:", exSql); return false; } finally { mDatabase.endTransaction(); @@ -684,6 +685,8 @@ class MtpDatabase { deleteDocumentsAndRoots( Document.COLUMN_DOCUMENT_ID + " NOT IN " + getIdList(ids), null); mDatabase.setTransactionSuccessful(); + } catch (IllegalArgumentException exArg) { + Log.w(TAG, "cleanDatabase.IllegalArgumentException (bypassed), dump:", exArg); } finally { mDatabase.endTransaction(); } diff --git a/tests/src/com/android/mtp/MtpDatabaseTest.java b/tests/src/com/android/mtp/MtpDatabaseTest.java index 32b169e..05d7b23 100644 --- a/tests/src/com/android/mtp/MtpDatabaseTest.java +++ b/tests/src/com/android/mtp/MtpDatabaseTest.java @@ -1055,6 +1055,17 @@ public class MtpDatabaseTest extends AndroidTestCase { mDatabase.getMapper().startAddingDocuments(null); mDatabase.getMapper().stopAddingDocuments(null); + // Clean database with error column + mDatabase.cleanDatabase(new Uri[] { + DocumentsContract.buildDocumentUri(MtpDocumentsProvider.AUTHORITY, + "wrong_id_test") + }); + + // Clean database with error uri + mDatabase.cleanDatabase(new Uri[] { + Uri.parse("content://com.android.providers.downloads.documents/wrong_uri_test") + }); + // Clean database. mDatabase.cleanDatabase(new Uri[] { DocumentsContract.buildDocumentUri(MtpDocumentsProvider.AUTHORITY, "3") |