Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34335379 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Propagate exception information through BinderRunner

Use exceptions to provide better error messages for Geocoder APIs.

Test: presubmits
Change-Id: Idd8a02d5ff8ec211d4855aefeae55d28943a3e5e
parent 33abaa26
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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
                }
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ public class ProxyLocationProvider extends AbstractLocationProvider implements
            }

            @Override
            public void onError() {
            public void onError(Throwable t) {
                synchronized (mLock) {
                    mFlushListeners.remove(callback);
                }
+1 −1
Original line number Diff line number Diff line
@@ -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) {}
    }

    /**
+3 −2
Original line number Diff line number Diff line
@@ -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);
            }
        }