[Unit test] Shorten CarPowerManagementTest execution time

IRL we poll every 2 seconds for changes in the power state. To
speed up the testing, do this every millisecond. Also, some
tests wait to verify that a transition did NOT occur. Reduce the
time that we wait for that.

This CL also fixes two issues that contributed to flakiness:
 - Ensures consistency in CarPowerManagementTest between the list
   of received power states and the semaphore that indicates that
   a new state has been received
 - Adds a null check to CarPowerManager

Fixes: 130378693
Test: This updates CarPowerManagementTest
Change-Id: I54a07dcf852707247c6bf2ba81b2c3418cf5815a
4 files changed
tree: bd5d10e526de35ec90636855afbed74e57b1fb4d
  1. car-bugreportd/
  2. car-default-input-service/
  3. car-lib/
  4. car-maps-placeholder/
  5. car-systemtest-lib/
  6. car-test-lib/
  7. car-usb-handler/
  8. car_product/
  9. computepipe/
  10. EncryptionRunner/
  11. evs/
  12. experimental/
  13. FrameworkPackageStubs/
  14. obd2-lib/
  15. procfs-inspector/
  16. service/
  17. tests/
  18. tools/
  19. user/
  20. vehicle-hal-support-lib/
  21. watchdog/
  22. .clang-format
  23. .gitignore
  24. Android.mk
  25. CleanSpec.mk
  26. CPPLINT.cfg
  27. OWNERS
  28. PREUPLOAD.cfg
  29. README.md
README.md

Native (C++) code format is required to be compatible with .clang-format file. Run

git clang-format --style=file --extension='h,cpp,cc' HEAD~

Note that clang-format is not desirable for Android java files. Therefore the command line above is limited to specific extensions.