Fix async behavior and address possible race conditions.
1. Don't release the lock until we've fully processed an app or user
removal so that JS stays in a consistent state outside of the lock.
Before, we released the lock between cancelling jobs and telling
controllers of the removal, so there was a short period where JS was
internally inconsistent and an app scheduling a job could land in JS's
inconsistency.
2. Actually lock around methods that require the lock be held.
Bug: 183921387
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I440e3c7753d119e025b0359d2b35bec90fa19628
2 files changed