Improve odrefresh metrics collection.

- Add an explicit switch to OdrMetrics to make the logic more
  straightforward, and only enable it when compilation was done or an
  error occurred.
- Initialize status to kUnknown instead of kOK so that the status
  doesn't show "OK" when an unexpected error occurs.
- Explicitly set status to kOK if compilation succeeds.
- Add a new status: kDalvikCachePermissionDenied, to indicate that
  odrefresh Failed to access the dalvik-cache directory due to lack of
  permission.
- Set the status in many places where the status is missing.
- Before this change, odrefresh fails on the "kCheck" stage when trying
  to clean up the dalvik-cache directory if it doesn't have the
  permission to create the directory. This is weird. After this change,
  odrefresh will fail on the "kPreparation" stage instead.

Bug: 246534524
Test: atest ArtGtestsTargetChroot:OdrMetricsTest
Test: -
  1. Run `odrefresh --compile`.
  2. See `<stage_reached>60</stage_reached><status>1</status>`.
Test: -
  1. Make the SELinux context of the dalvik-cache directory wrong.
  2. Run `odrefresh --compile`.
  3. See `<stage_reached>20</stage_reached><status>8</status>`.
Test: -
  1. Run `odrefresh --compile`.
  2. Kill dex2oat.
  3. See `<stage_reached>40</stage_reached><status>4</status>`.
Change-Id: I1a239f7d59668fa763934c074e4bfc5ebcc3ee42
7 files changed