FUSE: open and close consult MediaProvider first

open now operation checks with MediaProvider if the given package can open
the given file before actually opening the file. The actual file opening
happens in the native level in FuseDaemon; this saves us the burden of
translating POSIX flags to something that MediaProvider and
ParcelFileDescriptor can understand and also saves the overhead of
opening a ParcelFileDescriptor.

close operation notifies MediaProvider that a file has been closed only
if the file was open for write. MediaProvider then might trigger a
(Modern)MediaScanner scan if the file is in a scanned directory.

Also, fixes the bug where MediaProviderWrapper d'tor hangs while waiting
for JNI thread to terminate (which it never does).

Test: manual - echo and cat work
Test: create a large file and observe it in external.db with the right
size
Fixes: 142807069
Bug: 142863102
Fixes: 143473023

Change-Id: I4128b8508b2bcb32ea6188e112c4894801b41487
4 files changed