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

Commit e4dbf269 authored by Mark Harman's avatar Mark Harman
Browse files

Fix crash when selecting "Downloads" with SAF.

parent 9205276c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ Version 1.43.1 (Work in progress)

FIXED   Crash when selecting antibanding setting on devices with no support for antibanding; this
        option is now removed on such devices.
FIXED   Fixed some crashes.
FIXED   Crash when using Storage Access Framework to select "Downloads" on Android 8+.
FIXED   Fixed some other crashes.

Version 1.43 (2018/04/10)

+21 −10
Original line number Diff line number Diff line
@@ -368,6 +368,7 @@ public class StorageUtils {
			}
		}
		else if( "com.android.providers.downloads.documents".equals(uri.getAuthority()) ) {
			if( !is_folder ) {
				final String id = DocumentsContract.getDocumentId(uri);
				final Uri contentUri = ContentUris.withAppendedId(
						Uri.parse("content://downloads/public_downloads"), Long.parseLong(id));
@@ -376,6 +377,16 @@ public class StorageUtils {
				if( filename != null )
					file = new File(filename);
			}
			else {
				if( MyDebug.LOG )
					Log.d(TAG, "downloads uri not supported for folders");
				// This codepath can be reproduced by enabling SAF and selecting Downloads.
				// DocumentsContract.getDocumentId() throws IllegalArgumentException for
				// this (content://com.android.providers.downloads.documents/tree/downloads).
				// If we use DocumentsContract.getTreeDocumentId() for folders, it returns
				// "downloads" - not clear how to parse this!
			}
		}
		else if( "com.android.providers.media.documents".equals(uri.getAuthority()) ) {
			final String docId = DocumentsContract.getDocumentId(uri);
			final String[] split = docId.split(":");