Fix BatterySaverStateMachineTest.

1. Disable actually posting a notification so that the test doesn't deal
with a SecurityException.
2. Verify that the notification is only posted when expected.
3. Put the state change from PENDING_STICKY_ON to OFF at the
beginning of the block. setStickyActive() calls putGlobalSetting(),
which ends up calling setSettingsLocked() which then goes back to
updateStateLocked(). Since this is all in the same thread, the test was
seeing the state machine post the notification twice. Putting the
state change at the beginning prevents the "second" notification.

Bug: 132620259
Test: atest com.android.server.power.batterysaver.BatterySaverStateMachineTest
Test: atest CtsBatterySavingTestCases
Change-Id: I1ceecc150bc57a37002d7de4ece09b503ec583c8
2 files changed