Use a lock to serialize mutations to the Pre-reboot global state.

Previously, we used a single-threaded executor to serialize mutations.
This was feasible because PreRebootDexoptJob only exposed 3 APIs.
However, as we are adding more and more APIs, especially an API for
running Pre-reboot Dexopt synchronously, without going through the job
scheduler, it becomes harder and harder to make things correct with the
single-threaded executor approach. This CL reimplements serialization
with a lock.

Bug: 311377497
Test: atest ArtServiceTests:com.android.server.art.PreRebootDexoptJobTest --iterations 10
Change-Id: I8f61b979a29f4acc9de77336179d23e367b9c2c4
2 files changed