Skip to content

Commit ca8f4df

Browse files
authored
binder: Improve error descriptions for ServiceConnection callbacks (#12263)
Non-experts don't really know what these ServiceConnection callback names mean (eg b/437170499). Use the Status description to explain them a bit. Compare to #11628
1 parent 8ac5599 commit ca8f4df

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

binder/src/main/java/io/grpc/binder/internal/ServiceBinding.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,32 @@ public void onServiceConnected(ComponentName className, IBinder binder) {
356356
@Override
357357
@MainThread
358358
public void onServiceDisconnected(ComponentName name) {
359-
unbindInternal(Status.UNAVAILABLE.withDescription("onServiceDisconnected: " + name));
359+
unbindInternal(
360+
Status.UNAVAILABLE.withDescription(
361+
"Server process crashed, exited or was killed (onServiceDisconnected): " + name));
360362
}
361363

362364
@Override
363365
@MainThread
364366
public void onNullBinding(ComponentName name) {
365-
unbindInternal(Status.UNIMPLEMENTED.withDescription("onNullBinding: " + name));
367+
unbindInternal(
368+
Status.UNIMPLEMENTED.withDescription(
369+
"Remote Service returned null from onBind() for "
370+
+ bindIntent
371+
+ " (onNullBinding): "
372+
+ name));
366373
}
367374

368375
@Override
369376
@MainThread
370377
public void onBindingDied(ComponentName name) {
371-
unbindInternal(Status.UNAVAILABLE.withDescription("onBindingDied: " + name));
378+
unbindInternal(
379+
Status.UNAVAILABLE.withDescription(
380+
"Remote Service component "
381+
+ name.getClassName()
382+
+ " was disabled, or its package "
383+
+ name.getPackageName()
384+
+ " was disabled, force-stopped, replaced or uninstalled (onBindingDied)."));
372385
}
373386

374387
@VisibleForTesting

0 commit comments

Comments
 (0)