summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wei <jameswei@google.com>2020-04-07 04:48:05 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-04-07 04:48:05 +0000
commitfe851ad6f209b05cf908251bce96a09e1b1d3d8c (patch)
treeefba138ac2ae22eea6fe9a1f3e379c67b295ac0f
parent8c59354e694a7e395417a7c94388d194f21deca1 (diff)
parent8788b998339af115404ec7230d28c06d5dea4424 (diff)
downloadMtp-fe851ad6f209b05cf908251bce96a09e1b1d3d8c.tar.gz
MTP: Add MTP host exception handling#2 am: e0297ce1af am: 073d5efa7c am: 8788b99833
Change-Id: I34f9b56e0a7765f79929521d927573193ee1f881
-rw-r--r--src/com/android/mtp/MtpDatabase.java5
-rw-r--r--tests/src/com/android/mtp/MtpDatabaseTest.java11
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")