Replace the static version of GetOptimizationStatus with a factory.

The static version of GetOptimizationStatus is not extensible. We need a
function that can be used in both `GetOptimizationStatus` and
`GetDexOptNeeded` use cases.

Also:
- Add DCHECK to GetOptimizationStatus to make sure it doesn't return
  unexpected values.

Bug: 229268202
Test: m test-art-host-gtest-art_runtime_tests
Change-Id: I3c6401c9d52e0766766e3ae7ee19c62af5e35a4a
Merged-In: I71d546ec25703b7ffe3a6f20de3af1cb72f3fc19
3 files changed