CTS changes for MemoryFile constructor throwing IOException.

This change updates the CTS tests for MemoryFile
to catch IOExceptions thrown by the MemoryFile constructor.

Before, the MemoryFile constructor could throw IOException, but did not
declare this fact, see http://b/issue?id=1881829
This has now been fixed in
https://android-git.corp.google.com/g/2618
Unfortunately that change must be submitted together with this one in order
not to break the build.
diff --git a/tests/tests/os/src/android/os/cts/MemoryFileTest.java b/tests/tests/os/src/android/os/cts/MemoryFileTest.java
index bd859c0..1a062bc 100644
--- a/tests/tests/os/src/android/os/cts/MemoryFileTest.java
+++ b/tests/tests/os/src/android/os/cts/MemoryFileTest.java
@@ -53,8 +53,12 @@
         )
     })
     public void testConstructor() {
-        // new the MemoryFile instance
-        new MemoryFile("Test File", 1024);
+        try {
+            // new the MemoryFile instance
+            new MemoryFile("Test File", 1024);
+        } catch (IOException e) {
+            fail(e.getMessage());
+        }
     }
 
     @TestTargetNew(
@@ -64,11 +68,11 @@
         args = {byte[].class, int.class, int.class, int.class}
     )
     public void testWriteBytes() {
-        // new the MemoryFile instance
-        mMemoryFile = new MemoryFile("Test File", 1024);
-
         byte[] data = new byte[512];
         try {
+            // new the MemoryFile instance
+            mMemoryFile = new MemoryFile("Test File", 1024);
+
             mMemoryFile.writeBytes(data, 0, 0, 512);
         } catch (IOException e) {
             fail(e.getMessage());
@@ -113,12 +117,12 @@
         )
     })
     public void testGetOutputStream() {
-        // new the MemoryFile instance
-        mMemoryFile = new MemoryFile("Test File", 1024);
-        OutputStream out = mMemoryFile.getOutputStream();
-        assertNotNull(out);
         byte[] bs = new byte[] { 1, 2, 3, 4 };
         try {
+            // new the MemoryFile instance
+            mMemoryFile = new MemoryFile("Test File", 1024);
+            OutputStream out = mMemoryFile.getOutputStream();
+            assertNotNull(out);
             out.write(bs);
         } catch (IOException e) {
             fail(e.getMessage());
@@ -152,10 +156,10 @@
     @ToBeFixed(bug = "1537041", explanation = "When set mAllowPurging to true, writeBytes"
                      + "should throw out exception")
     public void testAllowPurging() {
-        // new the MemoryFile instance
-        mMemoryFile = new MemoryFile("Test File", 1024);
-
         try {
+            // new the MemoryFile instance
+            mMemoryFile = new MemoryFile("Test File", 1024);
+
             assertFalse(mMemoryFile.allowPurging(true));
             byte[] data = new byte[512];
             try {
@@ -185,18 +189,33 @@
         args = {}
     )
     public void testLength() {
-        // new the MemoryFile instance
-        mMemoryFile = new MemoryFile("Test File", 1024);
-        assertEquals(1024, mMemoryFile.length());
+        try {
+            mMemoryFile = new MemoryFile("Test File", 1024);
+            assertEquals(1024, mMemoryFile.length());
+        } catch (IOException e) {
+            fail(e.getMessage());
+        }
 
-        mMemoryFile = new MemoryFile("Test File", 512);
-        assertEquals(512, mMemoryFile.length());
+        try {
+            mMemoryFile = new MemoryFile("Test File", 512);
+            assertEquals(512, mMemoryFile.length());
+        } catch (IOException e) {
+            fail(e.getMessage());
+        }
 
-        mMemoryFile = new MemoryFile("Test File", Integer.MAX_VALUE);
-        assertEquals(Integer.MAX_VALUE, mMemoryFile.length());
+        try {
+            mMemoryFile = new MemoryFile("Test File", Integer.MAX_VALUE);
+            assertEquals(Integer.MAX_VALUE, mMemoryFile.length());
+        } catch (IOException e) {
+            fail(e.getMessage());
+        }
 
-        mMemoryFile = new MemoryFile("Test File", Integer.MIN_VALUE);
-        assertEquals(Integer.MIN_VALUE, mMemoryFile.length());
+        try {
+            mMemoryFile = new MemoryFile("Test File", Integer.MIN_VALUE);
+            assertEquals(Integer.MIN_VALUE, mMemoryFile.length());
+        } catch (IOException e) {
+            fail(e.getMessage());
+        }
     }
 
     @TestTargetNew(
@@ -206,10 +225,10 @@
         args = {byte[].class, int.class, int.class, int.class}
     )
     public void testReadBytes() {
-        // new the MemoryFile instance
-        mMemoryFile = new MemoryFile("Test File", 1024);
-
         try {
+            // new the MemoryFile instance
+            mMemoryFile = new MemoryFile("Test File", 1024);
+
             byte[] data = new byte[] { 1, 2, 3, 4 };
             mMemoryFile.writeBytes(data, 0, 0, data.length);
             byte[] gotData = new byte[4];
@@ -253,10 +272,9 @@
     )
     @ToBeFixed(bug="1398215", explanation="the file still can be read even after it closes.")
     public void testClose() {
-        // new the MemoryFile instance
-        mMemoryFile = new MemoryFile("Test File", 1024);
-
         try {
+            // new the MemoryFile instance
+            mMemoryFile = new MemoryFile("Test File", 1024);
             byte[] data = new byte[512];
             mMemoryFile.writeBytes(data, 0, 0, 128);
         } catch (IndexOutOfBoundsException e) {