Implement onBindingDied callback to catch client crashes.

This CL makes the following changes in binding behavior:
- onBindingDied is implemented to schedule a rebind
  - this resolves the case where a client crashes before the connection
    is established
- rebind is split into scheduleRebind and doRebind operations
  - scheduleRebind will only schedule a task if there isn't one pending
  - doRebind only rebinds if the service did not reconnect on its own
  - unbinding the ServiceConnection is deferred until doRebind

The resulting behavior is such that the first few crashes of a client will
be re-bound faster (as ActivityManager will restart it after 2, 4, and 8
seconds), but after the configured delay the client manager will then
unbind + bind, retaining the existing behavior of capping the backoff.

Bug: 137656857
Test: Manual testing against P.car and Q
Test: Updated VmsClientManagerTest
Test: atest AndroidCarApiTest CarServiceTest CarServiceUnitTest
Change-Id: I1372eae1b0b7fcbe77f982e59236fff71df13356
(cherry picked from commit 8d64eb3f5fe522ac7ced070b789c9c0ced79a8f7)
2 files changed
tree: 972fe8dfec4ca6345d8320d3abe6bdec8cb69925
  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. EncryptionRunner/
  10. evs/
  11. FrameworkPackageStubs/
  12. obd2-lib/
  13. procfs-inspector/
  14. service/
  15. tests/
  16. tools/
  17. user/
  18. vehicle-hal-support-lib/
  19. .clang-format
  20. .gitignore
  21. Android.mk
  22. CleanSpec.mk
  23. OWNERS
  24. PREUPLOAD.cfg
  25. 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.