Merge "Propagate exception information through BinderRunner"

This commit is contained in:
TreeHugger Robot
2022-01-27 02:32:06 +00:00
committed by Android (Google) Code Review
4 changed files with 9 additions and 8 deletions

View File

@@ -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
}

View File

@@ -208,7 +208,7 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements
}
@Override
public void onError() {
public void onError(Throwable t) {
synchronized (mLock) {
mFlushListeners.remove(callback);
}

View File

@@ -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) {}
}
/**

View File

@@ -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);
}
}