Stop reopening MTP devices.

BUG=26175809

Change-Id: I45a51c0623b349f12e7d3cf787a89b089f230bc1
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java
index 51c0281..3c46ba6 100644
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java
+++ b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java
@@ -307,32 +307,6 @@
         }
     }
 
-    /**
-     * Returns the set of device ID stored in the database.
-     */
-    int[] getDeviceIds() {
-        final Cursor cursor = mDatabase.query(
-                true,
-                TABLE_DOCUMENTS,
-                strings(COLUMN_DEVICE_ID),
-                null,
-                null,
-                null,
-                null,
-                null,
-                null);
-        try {
-            final int[] ids = new int[cursor.getCount()];
-            for (int i = 0; i < ids.length; i++) {
-                cursor.moveToNext();
-                ids[i] = cursor.getInt(0);
-            }
-            return ids;
-        } finally {
-            cursor.close();
-        }
-    }
-
     private boolean deleteDocumentsAndRoots(String selection, String[] args) {
         mDatabase.beginTransaction();
         try {
diff --git a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java
index d5f00e6..9338c1b 100644
--- a/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java
+++ b/packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java
@@ -293,19 +293,11 @@
     }
 
     /**
-     * Reopens MTP devices based on database state.
+     * Clears MTP identifier in the database.
      */
     private void resume() {
         synchronized (mDeviceListLock) {
             mDatabase.getMapper().clearMapping();
-            final int[] ids = mDatabase.getDeviceIds();
-            for (final int id : ids) {
-                try {
-                    openDevice(id);
-                } catch (IOException exception) {
-                    mDatabase.removeDeviceRows(id);
-                }
-            }
         }
     }
 
diff --git a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java
index dc6f79e..597d51e 100644
--- a/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java
+++ b/packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java
@@ -408,34 +408,6 @@
                         MtpDocumentsProvider.AUTHORITY, "1")));
     }
 
-    @MediumTest
-    public void testPauseAndResume() throws Exception {
-        setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_FILE);
-        mMtpManager.addValidDevice(0);
-        mProvider.openDevice(0);
-        setupRoots(0, new MtpRoot[] { new MtpRoot(0, 0, "Device", "Storage", 0, 0, "")});
-
-        {
-            final Cursor cursor = mProvider.queryRoots(
-                    strings(DocumentsContract.Root.COLUMN_ROOT_ID));
-            cursor.moveToNext();
-            assertEquals(1, cursor.getInt(0));
-        }
-
-        mProvider.shutdown();
-        setupProvider(MtpDatabaseConstants.FLAG_DATABASE_IN_FILE);
-
-        {
-            // We can still fetch roots after relaunching the provider.
-            final Cursor cursor = mProvider.queryRoots(
-                    strings(DocumentsContract.Root.COLUMN_ROOT_ID));
-            assertEquals(1, cursor.getCount());
-            cursor.moveToNext();
-            assertEquals(1, cursor.getInt(0));
-            assertEquals(1, mMtpManager.getOpenedDeviceIds().length);
-        }
-    }
-
     private void setupProvider(int flag) {
         mDatabase = new MtpDatabase(getContext(), flag);
         mProvider = new MtpDocumentsProvider();