Delay suspending if we aren't quite ready to do it.

We need a helper to suspend the system. If we are asked to suspend before
we have that helper, delay the request, to allow us to receive the helper.

At start up, SystemStateInterface.java receives a helper that it uses when
someone calls enterDeepSleep(), which tells SystemStateInterface to suspend.
If enterDeepSleep() is called before the helper has been received, we cannot
suspend immediately. In this case, delay the 'suspend' request to allow time
to get the helper.

If the helper is not received in 10 seconds, this code gives up on suspending
and shuts down the system.

Fixes: 142699725
Test: Created SystemStateInterfaceTest.java
Change-Id: Idbc18dcafde4657a5494e82f6b0900f3637c2fad
(cherry picked from commit f520fbf1c2354317937ac65eea757a1f173f73ff)
3 files changed
tree: d0a0f666eef2a98643c1d65b9109a6b815809602
  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. OWNERS
  27. PREUPLOAD.cfg
  28. 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.