Add stop method to backup handler thread.

This manually cherry picks ag/8713360 into master. I had to do a manual
cherry pick as the cherry pick from gerrit fails with:
"Could not perform action: Cannot create new patch set of change 8677635
because it is abandoned"

Currently we call .quit() on the underlying thread which will cause all
messages to stop being processed. This has the side effect that, because
the backup system is a state machine where the state transitions are
messages, the message to transition into a state where the WakeLock is
released may not occur when a user is torn down.

This change adds a stop method we can call instead of .quit() on the
thread which drops any remaining messages and then releases the
WakeLock.

We also wrap the wakelock acquire/release calls to prevent any acquire/release on
the underlying wakelock after a quit. For the acquire, this avoids a non-released
wakelock and for the release, this avoids a runtime exception which can happen
when we release a released wakelock

Test: atest CtsBackupTestCases CtsBackupHostTestCases
Test: m RunBackupFrameworksServicesRoboTests && atest RunBackupFrameworksServicesRoboTests
Bug: 136264323
Change-Id: Ic8742bf01a0ff71bd57dd73b01a423d3432bf7b2
7 files changed