Avoid using flock on profiles.

After this change, instead of using a flock to ensure atomicity, the
profile is saved as a temporary file and moved to the final location.

Unfortunately, we have to keep the old implementation as a fallback
because the new implementation requires an SELinux policy rule that
allows apps to create profile files, which doesn't exist on old
platforms.

Bug: 249522285
Test: atest art_standalone_libprofile_tests
Test: atest art_standalone_runtime_tests:ProfileCompilationInfoTest
Test: -
  1. adb shell am start -S -W -c android.intent.category.LAUNCHER -a android.intent.action.MAIN com.google.android.youtube
  2. adb shell killall -USR1 com.google.android.youtube
  3. adb shell ls /data/misc/profiles/cur/0/com.google.android.youtube/primary.prof -l
  4. See the profile saved and the inode changed.
Test: -
  1. Do the same as above on a T device.
  2. See the profile saved and the inode not changed.
Change-Id: I02706651c6fbadc013ee595fdb1bc80ad8d27622
Merged-In: I02706651c6fbadc013ee595fdb1bc80ad8d27622
(cherry picked from commit 441b9c57434351c34d418d43c1c5aea78b40a57e)
4 files changed