Propagate exception information through BinderRunner
Use exceptions to provide better error messages for Geocoder APIs. Test: presubmits Change-Id: Idd8a02d5ff8ec211d4855aefeae55d28943a3e5e
This commit is contained in:
@@ -83,9 +83,9 @@ public class GeocoderProxy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
public void onError(Throwable t) {
|
||||
try {
|
||||
listener.onResults("Service not Available", Collections.emptyList());
|
||||
listener.onResults(t.toString(), Collections.emptyList());
|
||||
} catch (RemoteException e) {
|
||||
// ignore
|
||||
}
|
||||
@@ -110,9 +110,9 @@ public class GeocoderProxy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
public void onError(Throwable t) {
|
||||
try {
|
||||
listener.onResults("Service not Available", Collections.emptyList());
|
||||
listener.onResults(t.toString(), Collections.emptyList());
|
||||
} catch (RemoteException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
public void onError(Throwable t) {
|
||||
synchronized (mLock) {
|
||||
mFlushListeners.remove(callback);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public interface ServiceWatcher {
|
||||
* cleanup in response to a single binder operation, it should not be used to propagate
|
||||
* errors further. Run on the ServiceWatcher thread.
|
||||
*/
|
||||
default void onError() {}
|
||||
default void onError(Throwable t) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.DeadObjectException;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
@@ -239,7 +240,7 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
|
||||
Preconditions.checkState(Looper.myLooper() == mHandler.getLooper());
|
||||
|
||||
if (mBinder == null) {
|
||||
operation.onError();
|
||||
operation.onError(new DeadObjectException());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -249,7 +250,7 @@ class ServiceWatcherImpl<TBoundServiceInfo extends BoundServiceInfo> implements
|
||||
// binders may propagate some specific non-RemoteExceptions from the other side
|
||||
// through the binder as well - we cannot allow those to crash the system server
|
||||
Log.e(TAG, "[" + mTag + "] error running operation on " + mBoundServiceInfo, e);
|
||||
operation.onError();
|
||||
operation.onError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user