Merge "Adjusted precision of refocus test"
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/MediaStoreSaver.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/MediaStoreSaver.java
index 6a1ed16..11ecec8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/MediaStoreSaver.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/MediaStoreSaver.java
@@ -37,23 +37,23 @@
                                        String imageName,
                                        Context mContext) {
         File picDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
-
-        if (!picDir.exists()) {
+        if (!picDir.exists() && picDir.mkdirs()) {
             // The Pictures directory does not exist on an x86 emulator
             picDir = mContext.getFilesDir();
         }
 
         File dir = new File(picDir, folderName);
-        dir.mkdirs();
+        if (!dir.exists() && !dir.mkdirs()) {
+            return "";
+        }
 
         try {
             File file = File.createTempFile(imageName, ".png", dir);
             FileOutputStream fOut = new FileOutputStream(file);
             bitmap.compress(Bitmap.CompressFormat.PNG, 0, fOut);
-            System.out.println("saved image: " + file.getAbsolutePath());
+            android.util.Log.v("RefocusTest", "saved image: " + file.getAbsolutePath());
             fOut.flush();
             fOut.close();
-            MediaStorageScan(mContext, file);
             return file.getAbsolutePath();
         } catch (FileNotFoundException e) {
             e.printStackTrace();
@@ -63,22 +63,4 @@
 
         return "";
     }
-
-    /*
-     * Refresh image files to view them on computer
-     */
-    private static void MediaStorageScan(Context context, final File file) {
-        final Uri fileUri = Uri.fromFile(file);
-
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
-            context.sendBroadcast(new Intent("android.hardware.action.NEW_PICTURE", fileUri));
-        }
-
-        context.sendBroadcast(new Intent("com.android.camera.NEW_PICTURE", fileUri));
-
-        final Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
-        intent.setData(fileUri);
-        context.sendBroadcast(intent);
-    }
-
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java b/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
index 706296b..4ff9f22 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/refocus/RefocusTest.java
@@ -35,26 +35,26 @@
  */
 public class RefocusTest extends RSBaseCompute {
     /**
-     * Test the orignal and current refocus code
+     * Test the orignal refocus code
      */
     public void testOriginalRefocus() {
         refocus(RenderScriptTask.script.f32, Double.POSITIVE_INFINITY);
     }
 
     /**
-     * Test the orignal and current refocus code
+     * Test the new refocus code
      */
     public void testNewRefocus() {
         // The new implementation may run on a GPU using relaxed floating point
         // mathematics. Hence more relaxed precision requirement.
-        refocus(RenderScriptTask.script.d1new, 50);
+        refocus(RenderScriptTask.script.d1new, 45);
     }
 
     /**
      * Test a refocus operator against the refocus_reference image
-     * @param d1new which version of refocus to run
+     * @param impl version of refocus to run
      */
-    private void refocus(RenderScriptTask.script d1new, double minimumPSNR) {
+    private void refocus(RenderScriptTask.script impl, double minimumPSNR) {
         Context ctx = getContext();
 
         RenderScript rs = RenderScript.create(ctx);
@@ -70,7 +70,7 @@
         DepthOfFieldOptions current_depth_options = new DepthOfFieldOptions(current_rgbz);
         RsTaskParams rsTaskParam = new RsTaskParams(rs, current_depth_options);
 
-        RenderScriptTask renderScriptTask = new RenderScriptTask(rs, d1new);
+        RenderScriptTask renderScriptTask = new RenderScriptTask(rs, impl);
         Bitmap outputImage = renderScriptTask.applyRefocusFilter(rsTaskParam.mOptions);
 
         Bitmap expectedImage = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.expected_output);