Snap for 6374687 from e0297ce1af405adb83121d3dad98488b52812f25 to rvc-release

Change-Id: I20827c03c138a6d889a32afda60ef81344ac754d
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 @@
             // 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 @@
             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 @@
         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")