fix: Resolve EACCESS error in special cases
Sometimes, when there is an attempt to patch an App, that APK is only marked as r-x and not rwx.
This can cause the patch to fail, as it cannot read the file after copying it to patcher/tmp-.../in.apk
This PR Fixes that issue (as far as i can tell; tested with brand new install of revanced manager, with and without patch. To Verify)
Cause: Dart/Flutter had no built in permission management system, and the Copy operation of Dart copies the attributes of the original file, including read/write perms.
Why Missing write perms cause File(path) to fail, even when it could have been read-only, i do not know, and it would probably need to be checked in java/kotlin docs.
FileReader instead of File is probably a better idea.
Why is Manager copying the file and trying to write to it in the first place?
the "in.apk" is copied to "out.apk". No reading or writing in that case. Could replace the in.apk File with a FoleReader.
Would still need to fix the perms for "out.apk" after patching is complete though
Why is Manager copying the file and trying to write to it in the first place?
So to answer this, it isn't writing to it at all. Hut java.io.File seems to be unable to open a file unless that file as a write flag set
Oh, actually, it seems the backtrace was not accurate due to release mode
patcherResult.applyTo(inFile)
This seems to be the culprit, it applies the patches to in.apk, then signs it and spits out out.apk
pog