
Once a controller bound to a MediaSessionService unbinds, this service may be destroyed immediately if this was the last bound controller and the service isn't started in the foreground. At the time of releasing the controller, there may still be pending commands that need to be handled by the session service. These commands may cause the session service to post a foreground notification to keep it alive. So to avoid the destruction of the service while these commands are still handled, we need to keep the controller bound. We also add a timeout in case the session tasks are never completed by the session implementation. In case the controller is destroyed, the unbinding happens automatically by the system. PiperOrigin-RevId: 463802220
Session test module
Tests cross-process use of the session module. To run the tests:
- Prepare a device (either an emulator or a real device) to run the tests on.
- Run
./gradlew :test-session-current:cAT