updating CallLogTest to be allow fileNotFound exceptions

AUTO targets were failing on some CallLogTests related to a recent
Security Bug fix.  The test failures were due to both
the data/data directory being inaccessible (SE) and the file passed
to ContentResolver not existing.

fix allows the fileNotFound error to pass the test.

bug: 230987259
bug:  219015884 (root patch)

Test: 3 modified tests
Change-Id: I0a180211e09211b317d3f594831c65813b73c897
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/CallLogTest.java b/tests/tests/provider/src/android/provider/cts/contacts/CallLogTest.java
index c2a2795..7c37f5e 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/CallLogTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/CallLogTest.java
@@ -78,7 +78,7 @@
     // Test call composer URI that throws Security Exception
     private static final Uri INVALID_CALL_LOG_URI = Uri.parse(
             "content://call_log/call_composer/%2fdata%2fdata%2fcom.android.providers"
-                    + ".contacts%2fshared_prefs%2fContactsUpgradeReceiver.xml");
+                    + ".contacts%2fdatabases%2fcontacts2.db");
     // Test Failure Error
     private static final String TEST_FAIL_DID_NOT_TRHOW_SE =
             "fail test because Security Exception was not throw";
@@ -213,47 +213,58 @@
 
     /**
      * Tests scenario where an app gives {@link ContentResolver} a file to open that is not in the
-     * Call Log directory.
+     * Call Log directory. Will throw a Security Exception if the file passed is found && a valid
+     * ParcelFileDescriptor is returned.
      */
     public void testOpenFileOutsideOfScopeThrowsException() throws FileNotFoundException {
         try {
             Context context = getInstrumentation().getContext();
             ContentResolver resolver = context.getContentResolver();
-            resolver.openFile(INVALID_CALL_LOG_URI, "w", null);
-            // previous line should throw exception
-            fail(TEST_FAIL_DID_NOT_TRHOW_SE);
-        } catch (SecurityException e) {
-            assertNotNull(e.toString());
+            ParcelFileDescriptor fileDescriptor =
+                    resolver.openFile(INVALID_CALL_LOG_URI, "w", null);
+            // only fail the test if the file is found
+            if (fileDescriptor != null) {
+                // invalid file found instead of hitting SE.  manually fail the test.
+                fail(TEST_FAIL_DID_NOT_TRHOW_SE);
+            }
+        } catch (SecurityException se) {
+            assertNotNull(se.toString());
         }
     }
 
     /**
-     * Tests scenario where an app gives {@link ContentResolver} a file to delete that is not in the
-     * Call Log directory.
+     * Tests scenario where an app gives {@link ContentResolver} {@link ContentValues} to delete
+     * in a table that is not owned by the Call Log directory.
      */
     public void testDeleteFileOutsideOfScopeThrowsException() {
         try {
             Context context = getInstrumentation().getContext();
             ContentResolver resolver = context.getContentResolver();
-            resolver.delete(INVALID_CALL_LOG_URI, "w", null);
-            // previous line should throw exception
-            fail(TEST_FAIL_DID_NOT_TRHOW_SE);
+            int numFilesDeleted =
+                    resolver.delete(INVALID_CALL_LOG_URI, "w", null);
+            if (numFilesDeleted > 0) {
+                // resolver.delete should throw an SE instead of deleting file
+                fail(TEST_FAIL_DID_NOT_TRHOW_SE);
+            }
         } catch (SecurityException e) {
             assertNotNull(e.toString());
         }
     }
 
     /**
-     * Tests scenario where an app gives {@link ContentResolver} a file to insert outside the
-     * Call Log directory.
+     * Tests scenario where an app gives {@link ContentResolver} {@link ContentValues} to insert
+     * in a table that is not owned by the Call Log directory.
      */
     public void testInsertFileOutsideOfScopeThrowsException() {
         try {
             Context context = getInstrumentation().getContext();
             ContentResolver resolver = context.getContentResolver();
-            resolver.insert(INVALID_CALL_LOG_URI, new ContentValues());
-            // previous line should throw exception
-            fail(TEST_FAIL_DID_NOT_TRHOW_SE);
+            Uri uri =
+                    resolver.insert(INVALID_CALL_LOG_URI, new ContentValues());
+            if (uri != null) {
+                // resolver.insert(...) should throw an SE instead of inserting ContentValues
+                fail(TEST_FAIL_DID_NOT_TRHOW_SE);
+            }
         } catch (SecurityException e) {
             assertNotNull(e.toString());
         }