Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 699e33c8 authored by Mark Harman's avatar Mark Harman
Browse files

Update testing for scoped storage.

parent 329c3984
Loading
Loading
Loading
Loading
+240 −145

File changed.

Preview size limit exceeded, changes collapsed.

+3 −4
Original line number Diff line number Diff line
@@ -2554,6 +2554,8 @@ public class ImageSaver extends Thread {
                    else {
                        broadcastSAFFile(saveUri, request.image_capture_intent);
                    }

                    main_activity.test_last_saved_imageuri = saveUri;
                }
            }
        }
@@ -2715,10 +2717,7 @@ public class ImageSaver extends Thread {
        if( MyDebug.LOG )
            Log.d(TAG, "broadcastSAFFile");
        StorageUtils storageUtils = main_activity.getStorageUtils();
        String real_file_path = storageUtils.broadcastUri(saveUri, true, false, true, image_capture_intent);
        if( real_file_path != null ) {
            main_activity.test_last_saved_image = real_file_path;
        }
        storageUtils.broadcastUri(saveUri, true, false, true, image_capture_intent);
    }

    /** As setExifFromFile, but can read the Exif tags directly from the jpeg data, and to a file descriptor, rather than a file.
+2 −1
Original line number Diff line number Diff line
@@ -186,7 +186,8 @@ public class MainActivity extends Activity {
    public volatile boolean test_low_memory;
    public volatile boolean test_have_angle;
    public volatile float test_angle;
    public volatile String test_last_saved_image;
    public volatile Uri test_last_saved_imageuri; // uri of last image; set if using scoped storage OR using SAF
    public volatile String test_last_saved_image; // filename (including full path) of last image; set if not using scoped storage nor using SAF (i.e., writing using File API)
    public static boolean test_force_supports_camera2; // okay to be static, as this is set for an entire test suite
    public volatile String test_save_settings_file;

+1 −4
Original line number Diff line number Diff line
@@ -2394,10 +2394,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {
        else {
            if( uri != null ) {
                // see note in onPictureTaken() for where we call broadcastFile for SAF photos
                String real_file_path = storageUtils.broadcastUri(uri, false, true, true, false);
                if( real_file_path != null ) {
                    main_activity.test_last_saved_image = real_file_path;
                }
                storageUtils.broadcastUri(uri, false, true, true, false);
                done = true;
            }
        }
+4 −7
Original line number Diff line number Diff line
@@ -270,9 +270,8 @@ public class StorageUtils {
    }

    /** Wrapper for broadcastFile, when we only have a Uri (e.g., for SAF)
     * @return If non-null, this contains the path of the file we found for the Uri.
     */
    public String broadcastUri(final Uri uri, final boolean is_new_picture, final boolean is_new_video, final boolean set_last_scanned, final boolean image_capture_intent) {
    public void broadcastUri(final Uri uri, final boolean is_new_picture, final boolean is_new_video, final boolean set_last_scanned, final boolean image_capture_intent) {
        if( MyDebug.LOG )
            Log.d(TAG, "broadcastUri: " + uri);
        /* We still need to broadcastFile for SAF for two reasons:
@@ -293,7 +292,6 @@ public class StorageUtils {
            //Uri media_uri = broadcastFileRaw(real_file, current_date, location);
            //announceUri(media_uri, is_new_picture, is_new_video);
            broadcastFile(real_file, is_new_picture, is_new_video, set_last_scanned);
            return (real_file==null ? null : real_file.getAbsolutePath());
        }
        else if( !image_capture_intent ) {
            if( MyDebug.LOG )
@@ -301,10 +299,9 @@ public class StorageUtils {
            // shouldn't do this for an image capture intent - e.g., causes crash when calling from Google Keep
            announceUri(uri, is_new_picture, is_new_video);
        }
        return null;
    }

    boolean isUsingSAF() {
    public boolean isUsingSAF() {
        // check Android version just to be safe
        if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
@@ -328,7 +325,7 @@ public class StorageUtils {
    }

    // only valid if isUsingSAF()
    private Uri getTreeUriSAF() {
    public Uri getTreeUriSAF() {
        String folder_name = getSaveLocationSAF();
        return Uri.parse(folder_name);
    }
@@ -600,7 +597,7 @@ public class StorageUtils {
     * See https://developer.android.com/guide/topics/providers/document-provider.html and
     * http://stackoverflow.com/questions/5568874/how-to-extract-the-file-name-from-uri-returned-from-intent-action-get-content .
     */
    String getFileName(Uri uri) {
    public String getFileName(Uri uri) {
        if( MyDebug.LOG ) {
            Log.d(TAG, "getFileName: " + uri);
            Log.d(TAG, "uri has path: " + uri.getPath());