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
2 files changed
tree: 89af8d34859c78b2f78403a0588610a8d12ad313
  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. media-router/
  13. obd2-lib/
  14. procfs-inspector/
  15. service/
  16. tests/
  17. tools/
  18. user/
  19. vehicle-hal-support-lib/
  20. .clang-format
  21. .gitignore
  22. Android.mk
  23. CleanSpec.mk
  24. OWNERS
  25. PREUPLOAD.cfg
  26. 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.