josesamuel / remoter

Remoter - An alternative to Android AIDL for Android Remote IPC services using plain java interfaces
Apache License 2.0
84 stars 14 forks source link

Needs to unbind on binding failure #9

Closed herriojr closed 3 years ago

herriojr commented 3 years ago

See: https://developer.android.com/guide/components/bound-services#Binding

josesamuel commented 3 years ago

Not sure what you mean, Remoter doesn't bind to service. that is done outside of remoter.

herriojr commented 3 years ago

I'm looking at the kotlin implementation as I was evaluating whether I should use it. Unless I'm misreading it, in the ServiceConnector, upon an onServiceDisconnected, you explicitly clear the service binder, which when a call to getService() happens, will cause it to try to explicitly bind to the service again with the same ServiceConnection, however, the ServiceConnection was never removed (unbindService()). Ideally, upon onServiceDisconnected(), all clients should wait for the onServiceConnected() call to happen unless a call to onBindingDied() gets called, in which case, you need to unbind then bind again (however, IDK if you really want to in this case because it means the remote process is in a death spiral).

The reason for all this is that there is retry logic to bring up bound service in case of failure. For the most part, if the failures aren't happening one after the other, you should always get a call back on onServiceConnected at some point unless you get a call to onBindingDied. If you get a call to onBindingDied, it means that the process you are trying to communicate to is in a death spiral and it's probably best to provide some way to notify the user of this API that this is the case as what should happen next really depends on how they want to handle it.

josesamuel commented 3 years ago

Thanks for the info!. Will take care of it soon and will comment here once done

josesamuel commented 2 years ago

Fixed in version 2.0.3. Added more tests and sample to cover this