Truncate export PCAP file on overwrite
Task/Issue URL: Related to https://github.com/duckduckgo/Android/pull/4371
Description
In Android 10/11, the "w" write mode no longer truncates the file during an overwrite. More details about this workaround can be found at https://issuetracker.google.com/issues/180526528
During the fix for https://github.com/duckduckgo/Android/issues/3069 all other instances of ContentResolver.open... were reviewed to see if they also used the "w" mode. The only other one was for exporting PCAP files as it used contentResolver.openOutputStream(uri) which is a convenience function that calls contentResolver.openOutputStream(uri, "w").
Steps to test this PR
- Export a PCAP file and overwrite any existing file of substantial size, the exported PCAP file should now be truncated and there should no longer be trailing bytes of the overwritten file.
@karlenDimla can you confirm this works? Assigning it to you, feel free to close.