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

Commit d504ab14 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

media.MediaPlayer: don't check file-existence for URI-s with scheme

setDataSource can be called with URI-s as well as with file paths.
Check file-existence only for file:// URI-s as well as URI-s
without scheme (which are assumed to be paths).

Bug: 17109022
Change-Id: I70f16a4f614dcef0b47fa264cf708473036cef4e
parent a66c40bf
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -1049,8 +1049,17 @@ public class MediaPlayer implements SubtitleController.Listener
    private void setDataSource(String path, String[] keys, String[] values)
            throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
        final Uri uri = Uri.parse(path);
        if ("file".equals(uri.getScheme())) {
        final String scheme = uri.getScheme();
        if ("file".equals(scheme)) {
            path = uri.getPath();
        } else if (scheme != null) {
            // handle non-file sources
            nativeSetDataSource(
                MediaHTTPService.createHttpServiceBinderIfNecessary(path),
                path,
                keys,
                values);
            return;
        }

        final File file = new File(path);
@@ -1060,18 +1069,8 @@ public class MediaPlayer implements SubtitleController.Listener
            setDataSource(fd);
            is.close();
        } else {
            _setDataSource(path, keys, values);
        }
            throw new IOException("setDataSource failed.");
        }

    private void _setDataSource(
        String path, String[] keys, String[] values)
        throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
        nativeSetDataSource(
                MediaHTTPService.createHttpServiceBinderIfNecessary(path),
                path,
                keys,
                values);
    }

    private native void nativeSetDataSource(