TeamNewPipe / NewPipe

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

Unable to import database since version 0.21.6 #6783

Closed andrewferguson closed 3 years ago

andrewferguson commented 3 years ago

Checklist

Steps to reproduce the bug

  1. Export a .zip file of the settings / history from NewPipe by going to Settings > Content > Export database.
  2. Attempt to import this .zip file back into NewPipe by going to Settings > Content > Import database.

Actual behaviour

During the import stage, rather than allowing the .zip file containing the exported DB to be selected, the file picker instead goes inside the .zip file, showing the exported files inside the zip file. Naturally, selecting one of these files results in the import failing as it is expecting a .zip file.

Expected behaviour

During the import stage, what should happen is that the file picker should allow the .zip file to be selected, to allow the import to succeed.

Screenshots/Screen recordings

Below is a screen recording of me:

  1. Exporting the settings to a .zip
  2. Attempting to import the .zip back into NewPipe. When the file picker does not let me select the .zip and instead goes into the .zip, I attempt to select one of the files inside the .zip in case that works, but (inevitably) this leads to a crash during import.

https://user-images.githubusercontent.com/13520045/127225626-f80be85a-af97-417d-b08e-1fcb71ab1f37.mp4

Device info

Possible cause of the issue

My suspicion is that this issue is caused by the upgrade to the Storage Access Framework as part of 0.21.6.

How to get past the issue

The easiest way to get past the issue is to downgrade to release 0.21.5, where importing from a .zip still works fine. From there you can import the settings / history, then upgrade back to the latest release (since settings and history are preserved when upgrading through F-Droid repositories).

XiangRongLin commented 3 years ago

My guess that the file picker of your ROM is doing something wrong, since it works for me on v0.20.8 on an android 10 phone and an android 4.4 emulator

Can you try out the apk in https://github.com/TeamNewPipe/NewPipe/pull/6820 and see if that changes anything?

ezavod commented 3 years ago

Have the same problem with LineageOS 14.1 (Android 7.1.2) and the default file manager (com.android.documentsui version 7.1.2). I believe it's a problem with the file manager (see workaround). @XiangRongLin Unfortunately the PR does not fix this issue. The contents of the zip are grayed out instead, that's it.

Workaround: I was able to import the database with "Material Files". After installing this file manager one gets asked which program should be used to import the database. Choose "Material Files" instead of the default system file manager. Note: Most other file managers do not work. (I guess they have to support the file open intent?)

XiangRongLin commented 3 years ago

Can you try

  1. out if this apk makes any difference app-debug.zip It's using ACTION_GET_CONTENT instead of ACTION_OPEN_DOCUMENT which should be the correct value according to the doc, since we only want a one time permission to read the file https://developer.android.com/guide/topics/providers/document-provider.html#client
  2. if you can long-click on the zip to select it and then press a "select" button or something of the like
ezavod commented 3 years ago

Thanks for your suggestions. It seems that the file manager does not recognize zip files as files but as directories instead. So it could be a bug in my particular rom (very outdated and only for fooling around with android dev stuff).

Regarding 2: Long-pressing the zip and then tapping the appearing 'open' button works in the original app.

Regarding 1: The new apk does not make a difference. The file manager still enters the zip file and one can select both contained files individually. Interestingly, long-pressing the zip and then opening crashes with the new apk:

Log ``` ------------------------------------- java.lang.SecurityException: Permission Denial: writing com.android.providers.downloads.DownloadStorageProvider uri content://com.android.providers.downloads.documents/document/408 from pid=6980, uid=10067 requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission() at android.os.Parcel.readException(Parcel.java:1692) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:146) at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:621) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1004) at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:839) at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:793) at us.shandian.giga.io.FileStreamSAF.(FileStreamSAF.java:32) at org.schabi.newpipe.streams.io.StoredFileHelper.getStream(StoredFileHelper.java:195) at org.schabi.newpipe.util.ZipHelper.isValidZipFile(ZipHelper.java:109) at org.schabi.newpipe.settings.ContentSettingsFragment.importDatabase(ContentSettingsFragment.java:213) at org.schabi.newpipe.settings.ContentSettingsFragment.lambda$requestImportPathResult$3$ContentSettingsFragment(ContentSettingsFragment.java:187) at org.schabi.newpipe.settings.-$$Lambda$ContentSettingsFragment$u198xmUumHODbN7IPNqi_vwsQvM.onClick(lambda) at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6186) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) ------------------------------------- ```
Stypox commented 3 years ago

I'd close this: this issue has been reported before, but there's nothing we can do about it as it's the file manager's duty to display the correct options, and no workarounds are doable.

Regarding 2: Long-pressing the zip and then tapping the appearing 'open' button works in the original app.

You mean that it works, at least that way?

The easiest way to get past the issue is to downgrade to release 0.21.5

You can also just disable SAF in download settings

ezavod commented 3 years ago

You mean that it works, at least that way?

Yes, that worked for me.