Closed yegor-pelykh closed 3 years ago
@yegor-pelykh thanks, did you test it on devices prior to Android 10? I think i would prefer it if the change only applies to >= 10 🤔 below that it's not documented what t
is doing?
@hpoul I tested this version both for Android below 10 (works as before) and for Android above 10 (now works correctly, with the file being truncated if the new file size is less than the current one).
Also, as I quoted earlier in this post: https://github.com/hpoul/file_picker_writable/issues/23#issuecomment-851246614
I poked around the Android source code for different versions, and found that before Android 10, "w" and "wt" were explicitly being parsed exactly the same in ParcelFileDescriptor, resulting in a bitmask with both MODE_WRITE_ONLY and MODE_TRUNCATE to open the file. Then in Android 10, there was a change and 'w' and 't' are now parsed individually.
Therefore, it will work correctly on previous versions, as in those versions w
= wt
took place. The Android developers now have just made the modes clearer.
So why do you need an explicit condition about the current version of Android? I would say it's unnecessary.
thanks, but I feel more comfortable only using wt
only since android 10. see https://github.com/hpoul/file_picker_writable/issues/23#issuecomment-903306591 and https://github.com/hpoul/file_picker_writable/commit/d2d1da2924548280518da8ba350d4a8d6a45f75b
Needed for correct work in Android >= 10