diff options
author | 2020-03-04 11:02:51 -0800 | |
---|---|---|
committer | 2020-03-04 11:04:09 -0800 | |
commit | c178f80d4703a715ce4cfc4238e11cc6d38d2861 (patch) | |
tree | 8c79ed0cab86d371d80a9ba3b7126b8aef0ca93d /location/lib/java | |
parent | 054e5a3b132c24eeba45207cd3eec0225e1d46f6 (diff) |
Make calls for geocoder one way
All calls out of system server must be oneway to prevent the system from
being blocked by external code. Geocode has been the very last interface
not to conform to this - this is now fixed.
Bug: 146677166
Test: atest GeocoderTest
Change-Id: Ib04d36a9b759f1737ebc2806e49f0bf1e53cea7c
Diffstat (limited to 'location/lib/java')
-rw-r--r-- | location/lib/java/com/android/location/provider/GeocodeProvider.java | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/location/lib/java/com/android/location/provider/GeocodeProvider.java b/location/lib/java/com/android/location/provider/GeocodeProvider.java index f7f3d82169a7..05d793542202 100644 --- a/location/lib/java/com/android/location/provider/GeocodeProvider.java +++ b/location/lib/java/com/android/location/provider/GeocodeProvider.java @@ -16,12 +16,14 @@ package com.android.location.provider; -import android.os.IBinder; - import android.location.Address; import android.location.GeocoderParams; +import android.location.IGeocodeListener; import android.location.IGeocodeProvider; +import android.os.IBinder; +import android.os.RemoteException; +import java.util.ArrayList; import java.util.List; /** @@ -38,19 +40,32 @@ import java.util.List; public abstract class GeocodeProvider { private IGeocodeProvider.Stub mProvider = new IGeocodeProvider.Stub() { - public String getFromLocation(double latitude, double longitude, int maxResults, - GeocoderParams params, List<Address> addrs) { - return GeocodeProvider.this.onGetFromLocation(latitude, longitude, maxResults, - params, addrs); + @Override + public void getFromLocation(double latitude, double longitude, int maxResults, + GeocoderParams params, IGeocodeListener listener) { + List<Address> results = new ArrayList<>(); + String error = onGetFromLocation(latitude, longitude, maxResults, params, results); + try { + listener.onResults(error, results); + } catch (RemoteException e) { + // ignore + } } - public String getFromLocationName(String locationName, + @Override + public void getFromLocationName(String locationName, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude, int maxResults, - GeocoderParams params, List<Address> addrs) { - return GeocodeProvider.this.onGetFromLocationName(locationName, lowerLeftLatitude, + GeocoderParams params, IGeocodeListener listener) { + List<Address> results = new ArrayList<>(); + String error = onGetFromLocationName(locationName, lowerLeftLatitude, lowerLeftLongitude, upperRightLatitude, upperRightLongitude, - maxResults, params, addrs); + maxResults, params, results); + try { + listener.onResults(error, results); + } catch (RemoteException e) { + // ignore + } } }; |