Ensure that binding state is false when handling dead binder

When a binding is disconnected, it is expected that binderDied() is
called after onBindingDied(). But, there exists a corner case where
the order is reversed. In this case, binderDied() cancels the
scheduling of MSG_UNBIND message, which blocks the chance of changing
mBinding value as false. As a results, mBinding value remains as true
even though the binding is disconnected. This would make the service
as unresponsive when a client tries reconnecting to the service.

This change ensures that mBinding becomes false even though binderDied()
is called before onBindingDied().

Bug: b/162753393
Test: compile & verify basic functions working
Change-Id: I66c5b130674a4355123fbac27f574d0d081e7b63
This commit is contained in:
Sanguk Jeon
2020-09-02 19:15:00 +09:00
committed by Todd Kennedy
parent 4e1e30e7bb
commit 761e81f6a8

View File

@@ -225,6 +225,7 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
if (mService != null) {
mService.asBinder().unlinkToDeath(this, 0);
}
mBinding = false;
mService = null;
mServiceDied = true;
cancelScheduledUnbind();