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

Commit 7200cd5a authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Allow Throwable to represent errors

Previously used Exception, but there's no good reason not to allow any
Throwable instead which allows for slightly more client flexibility.

Bug: 229872126
Test: atest GeocodeProviderBaseTest
Change-Id: Ie81f00dd2c082c331c10045e93fbeb8f2a393354
parent 1d651eb2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -616,8 +616,8 @@ package android.location.provider {
  @FlaggedApi(Flags.FLAG_NEW_GEOCODER) public abstract class GeocodeProviderBase {
    ctor public GeocodeProviderBase(@NonNull android.content.Context, @NonNull String);
    method @NonNull public final android.os.IBinder getBinder();
    method public abstract void onForwardGeocode(@NonNull android.location.provider.ForwardGeocodeRequest, @NonNull android.os.OutcomeReceiver<java.util.List<android.location.Address>,java.lang.Exception>);
    method public abstract void onReverseGeocode(@NonNull android.location.provider.ReverseGeocodeRequest, @NonNull android.os.OutcomeReceiver<java.util.List<android.location.Address>,java.lang.Exception>);
    method public abstract void onForwardGeocode(@NonNull android.location.provider.ForwardGeocodeRequest, @NonNull android.os.OutcomeReceiver<java.util.List<android.location.Address>,java.lang.Throwable>);
    method public abstract void onReverseGeocode(@NonNull android.location.provider.ReverseGeocodeRequest, @NonNull android.os.OutcomeReceiver<java.util.List<android.location.Address>,java.lang.Throwable>);
    field public static final String ACTION_GEOCODE_PROVIDER = "com.android.location.service.GeocodeProvider";
  }

+4 −4
Original line number Diff line number Diff line
@@ -104,14 +104,14 @@ public abstract class GeocodeProviderBase {
     */
    public abstract void onForwardGeocode(
            @NonNull ForwardGeocodeRequest request,
            @NonNull OutcomeReceiver<List<Address>, Exception> callback);
            @NonNull OutcomeReceiver<List<Address>, Throwable> callback);

    /**
     * Requests reverse geocoding of the given arguments. The given callback must be invoked once.
     */
    public abstract void onReverseGeocode(
            @NonNull ReverseGeocodeRequest request,
            @NonNull OutcomeReceiver<List<Address>, Exception> callback);
            @NonNull OutcomeReceiver<List<Address>, Throwable> callback);

    private class Service extends IGeocodeProvider.Stub {
        @Override
@@ -145,7 +145,7 @@ public abstract class GeocodeProviderBase {
        }
    }

    private static class SingleUseCallback implements OutcomeReceiver<List<Address>, Exception> {
    private static class SingleUseCallback implements OutcomeReceiver<List<Address>, Throwable> {

        private final AtomicReference<IGeocodeCallback> mCallback;

@@ -154,7 +154,7 @@ public abstract class GeocodeProviderBase {
        }

        @Override
        public void onError(Exception e) {
        public void onError(Throwable e) {
            try {
                Objects.requireNonNull(mCallback.getAndSet(null)).onError(e.toString());
            } catch (RemoteException r) {