TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
31.52k stars 3.06k forks source link

Download does not work after Upgrade from CM12.1 to CM13 #143

Closed henrykratom closed 8 years ago

henrykratom commented 8 years ago

Hi there, your App isn't able to download nether Video nor Audiofiles after the Upgrade from CM12.1 (Android 5.1.1) to CM13 (Android 6.0)

I couldn't figure out what the problem was, but this bug is reproducible on different devices ranging from Moto-G to Nexus 5/6 all of which are running CM13.

Hope you will be able to figure out what the problem is, other than that you have created a hell of a great app that is easily the best regarding Youtube-Playback there is out .

Greetings, Henry Kratom

graingert commented 8 years ago

@henrykratom I get this issue on stock/OTA Android 6.0.1 on my Nexus 6P

graingert commented 8 years ago

The symptom is, you click on the "Download" button, choose "Audio" or "Video" and then the app closes the choice dialogue and does nothing else (no download)

42SK commented 8 years ago

I was able to reproduce this bug on a phone running Android 6.0 (CM13). Here's the log output:

E/android.support.v4.app.DialogFragment( 2876): Cant' create directory named /storage/emulated/0/NewPipe
W/DownloadManager(21630): Path appears to be invalid: /storage/emulated/0/NewPipe/Free software, free society: Richard Stallman at TEDxGeneva 2014.webm
E/DatabaseUtils(21630): Writing exception to parcel
E/DatabaseUtils(21630): java.lang.SecurityException: No permission to write to /storage/emulated/0/NewPipe/Free software, free society: Richard Stallman at TEDxGeneva 2014.webm: Neither user 10126 nor current proc
ess has android.permission.WRITE_EXTERNAL_STORAGE.
E/DatabaseUtils(21630):     at android.app.ContextImpl.enforce(ContextImpl.java:1450)
E/DatabaseUtils(21630):     at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1482)
E/DatabaseUtils(21630):     at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:681)
E/DatabaseUtils(21630):     at com.android.providers.downloads.DownloadProvider.checkFileUriDestination(DownloadProvider.java:724)
E/DatabaseUtils(21630):     at com.android.providers.downloads.DownloadProvider.insert(DownloadProvider.java:558)
E/DatabaseUtils(21630):     at android.content.ContentProvider$Transport.insert(ContentProvider.java:263)
E/DatabaseUtils(21630):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:163)
E/DatabaseUtils(21630):     at android.os.Binder.execTransact(Binder.java:453)
henrykratom commented 8 years ago

If by Dialouge you mean the "Video/Audio"-Dialogue and not a Dialogue about "what to download it with etc." than yes, this is exactly what i am experiencing.

I first thought it might be a permission-issue that didn't allow NewPipe to create the folder "NewPipe" but even after manually creating it there isn't anything happening.

42SK commented 8 years ago

The log output indicates that there is a problem with the WRITE_EXTERNAL_STORAGE permission. Perhaps this is somehow related to the new runtime permissions in Android 6.0?

42SK commented 8 years ago

The DownloadDialog.java class doesn't perform any permission requests. I guess that's the reason why it can't obtain the WRITE_EXTERNAL_STORAGE permission.

graingert commented 8 years ago

Enabling that permission in the permissions settings works On 7 Jan 2016 10:46, "42SK" notifications@github.com wrote:

The DownloadDialog.java class doesn't perform any permission requests https://developer.android.com/training/permissions/requesting.html. I guess that's the reason why it can't obtain the WRITE_EXTERNAL_STORAGE permission.

— Reply to this email directly or view it on GitHub https://github.com/theScrabi/NewPipe/issues/143#issuecomment-169626559.

graingert commented 8 years ago

That permission is now grouped under "Storage" and I believe "/emulated/0/" counts as external On 7 Jan 2016 10:49, "henrykratom" notifications@github.com wrote:

@42SK https://github.com/42SK But would "WRITE_EXTERNAL_STORAGE" only be related if you wanted to use well external storage such as the internal Microsd which would not include the Internal Storage on which afaik NewPipe points to?

— Reply to this email directly or view it on GitHub https://github.com/theScrabi/NewPipe/issues/143#issuecomment-169627111.

42SK commented 8 years ago

@henrykratom I'm not sure, but the log claims that the application cannot write to the internal storage due to the fact that it hasn't got the WRITE_EXTERNAL_STORAGE permission, so I assume that it is somehow required for the download procedure.

graingert commented 8 years ago

@henrykratom I just enabled it using the new Android 6 "App Permissions" (not sure if that's the same as the old AppOps)

henrykratom commented 8 years ago

@graingert @42SK

What do you mean by enabling it? By using the "AppOps" in the Settings and manually setting it to "enabled" or did you have to change anything of the internals of Android (like SDFIX)? I guess it would this could make sense, as DownloadDialog.java doesn't trigger a Dialog Android itself doesn't ask you if you want to allow it and therefore automatically denies it.

Who would have thought that it would be that trivial a workaround & fix.

Will test it out later

42SK commented 8 years ago

The Android developer site says:

[...] [The WRITE_EXTERNAL_STORAGE] permission is not required to read/write files in your application-specific directories [...]

I think that the WRITE_EXTERNAL_STORAGE permission is therefore required whenever you want to write to any other directory than your application's directory.

graingert commented 8 years ago

http://www.greenbot.com/article/2990078/android/how-to-toggle-app-permissions-in-android-marshmallow.html

graingert commented 8 years ago

ah in that case NewPipe should start downloading to it's Application directory then move the files to the requested directory after permission is granted

42SK commented 8 years ago

@graingert The question is: Where is NewPipe's application directory?

henrykratom commented 8 years ago

Tested and works.

@42K That explanation makes total sense NewPipes Application directory should be under /storage/emulated/0/Android/data/packagenameofnewpipe, i guess?

42SK commented 8 years ago

Perhaps one can use the getExternalFilesDir(String type) method to determine an appropriate download location.

42SK commented 8 years ago

We should either change the download directory or implement the runtime permissions.

42SK commented 8 years ago

I'll try to implement the runtime permissions so that one can easily enable the WRITE_EXTERNAL_STORAGE permission.

henrykratom commented 8 years ago

Hmm i just did a search, and it probably is under /data/data/org.schabi.newpipe/ Which would be off limits for a normal user.

You could probably indeed check if you find a Videofile if you select that as the Download Directory in the NewPipe Settings, but even viewing is off-limits for a non-root User, can't check it myself due to a non existent wifi-connection atm.

42SK commented 8 years ago

@henrykratom Alright, implementing runtime permissions is probably the better solution.